@@ -378,21 +378,7 @@ func (lb *ListenerBuilder) buildHTTPConnectionManager(httpOpts *httpListenerOpts
378
378
379
379
// Metadata exchange filter needs to be added before any other HTTP filters are added. This is done to
380
380
// ensure that mx filter comes before HTTP RBAC filter. This is related to https://github.com/istio/istio/issues/41066
381
- if features .MetadataExchange && ! httpOpts .hbone && ! lb .node .IsAmbient () {
382
- if features .NativeMetadataExchange && util .IsIstioVersionGE119 (lb .node .IstioVersion ) {
383
- if httpOpts .class == istionetworking .ListenerClassSidecarInbound {
384
- filters = append (filters , xdsfilters .SidecarInboundMetadataFilter )
385
- } else {
386
- if httpOpts .skipIstioMXHeaders {
387
- filters = append (filters , xdsfilters .SidecarOutboundMetadataFilterSkipHeaders )
388
- } else {
389
- filters = append (filters , xdsfilters .SidecarOutboundMetadataFilter )
390
- }
391
- }
392
- } else {
393
- filters = append (filters , xdsfilters .HTTPMx )
394
- }
395
- }
381
+ filters = appendMxFilter (httpOpts , lb .node , filters )
396
382
// TODO: how to deal with ext-authz? It will be in the ordering twice
397
383
filters = append (filters , lb .authzCustomBuilder .BuildHTTP (httpOpts .class )... )
398
384
filters = extension .PopAppendHTTP (filters , wasm , extensions .PluginPhase_AUTHN )
@@ -449,3 +435,21 @@ func (lb *ListenerBuilder) buildHTTPConnectionManager(httpOpts *httpListenerOpts
449
435
}
450
436
return connectionManager
451
437
}
438
+
439
+ func appendMxFilter (httpOpts * httpListenerOpts , node * model.Proxy , filters []* hcm.HttpFilter ) []* hcm.HttpFilter {
440
+ if ! features .MetadataExchange || httpOpts .hbone || node .IsAmbient () {
441
+ return filters
442
+ }
443
+ if ! features .NativeMetadataExchange || ! util .IsIstioVersionGE119 (node .IstioVersion ) {
444
+ return append (filters , xdsfilters .HTTPMx )
445
+ }
446
+
447
+ if httpOpts .class == istionetworking .ListenerClassSidecarInbound {
448
+ return append (filters , xdsfilters .SidecarInboundMetadataFilter )
449
+ }
450
+
451
+ if httpOpts .skipIstioMXHeaders {
452
+ return append (filters , xdsfilters .SidecarOutboundMetadataFilterSkipHeaders )
453
+ }
454
+ return append (filters , xdsfilters .SidecarOutboundMetadataFilter )
455
+ }
0 commit comments