Skip to content

Commit 0c8bc56

Browse files
committed
TUN-7575: Add option to disable PTMU discovery over QUIC
This commit implements the option to disable PTMU discovery for QUIC connections. QUIC finds the PMTU during startup by increasing Ping packet frames until Ping responses are not received anymore, and it seems to stick with that PMTU forever. This is no problem if the PTMU doesn't change over time, but if it does it may case packet drops. We add this hidden flag for debugging purposes in such situations as a quick way to validate if problems that are being seen can be solved by reducing the packet size to the edge. Note however, that this option may impact UDP proxying since we expect being able to send UDP packets of 1280 bytes over QUIC. So, this option should not be used when tunnel is being used for UDP proxying.
1 parent fdab68a commit 0c8bc56

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

cmd/cloudflared/tunnel/cmd.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ const (
8282
// udpUnregisterSessionTimeout is how long we wait before we stop trying to unregister a UDP session from the edge
8383
udpUnregisterSessionTimeoutFlag = "udp-unregister-session-timeout"
8484

85+
// quicDisablePathMTUDiscovery sets if QUIC should not perform PTMU discovery and use a smaller (safe) packet size.
86+
// Packets will then be at most 1252 (IPv4) / 1232 (IPv6) bytes in size.
87+
// Note that this may result in packet drops for UDP proxying, since we expect being able to send at least 1280 bytes of inner packets.
88+
quicDisablePathMTUDiscovery = "quic-disable-pmtu-discovery"
89+
8590
// uiFlag is to enable launching cloudflared in interactive UI mode
8691
uiFlag = "ui"
8792

@@ -692,6 +697,13 @@ func tunnelFlags(shouldHide bool) []cli.Flag {
692697
Value: 5 * time.Second,
693698
Hidden: true,
694699
}),
700+
altsrc.NewBoolFlag(&cli.BoolFlag{
701+
Name: quicDisablePathMTUDiscovery,
702+
EnvVars: []string{"TUNNEL_DISABLE_QUIC_PMTU"},
703+
Usage: "Use this option to disable PTMU discovery for QUIC connections. This will result in lower packet sizes. Not however, that this may cause instability for UDP proxying.",
704+
Value: false,
705+
Hidden: true,
706+
}),
695707
altsrc.NewStringFlag(&cli.StringFlag{
696708
Name: connectorLabelFlag,
697709
Usage: "Use this option to give a meaningful label to a specific connector. When a tunnel starts up, a connector id unique to the tunnel is generated. This is a uuid. To make it easier to identify a connector, we will use the hostname of the machine the tunnel is running on along with the connector ID. This option exists if one wants to have more control over what their individual connectors are called.",

cmd/cloudflared/tunnel/configuration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ func prepareTunnelConfig(
240240
PQKexIdx: pqKexIdx,
241241
MaxEdgeAddrRetries: uint8(c.Int("max-edge-addr-retries")),
242242
UDPUnregisterSessionTimeout: c.Duration(udpUnregisterSessionTimeoutFlag),
243+
DisableQUICPathMTUDiscovery: c.Bool(quicDisablePathMTUDiscovery),
243244
}
244245
packetConfig, err := newPacketConfig(c, log)
245246
if err != nil {

supervisor/tunnel.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ type TunnelConfig struct {
7070
PacketConfig *ingress.GlobalRouterConfig
7171

7272
UDPUnregisterSessionTimeout time.Duration
73+
74+
DisableQUICPathMTUDiscovery bool
7375
}
7476

7577
func (c *TunnelConfig) registrationOptions(connectionID uint8, OriginLocalIP string, uuid uuid.UUID) *tunnelpogs.RegistrationOptions {
@@ -596,14 +598,15 @@ func (e *EdgeTunnelServer) serveQUIC(
596598
}
597599

598600
quicConfig := &quic.Config{
599-
HandshakeIdleTimeout: quicpogs.HandshakeIdleTimeout,
600-
MaxIdleTimeout: quicpogs.MaxIdleTimeout,
601-
KeepAlivePeriod: quicpogs.MaxIdlePingPeriod,
602-
MaxIncomingStreams: quicpogs.MaxIncomingStreams,
603-
MaxIncomingUniStreams: quicpogs.MaxIncomingStreams,
604-
EnableDatagrams: true,
605-
MaxDatagramFrameSize: quicpogs.MaxDatagramFrameSize,
606-
Tracer: quicpogs.NewClientTracer(connLogger.Logger(), connIndex),
601+
HandshakeIdleTimeout: quicpogs.HandshakeIdleTimeout,
602+
MaxIdleTimeout: quicpogs.MaxIdleTimeout,
603+
KeepAlivePeriod: quicpogs.MaxIdlePingPeriod,
604+
MaxIncomingStreams: quicpogs.MaxIncomingStreams,
605+
MaxIncomingUniStreams: quicpogs.MaxIncomingStreams,
606+
EnableDatagrams: true,
607+
MaxDatagramFrameSize: quicpogs.MaxDatagramFrameSize,
608+
Tracer: quicpogs.NewClientTracer(connLogger.Logger(), connIndex),
609+
DisablePathMTUDiscovery: e.config.DisableQUICPathMTUDiscovery,
607610
}
608611

609612
quicConn, err := connection.NewQUICConnection(

0 commit comments

Comments
 (0)