Skip to content

Commit 2a804ec

Browse files
committed
Set the QUIC InitialPacketSize to 1200 bytes
quic-go defaults the `InitialPacketSize` to 1280 bytes. This is used for the size of the payload plus UDP header. When quic-go creates its initial handshake packet, it pads it to this size as an optimization for the anti-amplification limit (which does not really apply to Caddy's server connections). Tailscale uses an MTU of 1280 (the minimum IPv6 MTU) because it is a tunnel operating in unknown environments, possibly inside other tunnels. When wrapped in an IP header (either v4 or v6), the 1280 byte QUIC packet constructed by quic-go exceeds the Tailscale MTU and gets dropped. This makes it impossible to respond to an HTTP3 connection attempt over Tailscale when using the default `InitialPacketSize`. We explicitly set the `InitialPacketSize` to 1200 (its minimum) to support HTTP3 connections over Tailscale and other low MTU connections. Once the connection is established, quic-go can perform MTU discovery to increase the packet size to the maximum supported by the connection, so any throughput loss due to the lowered `InitialPacketSize` is short-lived.
1 parent 873fac5 commit 2a804ec

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

listeners.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,9 @@ func (na NetworkAddress) ListenQUIC(ctx context.Context, portOffset uint, config
480480
earlyLn, err := tr.ListenEarly(
481481
http3.ConfigureTLSConfig(quicTlsConfig),
482482
&quic.Config{
483-
Allow0RTT: allow0rtt,
484-
Tracer: h3qlog.DefaultConnectionTracer,
483+
InitialPacketSize: 1200,
484+
Allow0RTT: allow0rtt,
485+
Tracer: h3qlog.DefaultConnectionTracer,
485486
},
486487
)
487488
if err != nil {

modules/caddyhttp/server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,9 @@ func (s *Server) serveHTTP3(addr caddy.NetworkAddress, tlsCfg *tls.Config) error
825825
TLSConfig: tlsCfg,
826826
MaxHeaderBytes: s.MaxHeaderBytes,
827827
QUICConfig: &quic.Config{
828-
Versions: []quic.Version{quic.Version1, quic.Version2},
829-
Tracer: h3qlog.DefaultConnectionTracer,
828+
Versions: []quic.Version{quic.Version1, quic.Version2},
829+
InitialPacketSize: 1200,
830+
Tracer: h3qlog.DefaultConnectionTracer,
830831
},
831832
IdleTimeout: time.Duration(s.IdleTimeout),
832833
}

0 commit comments

Comments
 (0)