Skip to content

Policy Tiers: feature-flagging, add fuzzer, fix corner cases#43893

Merged
jrajahalme merged 11 commits intomainfrom
feature/policy-pass-verdict-fixes
Feb 6, 2026
Merged

Policy Tiers: feature-flagging, add fuzzer, fix corner cases#43893
jrajahalme merged 11 commits intomainfrom
feature/policy-pass-verdict-fixes

Conversation

@jrajahalme
Copy link
Copy Markdown
Member

@jrajahalme jrajahalme commented Jan 20, 2026

This PR adds an automated fuzzer for detecting logic errors in the Tier support logic. It also fixes any bugs found.

In doing so, it adds support for multiple tiers.

Additionally, this PR does a better job of compartmentalizing the Tier and non-Tier codepaths, When Tiering is not enabled, then the original logic remains. This protects against any possible regressions.

@jrajahalme jrajahalme requested a review from squeed January 20, 2026 21:39
@jrajahalme jrajahalme added kind/bug This is a bug in the Cilium logic. sig/policy Impacts whether traffic is allowed or denied based on user-defined policies. labels Jan 20, 2026
@jrajahalme jrajahalme requested a review from a team as a code owner January 20, 2026 21:39
@jrajahalme jrajahalme added the release-note/misc This PR makes changes that have no direct user impact. label Jan 20, 2026
@jrajahalme jrajahalme requested a review from a team as a code owner January 20, 2026 21:39
@jrajahalme jrajahalme added the dont-merge/discussion A discussion is ongoing and should be resolved before merging, regardless of reviews & tests status. label Jan 20, 2026
@jrajahalme jrajahalme requested review from a team as code owners January 20, 2026 21:39
@jrajahalme jrajahalme force-pushed the feature/policy-pass-verdict-fixes branch 2 times, most recently from 6e592b0 to dfb9fde Compare January 21, 2026 12:00
@jrajahalme jrajahalme force-pushed the feature/policy-pass-verdict-fixes branch from dfb9fde to 96ba262 Compare February 1, 2026 15:57
@jrajahalme jrajahalme requested a review from squeed February 1, 2026 15:58
@jrajahalme jrajahalme force-pushed the feature/policy-pass-verdict-fixes branch from 96ba262 to 0f8c888 Compare February 1, 2026 16:22
@jrajahalme jrajahalme requested a review from a team as a code owner February 1, 2026 16:22
@jrajahalme jrajahalme requested a review from nebril February 1, 2026 16:22
@jrajahalme jrajahalme removed the dont-merge/discussion A discussion is ongoing and should be resolved before merging, regardless of reviews & tests status. label Feb 1, 2026
@jrajahalme
Copy link
Copy Markdown
Member Author

/test

@jrajahalme jrajahalme added the affects/v1.19 This issue affects v1.19 branch label Feb 1, 2026
@jrajahalme jrajahalme force-pushed the feature/policy-pass-verdict-fixes branch from 0f8c888 to d1385c4 Compare February 1, 2026 19:26
@jrajahalme
Copy link
Copy Markdown
Member Author

/test

@jrajahalme
Copy link
Copy Markdown
Member Author

Re-running /ci-multi-pool due to an unrelated bug: #44107

Copy link
Copy Markdown
Member

@nebril nebril left a comment

Choose a reason for hiding this comment

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

ci-structure LGTM

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Feb 2, 2026
squeed and others added 9 commits February 5, 2026 11:52
This generates random policy corpuses and compares MapState-based policy
calculation with the iterative simulator.

Signed-off-by: Casey Callendrello <cdc@isovalent.com>
Avoid using *testing.F for the logger as then any log within the fuzz
test would fail.

Fix the order of expected and actual for require.Equal.

Add more debugging.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
Hide precedence details from the policymap package.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
Add optional mapState indexing by identity to support incremental removal
of generated keys. This is only needed for deletion pass entries, so the
index is only used if the policy has pass verdicts.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
Proper processing of pass verdicts requires the default deny rule to be
explicitly added to the mapstate so that it can be seen by pass verdict
entries.

The default rule is added to the next tier if any non-default tiers or
priorities are in use, of if the traffic direction has any pass
rules. This way the pass rule can pass to the added default deny (or
allow) rule.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
Deny takes precedence over allow and pass, allow takes precedence over
pass. Define new HasPrecedenceOver() to handle this instead of using just
IsDeny() like before.  Would be simpler if Allow was not the zero value,
but changing that would require changing all unit testing code that uses
it as the default.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
Fix tier base priority calculation. When figuring out the priority range
for each tier, the full range of the remaining tiers must be included to
add enough space for pass verdicts on higher tiers. Then, when setting
the base priotity of each tier, this has to be reversed.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
Commit fuzzer cases found during development.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
A pass of a specific identity to a lower tier rule with wildcard identity
should pass the given identity only and keep the wildcard entry at the
original precedence to take care of traffic with other identities. Since
the original entry needs to be kept, a new generated entry with the
identity from the pass entry and the L4 from the passed to entry must be
added.

We missed this case earlier due to BroaderOrEqualKeys only iterating
wildcard identity entries when the new key is a wildcard entry. Entries
that have a broader or equal L4 but more specific L3 are not as a whole
"broader or equal". To handle the need for generated entries for the pass
verdict processing "BroaderOrEqualKeys" is changed to also iterate all
specific L3 keys if the L4 is broader or equal and the given key has the
wildcard identity. The old behavior is retained with
CoveringBroaderOrEqualKeys(). Similarly, NarrowerOrEqualKeys() is renamed
as CoveringNarrowerOrEqualKeys() while NarrowerOrEqualKeys() now also
iterates keys with the wildcard identity when the given key has a
specific identity.

The addition of generated entries requires these entries to be deleted
when that identity is incrementally deleted. Since selector cache is
transactional we can delete all keys with the deleted identity, when the
first key with that identity is deleted. To make this efficient we use
the new id index.

To add support for pass verdicts at multiple tiers, the pass metadata is
now stored as a slice. Overhead to non-pass entries is reduced by storing
the slice via a pointer ('passes'), as most mapStateEntries would not
have any pass metadata.

If 'passes' is non-nil, then the pointed-to slice must have at least
one element, and all elements must have non-zero 'passPrecedence'.

When merging pass metadata we clone the slice to be mutated so that the
same slice can safely be used in multiple entries.

Split insertWithPasses() from insertWithChanges(); insertWithPasses() is
only calling it if the policy has any pass verdicts. This reduces the
chance of regressions for non-pass policies.

Log a warning if a policy with pass verdicts is also using auth
requirements, as this combination has not been implemented. Adjust a test
to not claim all features when that is not the case.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
@jrajahalme jrajahalme force-pushed the feature/policy-pass-verdict-fixes branch from 86a4270 to f8c128b Compare February 5, 2026 11:03
@jrajahalme
Copy link
Copy Markdown
Member Author

/test

1 similar comment
@jrajahalme
Copy link
Copy Markdown
Member Author

/test

@maintainer-s-little-helper maintainer-s-little-helper bot removed the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Feb 5, 2026
@squeed squeed changed the title Policy pass verdict fixes Policy Tiers: feature-flagging, add fuzzer, fix corner cases Feb 6, 2026
Copy link
Copy Markdown
Contributor

@squeed squeed left a comment

Choose a reason for hiding this comment

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

amazing work. really love the extensive comments.

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Feb 6, 2026
@jrajahalme jrajahalme added this pull request to the merge queue Feb 6, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 6, 2026
@jrajahalme jrajahalme added this pull request to the merge queue Feb 6, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 6, 2026
@jrajahalme
Copy link
Copy Markdown
Member Author

main merge is failing/flaking for quay authentication failures, retrying merge.

@jrajahalme jrajahalme added this pull request to the merge queue Feb 6, 2026
Merged via the queue into main with commit 6bc370b Feb 6, 2026
584 of 639 checks passed
@jrajahalme jrajahalme deleted the feature/policy-pass-verdict-fixes branch February 6, 2026 14:44
Comment on lines +46 to +48
// PreviousMapState returns an empty policy.MapState with preallocated map sizes from the current one.
func (e *Endpoint) PreviousMapState() *policy.MapState {
return e.desiredPolicy.GetMapState()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does it really return an empty policy.MapState? The implementation seems to do return &desiredPolicy.policyMapState which seems decidedly like it's returning a pointer to map state currently in use.

@github-actions github-actions bot added the backport-done/1.19 The backport for Cilium 1.19.x for this PR is done. label Feb 17, 2026
@julianwiedmann julianwiedmann removed the needs-backport/1.19 This PR / issue needs backporting to the v1.19 branch label Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

affects/v1.19 This issue affects v1.19 branch backport/author The backport will be carried out by the author of the PR. backport-done/1.19 The backport for Cilium 1.19.x for this PR is done. kind/bug This is a bug in the Cilium logic. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact. sig/policy Impacts whether traffic is allowed or denied based on user-defined policies.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants