@@ -457,7 +457,6 @@ func (t *Translator) addHCMToXDSListener(
457457
458458 filterChain := & listenerv3.FilterChain {
459459 Filters : filters ,
460- Name : httpsListenerFilterChainName (irListener ),
461460 }
462461
463462 if irListener .TLS != nil {
@@ -481,6 +480,7 @@ func (t *Translator) addHCMToXDSListener(
481480 }
482481 }
483482 filterChain .TransportSocket = tSocket
483+ filterChain .Name = httpsListenerFilterChainName (irListener )
484484
485485 if err := addServerNamesMatch (xdsListener , filterChain , irListener .Hostnames ); err != nil {
486486 return err
@@ -490,10 +490,10 @@ func (t *Translator) addHCMToXDSListener(
490490 } else {
491491 // Add the HTTP filter chain as the default filter chain
492492 // Make sure one does not exist
493- // TODO(zhaohuabing): this branch never gets called, clean the code
494493 if xdsListener .DefaultFilterChain != nil {
495494 return errors .New ("default filter chain already exists" )
496495 }
496+ filterChain .Name = httpListenerDefaultFilterChainName (irListener , t .xdsNameSchemeV2 () )
497497 xdsListener .DefaultFilterChain = filterChain
498498 }
499499
@@ -505,6 +505,16 @@ func routeConfigName(irListener *ir.HTTPListener) string {
505505 return irListener .Name
506506}
507507
508+ // port value is used for the default filter chain name for HTTP listeners, as multiple HTTP listeners are merged into
509+ // one filter chain.
510+ func httpListenerDefaultFilterChainName (irListener * ir.HTTPListener , nameSchemeV2 bool ) string {
511+ if nameSchemeV2 {
512+ return fmt .Sprint ("http-" , irListener .ExternalPort )
513+ }
514+ // For backward compatibility, we use the listener name as the filter chain name.
515+ return irListener .Name
516+ }
517+
508518// irListener name is used as the filter chain name for HTTPS listener, as Listener is 1:1 mapping to the filter chain
509519// The Gateway API layer ensures that each listener has a unique combination of hostname and port.
510520func httpsListenerFilterChainName (irListener * ir.HTTPListener ) string {
0 commit comments