net/art: fix slowPrefixTable bugs found by fuzzing

One is a straight "I forgot how to Go" bug, the others are semantic
mismatches with the main implementation around masking the prefixes
passed to insert/delete.

Updates #7781

Signed-off-by: David Anderson <danderson@tailscale.com>
pull/8701/head
David Anderson 11 months ago committed by Dave Anderson
parent aaca911904
commit 1e6f0bb608

@ -1115,6 +1115,7 @@ type slowPrefixEntry[T any] struct {
}
func (t *slowPrefixTable[T]) delete(pfx netip.Prefix) {
pfx = pfx.Masked()
ret := make([]slowPrefixEntry[T], 0, len(t.prefixes))
for _, ent := range t.prefixes {
if ent.pfx == pfx {
@ -1126,9 +1127,10 @@ func (t *slowPrefixTable[T]) delete(pfx netip.Prefix) {
}
func (t *slowPrefixTable[T]) insert(pfx netip.Prefix, val *T) {
for _, ent := range t.prefixes {
pfx = pfx.Masked()
for i, ent := range t.prefixes {
if ent.pfx == pfx {
ent.val = val
t.prefixes[i].val = val
return
}
}

Loading…
Cancel
Save