gatewayapi: apply SecurityPolicy authorization to UDP routes - #9836
Closed
zhaohuabing wants to merge 2 commits into
Closed
gatewayapi: apply SecurityPolicy authorization to UDP routes#9836zhaohuabing wants to merge 2 commits into
zhaohuabing wants to merge 2 commits into
Conversation
A UDP listener has no network filter chain, so the network RBAC filter used for TCPRoute authorization cannot be reused. Instead the authorization decision rides along with route selection in the matcher that udp_proxy already uses: a datagram whose source IP matches is routed to the cluster, and one that matches nothing is dropped by udp_proxy and counted as downstream_sess_no_route. Because a denial can only be expressed as the absence of a match, the ordered Allow/Deny rules are compiled into allow-only predicates. A Deny rule never becomes an entry of its own; it subtracts from the Allow rules that follow it and from a permissive default action. An allowlist therefore emits one entry per Allow rule with no on_no_match, and a denylist collapses to a single negated entry. Adds Authorization to ir.UDPRoute. Nothing populates it yet. Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
Wires client-IP CIDR authorization through to ir.UDPRoute, for SecurityPolicies targeting a UDPRoute as well as those targeting a Gateway, a Gateway listener, a ListenerSet or a ListenerSet listener — matching what TCP already supports. TCP and UDP accept and reject exactly the same fields, so validateSecurityPolicyForTCP becomes validateSecurityPolicyForL4, taking the protocol name for its error messages. A UDP listener holds at most one route: when several UDPRoutes name the same listener only the oldest is attached, so a policy targeting one of the others has nothing to apply to. The TCP case also gains the nil listener guard it was missing. Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
✅ Deploy Preview for cerulean-figolla-1f9435 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #9836 +/- ##
==========================================
- Coverage 76.36% 76.35% -0.01%
==========================================
Files 261 262 +1
Lines 44537 44630 +93
==========================================
+ Hits 34011 34079 +68
- Misses 8279 8294 +15
- Partials 2247 2257 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Wires client-IP CIDR authorization through to
ir.UDPRoute, for SecurityPolicies targeting aUDPRouteas well as those targeting a Gateway, a Gateway listener, a ListenerSet or a ListenerSet listener — matching what TCP already supports.TCP and UDP accept and reject exactly the same fields, so
validateSecurityPolicyForTCPbecomesvalidateSecurityPolicyForL4, taking the protocol name for its error messages.Stacked on #9835 (IR + xDS), which it needs to compile, and pairs with #9833 (the API change that admits
UDPRouteas a target). Part of #9832.Two things worth a look:
GetTCPListenerreturns nil when not found andtl.Routeswas dereferenced unchecked.