Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: add h3 alpn by default if http3 is enabled #2887

Merged
merged 1 commit into from
Mar 12, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions internal/xds/translator/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ func (t *Translator) addXdsHTTPFilterChain(xdsListener *listenerv3.Listener, irL
if irListener.TLS != nil {
var tSocket *corev3.TransportSocket
if http3Listener {
tSocket, err = buildDownstreamQUICTransportSocket(irListener.TLS)
tSocket, err = buildDownstreamQUICTransportSocket(irListener.TLS, http3Listener)
if err != nil {
return err
}
} else {
tSocket, err = buildXdsDownstreamTLSSocket(irListener.TLS)
tSocket, err = buildXdsDownstreamTLSSocket(irListener.TLS, http3Listener)
if err != nil {
return err
}
Expand Down Expand Up @@ -388,7 +388,7 @@ func addXdsTCPFilterChain(xdsListener *listenerv3.Listener, irListener *ir.TCPLi
}

if isTLSTerminate {
tSocket, err := buildXdsDownstreamTLSSocket(irListener.TLS.Terminate)
tSocket, err := buildXdsDownstreamTLSSocket(irListener.TLS.Terminate, false)
if err != nil {
return err
}
Expand Down Expand Up @@ -427,12 +427,12 @@ func addXdsTLSInspectorFilter(xdsListener *listenerv3.Listener) error {
return nil
}

func buildDownstreamQUICTransportSocket(tlsConfig *ir.TLSConfig) (*corev3.TransportSocket, error) {
func buildDownstreamQUICTransportSocket(tlsConfig *ir.TLSConfig, http3Listener bool) (*corev3.TransportSocket, error) {
tlsCtx := &quicv3.QuicDownstreamTransport{
DownstreamTlsContext: &tlsv3.DownstreamTlsContext{
CommonTlsContext: &tlsv3.CommonTlsContext{
TlsParams: buildTLSParams(tlsConfig),
AlpnProtocols: buildALPNProtocols(tlsConfig.ALPNProtocols),
AlpnProtocols: buildALPNProtocols(tlsConfig.ALPNProtocols, http3Listener),
},
},
}
Expand Down Expand Up @@ -468,11 +468,11 @@ func buildDownstreamQUICTransportSocket(tlsConfig *ir.TLSConfig) (*corev3.Transp
}, nil
}

func buildXdsDownstreamTLSSocket(tlsConfig *ir.TLSConfig) (*corev3.TransportSocket, error) {
func buildXdsDownstreamTLSSocket(tlsConfig *ir.TLSConfig, http3Listener bool) (*corev3.TransportSocket, error) {
tlsCtx := &tlsv3.DownstreamTlsContext{
CommonTlsContext: &tlsv3.CommonTlsContext{
TlsParams: buildTLSParams(tlsConfig),
AlpnProtocols: buildALPNProtocols(tlsConfig.ALPNProtocols),
AlpnProtocols: buildALPNProtocols(tlsConfig.ALPNProtocols, http3Listener),
TlsCertificateSdsSecretConfigs: []*tlsv3.SdsSecretConfig{},
},
}
Expand Down Expand Up @@ -551,9 +551,13 @@ func buildTLSVersion(version *ir.TLSVersion) tlsv3.TlsParameters_TlsProtocol {
return tlsv3.TlsParameters_TLS_AUTO
}

func buildALPNProtocols(alpn []string) []string {
func buildALPNProtocols(alpn []string, http3Listener bool) []string {
if len(alpn) == 0 {
return []string{"h2", "http/1.1"}
out := []string{"h2", "http/1.1"}
if http3Listener {
out = append(out, "h3")
}
return out
}
return alpn
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
alpnProtocols:
- h2
- http/1.1
- h3
Comment on lines 43 to +45
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we sort this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought of it, would change every file ..... I'm fine if you are

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can do that in separated, let this one clean.

tlsCertificateSdsSecretConfigs:
- name: envoy-gateway-tls-secret-1
sdsConfig:
Expand Down