Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
port: 1234
- name: udp
protocol: UDP
port: 1234
port: 2345
- name: tls-passthrough
protocol: TLS
port: 8443
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
port: 1234
- name: udp
protocol: UDP
port: 1234
port: 2345
- name: tls-passthrough
protocol: TLS
port: 8443
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
port: 1234
- name: udp
protocol: UDP
port: 1234
port: 2345
- name: tls-passthrough
protocol: TLS
port: 8443
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: http
supportedKinds:
- group: gateway.networking.k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: http
supportedKinds:
- group: gateway.networking.k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ gateways:
namespaces:
from: Same
name: udp
port: 1234
port: 2345
protocol: UDP
- allowedRoutes:
namespaces:
Expand Down Expand Up @@ -259,6 +259,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: tcp
supportedKinds:
- group: gateway.networking.k8s.io
Expand All @@ -280,6 +285,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: udp
supportedKinds:
- group: gateway.networking.k8s.io
Expand All @@ -301,6 +311,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: tls-passthrough
supportedKinds:
- group: gateway.networking.k8s.io
Expand All @@ -322,6 +337,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: http
supportedKinds:
- group: gateway.networking.k8s.io
Expand All @@ -343,6 +363,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: grpc
supportedKinds:
- group: gateway.networking.k8s.io
Expand Down Expand Up @@ -1477,7 +1502,7 @@ xds:
address:
socketAddress:
address: 0.0.0.0
portValue: 1234
portValue: 2345
protocol: UDP
listenerFilters:
- name: envoy.filters.udp_listener.udp_proxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: http
supportedKinds:
- group: gateway.networking.k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@
"lastTransitionTime": null,
"reason": "ResolvedRefs",
"message": "Listener references have been resolved"
},
{
"type": "Conflicted",
"status": "False",
"lastTransitionTime": null,
"reason": "NoConflicts",
"message": "No conflicts detected"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@
"address": {
"socketAddress": {
"address": "0.0.0.0",
"portValue": 1234,
"portValue": 2345,
"protocol": "UDP"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ xds:
address:
socketAddress:
address: 0.0.0.0
portValue: 1234
portValue: 2345
protocol: UDP
listenerFilters:
- name: envoy.filters.udp_listener.udp_proxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ xds:
address:
socketAddress:
address: 0.0.0.0
portValue: 1234
portValue: 2345
protocol: UDP
listenerFilters:
- name: envoy.filters.udp_listener.udp_proxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: http
supportedKinds:
- group: gateway.networking.k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ gateways:
namespaces:
from: Same
name: udp
port: 1234
port: 2345
protocol: UDP
- allowedRoutes:
namespaces:
Expand Down Expand Up @@ -103,6 +103,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: tcp
supportedKinds:
- group: gateway.networking.k8s.io
Expand All @@ -124,6 +129,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: udp
supportedKinds:
- group: gateway.networking.k8s.io
Expand All @@ -145,6 +155,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: tls-passthrough
supportedKinds:
- group: gateway.networking.k8s.io
Expand All @@ -166,6 +181,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: http
supportedKinds:
- group: gateway.networking.k8s.io
Expand All @@ -187,6 +207,11 @@ gateways:
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: null
message: No conflicts detected
reason: NoConflicts
status: "False"
type: Conflicted
name: grpc
supportedKinds:
- group: gateway.networking.k8s.io
Expand Down
16 changes: 12 additions & 4 deletions internal/gatewayapi/contexts.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package gatewayapi

import (
"math"

certificatesv1b1 "k8s.io/api/certificates/v1beta1"
corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
Expand Down Expand Up @@ -85,12 +87,18 @@ func (g *GatewayContext) attachEnvoyProxy(resources *resource.Resources, epMap m
}
}

func (g *GatewayContext) IncreaseAttachedListenerSets() {
func (g *GatewayContext) IncreaseAttachedListenerSets(count uint32) {
countInt32 := int32(count)
if g.Status.AttachedListenerSets == nil {
g.Status.AttachedListenerSets = ptr.To[int32](1)
} else {
*g.Status.AttachedListenerSets++
if countInt32 > 0 {
g.Status.AttachedListenerSets = ptr.To(countInt32)
}
return
}

// Check for potential overflow before adding
newValue := int64(*g.Status.AttachedListenerSets) + int64(countInt32)
*g.Status.AttachedListenerSets = int32(min(newValue, math.MaxInt32))
}

// ListenerContext wraps a Listener and provides helper methods for
Expand Down
33 changes: 16 additions & 17 deletions internal/gatewayapi/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ import (
)

const (
TCPProtocol = "TCP"
UDPProtocol = "UDP"

L4Protocol = "L4"
L7Protocol = "L7"
HTTPProtocol = "HTTP"
TCPProtocol = "TCP"
UDPProtocol = "UDP"

// CACertKey is the key used in ConfigMaps and Secrets to store CA certificate data
CACertKey = "ca.crt"
Expand Down Expand Up @@ -381,26 +379,27 @@ func hostnameMatchesWildcardHostname(hostname, wildcardHostname string) bool {
return len(wildcardMatch) > 0
}

func containsPort(ports []*protocolPort, port *protocolPort) bool {
for _, protocolPort := range ports {
curProtocol, curLevel := layer4Protocol(protocolPort)
myProtocol, myLevel := layer4Protocol(port)
if protocolPort.port == port.port && (curProtocol == myProtocol && curLevel == myLevel) {
return true
func checkPortProtocol(gatewayPorts []*protocolPort, servicePort *protocolPort) (bool, bool) {
for _, gatewayPort := range gatewayPorts {
if gatewayPort.port != servicePort.port {
continue
}

return true, listenerProtocol(gatewayPort) == listenerProtocol(servicePort)
}
return false

return false, true
}

// layer4Protocol returns listener L4 protocol and listen protocol level
func layer4Protocol(protocolPort *protocolPort) (string, string) {
// listenerProtocol returns listener L4 protocol and listen protocol level
func listenerProtocol(protocolPort *protocolPort) string {
switch protocolPort.protocol {
case gwapiv1.HTTPProtocolType, gwapiv1.HTTPSProtocolType, gwapiv1.TLSProtocolType:
return TCPProtocol, L7Protocol
return HTTPProtocol
case gwapiv1.TCPProtocolType:
return TCPProtocol, L4Protocol
return TCPProtocol
default:
return UDPProtocol, L4Protocol
return UDPProtocol
}
}

Expand Down
Loading
Loading