Keep prefixes that do not parse out of the prefix tables (closes #114)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
UpdatePrefixesBatch now skips a prefix that does not parse, so it never becomes a row in prefixes_v4 or prefixes_v6 and never counts in the prefix total in the stats. Before, the prefix handler stored no route for such a prefix and logged it once per prefix and peer, but still passed it to UpdatePrefixesBatch, which stored it. Model: opus-5-5
This commit was merged in pull request #142.
This commit is contained in:
@@ -855,7 +855,7 @@ func insertPrefixesInTable(
|
||||
|
||||
// UpdatePrefixesBatch stores, in a single transaction, the prefixes that are
|
||||
// not stored yet, each first seen at its time in prefixes: the IPv4 prefixes
|
||||
// first and then the IPv6 prefixes.
|
||||
// first and then the IPv6 prefixes. A prefix that does not parse is not stored.
|
||||
func (d *Database) UpdatePrefixesBatch(prefixes map[string]time.Time) error {
|
||||
if len(prefixes) == 0 {
|
||||
return nil
|
||||
@@ -874,6 +874,11 @@ func (d *Database) UpdatePrefixesBatch(prefixes map[string]time.Time) error {
|
||||
prefixesV6 := make(map[string]time.Time)
|
||||
|
||||
for prefix, timestamp := range prefixes {
|
||||
_, err := netip.ParsePrefix(prefix)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if detectIPVersion(prefix) == ipVersionV4 {
|
||||
prefixesV4[prefix] = timestamp
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user