Skip to content

Commit

Permalink
http3: use service port in alt-svc header (#2886)
Browse files Browse the repository at this point in the history
Fixes: #2882

Signed-off-by: Arko Dasgupta <arko@tetrate.io>
  • Loading branch information
arkodg authored Mar 12, 2024
1 parent 3ff6f13 commit 76340b5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions internal/gatewayapi/clienttrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ func (t *Translator) translateClientTrafficPolicyForListener(policy *egv1a1.Clie

// enable http3 if set and TLS is enabled
if httpIR.TLS != nil && policy.Spec.HTTP3 != nil {
httpIR.HTTP3 = &ir.HTTP3Settings{}
http3 := &ir.HTTP3Settings{
QUICPort: int32(l.Port),
}
httpIR.HTTP3 = http3
var proxyListenerIR *ir.ProxyListener
for _, proxyListener := range infraIR[irKey].Proxy.Listeners {
if proxyListener.Name == irListenerName {
Expand All @@ -327,7 +330,7 @@ func (t *Translator) translateClientTrafficPolicyForListener(policy *egv1a1.Clie
}
}
if proxyListenerIR != nil {
proxyListenerIR.HTTP3 = &ir.HTTP3Settings{}
proxyListenerIR.HTTP3 = http3
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ infraIR:
proxy:
listeners:
- address: null
http3: {}
http3:
quicPort: 443
name: envoy-gateway/gateway-1/tls
ports:
- containerPort: 10443
Expand All @@ -127,7 +128,8 @@ xdsIR:
- address: 0.0.0.0
hostnames:
- '*'
http3: {}
http3:
quicPort: 443
isHTTP2: false
name: envoy-gateway/gateway-1/tls
path:
Expand Down
1 change: 1 addition & 0 deletions internal/ir/infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type ProxyListener struct {

// HTTP3Settings provides HTTP/3 configuration on the listener.
type HTTP3Settings struct {
QUICPort int32 `json:"quicPort" yaml:"quicPort"`
}

// ListenerPort defines a network port of a listener.
Expand Down
3 changes: 2 additions & 1 deletion internal/xds/translator/testdata/in/xds-ir/http3.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
http:
- address: 0.0.0.0
http3: {}
http3:
quicPort: 443
hostnames:
- '*'
isHTTP2: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- append: true
header:
key: alt-svc
value: h3=":10443"; ma=86400
value: h3=":443"; ma=86400
route:
cluster: httproute/default/httproute-1/rule/0
upgradeConfigs:
Expand Down
2 changes: 1 addition & 1 deletion internal/xds/translator/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (t *Translator) processHTTPListenerXdsTranslation(
}

if enabledHTTP3 {
http3AltSvcHeader := buildHTTP3AltSvcHeader(int(httpListener.Port))
http3AltSvcHeader := buildHTTP3AltSvcHeader(int(httpListener.HTTP3.QUICPort))
if xdsRoute.ResponseHeadersToAdd == nil {
xdsRoute.ResponseHeadersToAdd = make([]*corev3.HeaderValueOption, 0)
}
Expand Down

0 comments on commit 76340b5

Please sign in to comment.