Skip to content

[v3.32] Fix typha panic on invalid CIDRs in network policies#12371

Open
caseydavenport wants to merge 1 commit intoprojectcalico:release-v3.32from
caseydavenport:casey-pick-12276-v3.32
Open

[v3.32] Fix typha panic on invalid CIDRs in network policies#12371
caseydavenport wants to merge 1 commit intoprojectcalico:release-v3.32from
caseydavenport:casey-pick-12276-v3.32

Conversation

@caseydavenport
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 7, 2026 18:42
@caseydavenport caseydavenport requested a review from a team as a code owner April 7, 2026 18:42
@caseydavenport caseydavenport added docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact labels Apr 7, 2026
@marvin-tigera marvin-tigera added this to the Calico v3.32.0 milestone Apr 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Typha crash path caused by invalid CIDR strings making it through rule conversion, resulting in nil entries that could trigger a nil pointer dereference when rules are stringified/logged.

Changes:

  • Update NormalizeIPNets to skip unparseable CIDR/IP strings instead of emitting nil entries.
  • Add a regression test that reproduces the invalid-CIDR scenario and asserts no panic plus correct filtering.
  • Harden model.Rule.String() formatting to tolerate nil net entries (avoid nil deref in logging).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
libcalico-go/lib/backend/syncersv1/updateprocessors/rules.go Filters invalid CIDRs out of destination net lists during API v3 → backend rule conversion.
libcalico-go/lib/backend/syncersv1/updateprocessors/rules_test.go Adds regression coverage for invalid CIDR handling and ensures Rule.String() won’t panic.
libcalico-go/lib/backend/model/rule.go Makes Rule.String() robust against nil *net.IPNet entries when joining CIDRs.

Comment on lines 272 to 274
// NormalizeIPNets converts an []*IPNet to a slice of networks by ensuring the IP addresses
// are correctly masked.
// are correctly masked. Unparseable CIDRs are skipped.
func NormalizeIPNets(nets []string) []*cnet.IPNet {
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

The doc comment for NormalizeIPNets is now inaccurate/misleading: the function takes a slice of CIDR/IP strings (not an []*IPNet) and returns a normalized slice, skipping unparseable entries. Suggest updating the comment to match the actual parameter/return types to avoid confusion for future callers.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants