@@ -45,6 +45,7 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
4545 t .validateConflictedLayer7Listeners (gateways )
4646 t .validateConflictedLayer4Listeners (gateways , gwapiv1 .TCPProtocolType )
4747 t .validateConflictedLayer4Listeners (gateways , gwapiv1 .UDPProtocolType )
48+ t .validateConflictedProtocolsListeners (gateways )
4849 if t .MergeGateways {
4950 t .validateConflictedMergedListeners (gateways )
5051 }
@@ -104,6 +105,7 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
104105 t .validateHostName (listener )
105106
106107 // Process conditions and check if the listener is ready
108+ << << << < Updated upstream
107109 isReady := t .validateListenerConditions (listener )
108110
109111 if listener .isFromListenerSet () && isReady {
@@ -113,6 +115,12 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
113115 }.String ()
114116 gatewayAttachedListenerSets .Insert (lsKey )
115117 }
118+ == == == =
119+ // TODO: this's skipped in https://github.com/envoyproxy/gateway/pull/8194
120+ // for TLSRouteInvalidNoMatchingListener conformance test, but looks like it's
121+ // a must, consider to skip invalid listener again?
122+ listenerValid := t .validateListenerConditions (listener )
123+ >> >> >> > Stashed changes
116124
117125 address := netutils .IPv4ListenerAddress
118126 ipFamily := getEnvoyIPFamily (gateway .envoyProxy )
@@ -122,7 +130,30 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
122130
123131 // Add the listener to the Xds IR
124132 servicePort := & protocolPort {protocol : listener .Protocol , port : listener .Port }
133+ // Add the listener to the Infra IR.
134+ // Infra IR ports must have a unique port number per layer protocol.
135+ gatewayPortProtocols := foundPorts [irKey ]
136+ portExists , protocolValid := checkPortProtocol (gatewayPortProtocols , servicePort )
137+ if ! protocolValid {
138+ continue
139+ }
140+
141+ if listener .isFromListenerSet () && listenerValid {
142+ lsKey := types.NamespacedName {
143+ Namespace : listener .listenerSet .Namespace ,
144+ Name : listener .listenerSet .Name ,
145+ }.String ()
146+ gatewayAttachedListenerSets .Insert (lsKey )
147+ }
148+ foundPorts [irKey ] = append (foundPorts [irKey ], servicePort )
125149 containerPort := t .servicePortToContainerPort (listener .Port , gateway .envoyProxy )
150+ if ! portExists {
151+ // Only add to Infra IR if the port number is unique for the layer protocol.
152+ // If the same port number is used in another listener with a different protocol,
153+ // it will be skipped when checking port protocol.
154+ t .processInfraIRListener (listener , infraIR , irKey , servicePort , containerPort )
155+ }
156+
126157 switch listener .Protocol {
127158 case gwapiv1 .HTTPProtocolType , gwapiv1 .HTTPSProtocolType :
128159 irListener := & ir.HTTPListener {
@@ -184,14 +215,6 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
184215 }
185216 xdsIR [irKey ].UDP = append (xdsIR [irKey ].UDP , irListener )
186217 }
187-
188- // Add the listener to the Infra IR. Infra IR ports must have a unique port number per layer-4 protocol
189- // (TCP or UDP).
190- if ! containsPort (foundPorts [irKey ], servicePort ) {
191- t .processInfraIRListener (listener , infraIR , irKey , servicePort , containerPort )
192- foundPorts [irKey ] = append (foundPorts [irKey ], servicePort )
193- }
194-
195218 }
196219 gateway .IncreaseAttachedListenerSets (uint32 (len (gatewayAttachedListenerSets )))
197220 }
0 commit comments