Skip to content

gatewayapi: apply SecurityPolicy authorization to UDP routes - #9836

Closed
zhaohuabing wants to merge 2 commits into
envoyproxy:mainfrom
zhaohuabing:udp-authz-gatewayapi
Closed

gatewayapi: apply SecurityPolicy authorization to UDP routes#9836
zhaohuabing wants to merge 2 commits into
envoyproxy:mainfrom
zhaohuabing:udp-authz-gatewayapi

Conversation

@zhaohuabing

Copy link
Copy Markdown
Member

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.

Stacked on #9835 (IR + xDS), which it needs to compile, and pairs with #9833 (the API change that admits UDPRoute as a target). Part of #9832.

Two things worth a look:

  • 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 new testdata covers that alongside conflict, bogus-sectionName and override precedence.
  • The TCP case also gains the nil listener guard it was missing: GetTCPListener returns nil when not found and tl.Routes was dereferenced unchecked.

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>
@netlify

netlify Bot commented Aug 25, 2026

Copy link
Copy Markdown

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit 1a035d9
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6a8d6078e9017900071e3ec5
😎 Deploy Preview https://deploy-preview-9836--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.08696% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.35%. Comparing base (61f6772) to head (1a035d9).

Files with missing lines Patch % Lines
internal/gatewayapi/securitypolicy.go 71.42% 6 Missing and 6 partials ⚠️
internal/xds/translator/authorization_udp.go 96.66% 1 Missing and 1 partial ⚠️
internal/xds/translator/listener.go 84.61% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zhaohuabing
zhaohuabing deleted the udp-authz-gatewayapi branch August 26, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant