Repository navigation
fix(configapi): widen only a zero-length prefix of 0.0.0.0 to any - #604
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused change keeps filter rendering and shape counting aligned, with regression coverage for corrected and preserved behavior and no unresolved findings.
No open issues 🎉
What changed in this PR
This PR prevents valid, nonzero-length prefixes beginning with 0.0.0.0 from being widened to any, keeping SDF filter generation and UPF rule-shape validation consistent.
Changes:
- Shares the endpoint-widening check between filter rendering and shape counting.
- Preserves existing behavior for
0.0.0.0/0and legacy non-prefix endpoints. - Adds regression coverage for narrower prefixes and their effect on shape limits.
| File | Description |
|---|---|
| configapi/slice_operations_test.go | Adds filter and shape-limit regression cases and corrects an existing test fixture. |
| configapi/slice_helpers.go | Introduces a shared check that preserves valid narrower prefixes in filters and shape counts. |
Review effort: Balanced
gab-arrobo
approved these changes
Oct 22, 2026
BuildSDFFilter wrote every endpoint beginning 0.0.0.0 as "any", so a rule for 0.0.0.0/1, half the address space, was installed as matching every address. ruleShapeOf mirrored the same test, so the shape count was exact; the widening itself was the defect. Only a prefix of length 0, or an endpoint beginning 0.0.0.0 that does not parse as one prefix (a bare 0.0.0.0, or an endpoint of several fields stored before the endpoint check), is still written as "any": the SMF reads only "any" as a match-all packet filter, and the PCF only a filter ending "any to assigned" as the default QoS flow. A narrower prefix of 0.0.0.0 is written as given, and counts as its own shape. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Edvin Lindqvist <edvin.lindqvist@forsway.com>
gab-arrobo
force-pushed
the
fix/zero-prefix-endpoint
branch
from
October 22, 2026 19:27
ebc71b5 to
e1e739c
Compare
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.
Summary
BuildSDFFilterwrites every endpoint beginning0.0.0.0asany. A rule for0.0.0.0/1, half the address space, is therefore installed as matching every address, and so is any other prefix of0.0.0.0. The slice check from #593 accepts such an endpoint, since it is a valid prefix.ruleShapeOfuses the same test, so the shape count matched what was installed; the widening itself is the defect.After this change:
0.0.0.0/0) is still written asany.0.0.0.0that does not parse as a single prefix: a bare0.0.0.0, or an endpoint of several fields such as0.0.0.0/1 80. Those are unchanged and still written asany. fix(configapi): refuse slices whose rules a UPF has no room to match #593's endpoint check refuses them, so only slices stored before it can hold them.0.0.0.0staysanybecause that is what was installed for it before, and it names no narrower set. Only a parsed prefix longer than 0 bits is now honoured.0.0.0.0, such as0.0.0.0/1or0.0.0.0/30, is written as given, andruleShapeOfcounts it as its own prefix length.Why
/0staysany:any(qos.IsMatchAllIPFilter). A prefix it encodes as a remote address and mask (buildPFCompAddr), which is right for0.0.0.0/1.any to assigned(hasDefaultQosFlowinpolling/pcc_policy_config.go).anyas0.0.0.0/0, so it parses either form.Behaviour change:
0.0.0.0/1pushes the narrower filter after an upgrade. Its rule then matches what it names, not every address.validateUpfRuleShapes. A UPF that was within the shape limit only because the rule counted as the any-traffic shape can now be over it. The next post of a slice on that UPF is then refused until it is brought back under.Testing
TestBuildSDFFilterWritesOnlyAZeroPrefixAsAny:0.0.0.0/0, bare0.0.0.0and stored0.0.0.0/0 80and0.0.0.0/1 80are written asany, and0.0.0.0/1,/30and/32as given.TestValidateUpfRuleShapes:0.0.0.0/1is a ninth shape beside the seven prefixes and match-any.0.0.0.0/30as a rule sharing the any-endpoint shape. That held only because of the widening, so it now uses198.18.0.0/24, a second /24 address.ffa24ba. The shape case answers 200, not 400, and/1,/30and/32are written asany.ruleShapeOfonly, it fails the shape case.BuildSDFFilteronly, it fails the filter test.pre-commit run --all-filespasses on macOS (darwin/arm64) on ebc71b5. That includesgo test -race ./... -count=20and golangci-lint v2.13.2.🤖 Generated with Claude Code