Skip to content

Fix: IPSet mutations - #357

Merged
Loyalsoldier merged 2 commits into
masterfrom
copilot/find-and-fix-potential-bugs
Jul 29, 2026
Merged

Fix: IPSet mutations#357
Loyalsoldier merged 2 commits into
masterfrom
copilot/find-and-fix-potential-bugs

Conversation

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Container operations could panic when entries omitted an address family, while cached IP sets remained stale after later mutations.

Changes

  • Guard AddSet and RemoveSet calls when IPv4 or IPv6 data is absent.
  • Invalidate cached IP sets after adding, removing, or disabling prefixes.
  • Add regression coverage for single-family merges and post-cache mutations.

Copilot AI requested review from Copilot and removed request for Copilot July 28, 2026 10:28
Copilot AI changed the title Fix IP set updates after container mutations Fix IP set mutations for single-family entries Jul 28, 2026
Copilot AI requested a review from Loyalsoldier July 28, 2026 10:28
Copilot AI review requested due to automatic review settings July 29, 2026 09:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Entry cached IP sets on prefix add/remove mutations.
  • Guard IPSetBuilder.AddSet/RemoveSet calls in container merges/removals when the source family is absent (nil set) 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 thread lib/container.go
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
Loyalsoldier marked this pull request as ready for review July 29, 2026 09:55
@Loyalsoldier Loyalsoldier changed the title Fix IP set mutations for single-family entries Fix: IPSet mutations Jul 29, 2026
@Loyalsoldier
Loyalsoldier merged commit 087ef8e into master Jul 29, 2026
5 checks passed
@Loyalsoldier
Loyalsoldier deleted the copilot/find-and-fix-potential-bugs branch July 29, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants