AlinsRan opened a new pull request, #2818:
URL: https://github.com/apache/apisix-ingress-controller/pull/2818

   ### Type of change:
   
   - [x] Bugfix
   
   ### What this PR does / why we need it:
   
   Fixes #2802
   
   `TranslateTCPRoute` / `TranslateUDPRoute` emitted a single `StreamRoute` 
with **no match criteria** (the old `// TODO: ... server_port`). In APISIX 
stream mode a StreamRoute without `server_port` matches every connection on any 
stream listener, so all L4 routes across all Gateways collided onto one backend 
— `parentRefs.sectionName` and per-listener port routing were ignored.
   
   Fix:
   - **Controllers** (`tcproute_controller.go`, `udproute_controller.go`): 
populate `tctx.Listeners` from the listeners `ParseRouteParentRefs` already 
matched for each parentRef — which honors `sectionName`, `port`, protocol and 
`allowedRoutes` — mirroring the HTTPRoute/GRPCRoute path.
   - **Translator** (`tcproute.go`, `udproute.go`): emit **one StreamRoute per 
matched listener port**, each with `ServerPort` set and a port-qualified 
name/ID so multiple listeners no longer collide. A route that matched no 
listener falls back to the previous single portless StreamRoute (backward 
compatible).
   
   Result: a TCPRoute with `sectionName: test1` (listener on 9093) now only 
serves 9093; a route without `sectionName` fans out to one StreamRoute per 
attached listener port.
   
   **Scope:** TLSRoute is intentionally not included — it already sets `SNI` 
(its primary L4 discriminator) and has a separate pre-existing per-host naming 
issue that should be fixed on its own. TCP/UDP `remote_addr`/`server_addr` 
matching remains a future TODO.
   
   ### Pre-submission checklist:
   
   - [x] Did you explain what problem does this PR solve?
   - [x] Have you added corresponding test cases? 
(`l4route_serverport_test.go`: sectionName→single port, multi-listener→distinct 
ServerPorts, dedup, no-listener fallback; TCP + UDP)
   - [ ] Have you modified the corresponding document? (n/a)
   - [x] Is this PR backward compatible? (StreamRoute names/IDs gain a port 
suffix when a listener matched; IDs are controller-managed internal identifiers)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to