Skip to content

fix: CTP port overlap check fails when gateway name is a prefix of another - #9253

Closed
AruneshDwivedi wants to merge 1 commit into
envoyproxy:mainfrom
AruneshDwivedi:fix/ctp-gateway-name-prefix-match
Closed

AruneshDwivedi wants to merge 1 commit into
envoyproxy:mainfrom
AruneshDwivedi:fix/ctp-gateway-name-prefix-match

Conversation

@AruneshDwivedi

@AruneshDwivedi AruneshDwivedi commented Jun 19, 2026 •

Copy link
Copy Markdown

When mergeGateways is enabled, two gateways with names like gw and gw-b on the same port should conflict. They don't, because the prefix check in validatePortOverlapForClientTrafficPolicy uses strings.Index without a trailing slash, so "envoy-gateway/gw" matches "envoy-gateway/gw-b/http".

The same class of bug was fixed in #9026 for extractListenerSetPrefixFromListener by adding a trailing slash. Same approach here.

Changes:

  • extractGatewayNameFromListener(irListenerName) + "/" -- adds trailing slash to the prefix
  • strings.HasPrefix(currName, gatewayName) instead of strings.Index(...) != 0 -- clearer intent, same behavior

Repro: create gateways gw and gw-b both with port 8081, apply a gateway-wide CTP targeting gw. Before this fix it's accepted (wrong). After, it correctly returns an error about multiple listeners on the same port.

Fixes #9226

…lap validation

When mergeGateways is enabled and two Gateways exist where one name is a string prefix of the other (e.g. 'gw' and 'gw-b'), a Gateway-wide ClientTrafficPolicy targeting the shorter-named Gateway was incorrectly accepted even though a same-port HTTP listener exists on the other Gateway.

The port overlap validation used strings.Index without a trailing slash, causing 'envoy-gateway/gw' to falsely match 'envoy-gateway/gw-b/http'. This fix adds a trailing slash to the gateway name prefix and uses strings.HasPrefix for clarity.

Fixes envoyproxy#9226

Signed-off-by: Arunesh Dwivedi <[email protected]>
@netlify

netlify Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit 92d3fa1
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6a34ebd905b19c00096fec72
😎 Deploy Preview https://deploy-preview-9253--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.

@AruneshDwivedi
AruneshDwivedi marked this pull request as ready for review June 19, 2026 08:06
@AruneshDwivedi
AruneshDwivedi requested a review from a team as a code owner June 19, 2026 08:06
@AruneshDwivedi AruneshDwivedi changed the title fix: add trailing slash to gateway name prefix check in CTP port overlap validation fix: CTP port overlap check fails when gateway name is a prefix of another Jun 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions!

@github-actions github-actions Bot added the stale label Jul 19, 2026
@arkodg
arkodg requested a review from zhaohuabing July 20, 2026 04:36
@arkodg arkodg added this to the v1.9.0-rc.1 Release milestone Jul 20, 2026
@github-actions github-actions Bot removed the stale label Jul 20, 2026
@zirain

zirain commented Jul 21, 2026

Copy link
Copy Markdown
Member

@AruneshDwivedi can you fix a conflict and add a testcase?

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway-wide CTP incorrectly accepted when Gateway name is a prefix of another Gateway name (mergeGateways)

4 participants