@@ -457,7 +457,6 @@ func (t *Translator) addHCMToXDSListener(
457
457
458
458
filterChain := & listenerv3.FilterChain {
459
459
Filters : filters ,
460
- Name : httpsListenerFilterChainName (irListener ),
461
460
}
462
461
463
462
if irListener .TLS != nil {
@@ -481,6 +480,7 @@ func (t *Translator) addHCMToXDSListener(
481
480
}
482
481
}
483
482
filterChain .TransportSocket = tSocket
483
+ filterChain .Name = httpsListenerFilterChainName (irListener )
484
484
485
485
if err := addServerNamesMatch (xdsListener , filterChain , irListener .Hostnames ); err != nil {
486
486
return err
@@ -490,10 +490,10 @@ func (t *Translator) addHCMToXDSListener(
490
490
} else {
491
491
// Add the HTTP filter chain as the default filter chain
492
492
// Make sure one does not exist
493
- // TODO(zhaohuabing): this branch never gets called, clean the code
494
493
if xdsListener .DefaultFilterChain != nil {
495
494
return errors .New ("default filter chain already exists" )
496
495
}
496
+ filterChain .Name = httpListenerDefaultFilterChainName (irListener , t .xdsNameSchemeV2 () )
497
497
xdsListener .DefaultFilterChain = filterChain
498
498
}
499
499
@@ -505,6 +505,16 @@ func routeConfigName(irListener *ir.HTTPListener) string {
505
505
return irListener .Name
506
506
}
507
507
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
+
508
518
// irListener name is used as the filter chain name for HTTPS listener, as Listener is 1:1 mapping to the filter chain
509
519
// The Gateway API layer ensures that each listener has a unique combination of hostname and port.
510
520
func httpsListenerFilterChainName (irListener * ir.HTTPListener ) string {
0 commit comments