Support HTTPRoute destination port matching
This commit is contained in:
parent
eccfcc0924
commit
d317cd90fc
7 changed files with 28 additions and 25 deletions
|
@ -30,12 +30,13 @@ profiles:
|
|||
result: success
|
||||
statistics:
|
||||
Failed: 0
|
||||
Passed: 12
|
||||
Passed: 13
|
||||
Skipped: 0
|
||||
supportedFeatures:
|
||||
- GatewayPort8080
|
||||
- HTTPRouteBackendProtocolH2C
|
||||
- HTTPRouteBackendProtocolWebSocket
|
||||
- HTTPRouteDestinationPortMatching
|
||||
- HTTPRouteHostRewrite
|
||||
- HTTPRouteMethodMatching
|
||||
- HTTPRoutePathRedirect
|
||||
|
@ -50,7 +51,6 @@ profiles:
|
|||
- GatewayStaticAddresses
|
||||
- HTTPRouteBackendRequestHeaderModification
|
||||
- HTTPRouteBackendTimeout
|
||||
- HTTPRouteDestinationPortMatching
|
||||
- HTTPRouteParentRefPort
|
||||
- HTTPRouteRequestMirror
|
||||
- HTTPRouteRequestMultipleMirrors
|
||||
|
|
|
@ -18,6 +18,7 @@ func SupportedFeatures() []features.FeatureName {
|
|||
features.HTTPRouteResponseHeaderModificationFeature.Name,
|
||||
features.HTTPRouteBackendProtocolH2CFeature.Name,
|
||||
features.HTTPRouteBackendProtocolWebSocketFeature.Name,
|
||||
features.HTTPRouteDestinationPortMatchingFeature.Name,
|
||||
features.TLSRouteFeature.Name,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,17 +49,16 @@ func (p *Provider) loadGRPCRoutes(ctx context.Context, gatewayListeners []gatewa
|
|||
}
|
||||
|
||||
for _, listener := range gatewayListeners {
|
||||
if !matchListener(listener, route.Namespace, parentRef) {
|
||||
continue
|
||||
}
|
||||
|
||||
accepted := true
|
||||
if !allowRoute(listener, route.Namespace, kindGRPCRoute) {
|
||||
if !matchListener(listener, route.Namespace, parentRef) {
|
||||
accepted = false
|
||||
}
|
||||
if accepted && !allowRoute(listener, route.Namespace, kindGRPCRoute) {
|
||||
parentStatus.Conditions = updateRouteConditionAccepted(parentStatus.Conditions, string(gatev1.RouteReasonNotAllowedByListeners))
|
||||
accepted = false
|
||||
}
|
||||
hostnames, ok := findMatchingHostnames(listener.Hostname, route.Spec.Hostnames)
|
||||
if !ok {
|
||||
if accepted && !ok {
|
||||
parentStatus.Conditions = updateRouteConditionAccepted(parentStatus.Conditions, string(gatev1.RouteReasonNoMatchingListenerHostname))
|
||||
accepted = false
|
||||
}
|
||||
|
|
|
@ -53,17 +53,16 @@ func (p *Provider) loadHTTPRoutes(ctx context.Context, gatewayListeners []gatewa
|
|||
}
|
||||
|
||||
for _, listener := range gatewayListeners {
|
||||
if !matchListener(listener, route.Namespace, parentRef) {
|
||||
continue
|
||||
}
|
||||
|
||||
accepted := true
|
||||
if !allowRoute(listener, route.Namespace, kindHTTPRoute) {
|
||||
if !matchListener(listener, route.Namespace, parentRef) {
|
||||
accepted = false
|
||||
}
|
||||
if accepted && !allowRoute(listener, route.Namespace, kindHTTPRoute) {
|
||||
parentStatus.Conditions = updateRouteConditionAccepted(parentStatus.Conditions, string(gatev1.RouteReasonNotAllowedByListeners))
|
||||
accepted = false
|
||||
}
|
||||
hostnames, ok := findMatchingHostnames(listener.Hostname, route.Spec.Hostnames)
|
||||
if !ok {
|
||||
if accepted && !ok {
|
||||
parentStatus.Conditions = updateRouteConditionAccepted(parentStatus.Conditions, string(gatev1.RouteReasonNoMatchingListenerHostname))
|
||||
accepted = false
|
||||
}
|
||||
|
|
|
@ -112,6 +112,7 @@ type ExtensionBuilderRegistry interface {
|
|||
type gatewayListener struct {
|
||||
Name string
|
||||
|
||||
Port gatev1.PortNumber
|
||||
Protocol gatev1.ProtocolType
|
||||
TLS *gatev1.GatewayTLSConfig
|
||||
Hostname *gatev1.Hostname
|
||||
|
@ -429,6 +430,7 @@ func (p *Provider) loadGatewayListeners(ctx context.Context, gateway *gatev1.Gat
|
|||
GWName: gateway.Name,
|
||||
GWNamespace: gateway.Namespace,
|
||||
GWGeneration: gateway.Generation,
|
||||
Port: listener.Port,
|
||||
Protocol: listener.Protocol,
|
||||
TLS: listener.TLS,
|
||||
Hostname: listener.Hostname,
|
||||
|
@ -1118,6 +1120,10 @@ func matchListener(listener gatewayListener, routeNamespace string, parentRef ga
|
|||
return false
|
||||
}
|
||||
|
||||
if parentRef.Port != nil && *parentRef.Port != listener.Port {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -49,12 +49,11 @@ func (p *Provider) loadTCPRoutes(ctx context.Context, gatewayListeners []gateway
|
|||
}
|
||||
|
||||
for _, listener := range gatewayListeners {
|
||||
if !matchListener(listener, route.Namespace, parentRef) {
|
||||
continue
|
||||
}
|
||||
|
||||
accepted := true
|
||||
if !allowRoute(listener, route.Namespace, kindTCPRoute) {
|
||||
if !matchListener(listener, route.Namespace, parentRef) {
|
||||
accepted = false
|
||||
}
|
||||
if accepted && !allowRoute(listener, route.Namespace, kindTCPRoute) {
|
||||
parentStatus.Conditions = updateRouteConditionAccepted(parentStatus.Conditions, string(gatev1.RouteReasonNotAllowedByListeners))
|
||||
accepted = false
|
||||
}
|
||||
|
|
|
@ -49,17 +49,16 @@ func (p *Provider) loadTLSRoutes(ctx context.Context, gatewayListeners []gateway
|
|||
}
|
||||
|
||||
for _, listener := range gatewayListeners {
|
||||
if !matchListener(listener, route.Namespace, parentRef) {
|
||||
continue
|
||||
}
|
||||
|
||||
accepted := true
|
||||
if !allowRoute(listener, route.Namespace, kindTLSRoute) {
|
||||
if !matchListener(listener, route.Namespace, parentRef) {
|
||||
accepted = false
|
||||
}
|
||||
if accepted && !allowRoute(listener, route.Namespace, kindTLSRoute) {
|
||||
parentStatus.Conditions = updateRouteConditionAccepted(parentStatus.Conditions, string(gatev1.RouteReasonNotAllowedByListeners))
|
||||
accepted = false
|
||||
}
|
||||
hostnames, ok := findMatchingHostnames(listener.Hostname, route.Spec.Hostnames)
|
||||
if !ok {
|
||||
if accepted && !ok {
|
||||
parentStatus.Conditions = updateRouteConditionAccepted(parentStatus.Conditions, string(gatev1.RouteReasonNoMatchingListenerHostname))
|
||||
accepted = false
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue