[v3.32] app-policy: match named ports against the IP+port set key - #13891
Open
dimitri-nicolo wants to merge 1 commit into
Open
dimitri-nicolo wants to merge 1 commit into
dimitri-nicolo wants to merge 1 commit into
Conversation
…ed-ports app-policy: match named ports against the IP+port set key (cherry picked from commit 7753bba)
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Implementation and test coverage are complete; the remaining documentation comment is a non-blocking nit.
Pull request overview
Fixes Dikastes named-port matching by using Felix-compatible IP/protocol/port IP-set keys, including SCTP.
Changes:
- Adds memoized source and destination IP-port keys.
- Updates named-port and IP-port-set matching.
- Expands tests for named ports, negation, source legs, and SCTP.
File summaries
| File | Summary |
|---|---|
app-policy/checker/requestcache.go |
Builds and caches IP-port keys. |
app-policy/checker/requestcache_test.go |
Tests key formatting. |
app-policy/checker/match.go |
Uses IP-port keys and supports SCTP. |
app-policy/checker/match_test.go |
Covers named-port and SCTP scenarios. |
Review details
Suppressed comments (1)
app-policy/checker/match.go:42
- This adds SCTP members to the format accepted by the checker, but the IP-set contract still documents
IP_AND_PORTas onlytcp|udpinfelix/proto/felixbackend.proto:195andapp-policy/policystore/ipset.go:43,50. Please update those contract comments (and regenerated artifacts if required) so consumers are not told that the SCTP members this change relies on are invalid.
132: "sctp",
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
CI triage — CalicoRecommendation: Dig deeper before merging Likely caused by this PR
Unrelated failures
workflow_id: 094d828b-80fc-491b-943a-191dc848dd38 |
electricjesus
approved these changes
Sep 14, 2026
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.
Cherry-pick history
Fixes #13174.
The problem
A policy rule that references a named port never matches in the app-policy checker (Dikastes). An
Allowrule therefore falls through to the default deny, and aDenyrule silently does nothing. The main dataplanes allow the same flow, so ALP and non-ALP disagree.Why
Felix does not hand out a set of port numbers for a named port. It resolves the name against every endpoint that declares it and emits an IP+port set (
IPSetUpdate_IP_AND_PORT) whose members look like10.0.0.1,tcp:8080— the set means "this port, on these endpoints" (felix/calc/rule_scanner.go,felix/labelindex/ipsetmember/ip_set_member.go).Every other dataplane matches it that way:
--match-set <set> src,src/dst,dst(felix/rules/policy.go)(IP, protocol, port)key from the leg the rule names (felix/bpf/polprog/pol_prog_builder.go)matchPort/matchNotPortinapp-policy/checker/match.goinstead looked up the bare port number, e.g."8080", which no member of such a set can equal. The lookup always missed.The change
matchPort/matchNotPorttake the leg's<IP>,<protocol>:<port>accessor and look that key up, matching what the other dataplanes do.requestCachememoizes the source-side key alongside the destination one it already had; both now share anipProtoPortKeyhelper.protocolMapL4gains132: "sctp". A named port can be declared on sctp, and the key would otherwise carry an empty protocol field. This closes the same gap formatchDstIPPortSetIds, which uses the same key.Testing
TestMatchNamedPortsis the reported case plus the wrong-endpoint, wrong-port, wrong-protocol, negated and source-leg variants, and the numeric-OR-named case. I confirmed it reproduces the bug: with the old bare-port lookup restored, three of its cases fail (dst named port matches…,negated dst named port excludes…,src named port matches on the source leg).TestMatchPort(added by #13408 while this PR was open) keyed its named port set on the bare port number; it now uses an IP+port member and gives the flow an IP and protocol.The sctp entry in
protocolMapL4is covered by an sctp named port inTestMatchNamedPorts, an sctp set inTestMatchDstIPPortSetIds, andTestIPProtoPortKey.go test ./app-policy/...passes.Release note: