Fix: IPSet mutations - #357
Merged
Merged
Conversation
Copilot
AI
changed the title
Fix IP set updates after container mutations
Fix IP set mutations for single-family entries
Jul 28, 2026
Copilot created this pull request from a session on behalf of
Loyalsoldier
July 28, 2026 10:28
View session
There was a problem hiding this comment.
Pull request overview
Fixes two classes of issues in the lib IP entry/container model: (1) avoiding panics when merging/removing entries that only contain a single address family, and (2) ensuring cached *netipx.IPSet values are invalidated whenever the underlying builders are mutated so lookups/marshalling can’t return stale results.
Changes:
- Invalidate
Entrycached IP sets on prefix add/remove mutations. - Guard
IPSetBuilder.AddSet/RemoveSetcalls in container merges/removals when the source family is absent (nilset) and invalidate the destination cache after mutations. - Clear cached sets when dropping builders via ignore/remove-entry paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/entry.go | Clears cached ipv4Set/ipv6Set on prefix add/remove so buildIPSet() rebuilds after mutations. |
| lib/container.go | Skips AddSet/RemoveSet when the incoming family is missing and clears cached sets whenever a builder is mutated or dropped. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+92
to
+97
| if ipv6set != nil { | ||
| if !val.hasIPv6Builder() { | ||
| val.ipv6Builder = new(netipx.IPSetBuilder) | ||
| } | ||
| val.ipv6Builder.AddSet(ipv6set) | ||
| val.ipv6Set = nil |
Loyalsoldier
marked this pull request as ready for review
July 29, 2026 09:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Container operations could panic when entries omitted an address family, while cached IP sets remained stale after later mutations.
Changes
AddSetandRemoveSetcalls when IPv4 or IPv6 data is absent.