From 007c5159f4cb7d7f7eabdbad53b0e8affd9986b8 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Thu, 19 Feb 2026 17:24:06 +0000 Subject: [PATCH] hotfix(pmtud): increase TCP margin from 150 to 300 compared to ICMP found MTU --- internal/pmtud/pmtud.go | 7 ++++--- internal/pmtud/test/mtu.go | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/pmtud/pmtud.go b/internal/pmtud/pmtud.go index 716f416f..edf07ca6 100644 --- a/internal/pmtud/pmtud.go +++ b/internal/pmtud/pmtud.go @@ -13,7 +13,7 @@ import ( "github.com/qdm12/gluetun/internal/pmtud/tcp" ) -var ErrPMTUDFailICMPAndTCP = errors.New("PMTUD failed with both ICMP and TCP") +var ErrPMTUDFailICMPAndTCP = errors.New("PMTUD succeeded with ICMP but failed with TCP") // PathMTUDiscover discovers the maximum MTU using both ICMP and TCP. // Multiple ICMP addresses and TCP addresses can be specified for redundancy. @@ -66,7 +66,7 @@ func PathMTUDiscover(ctx context.Context, icmpAddrs []netip.Addr, tcpAddrs []net minMTU = constants.MinIPv6MTU } if icmpSuccess { - const mtuMargin = 150 + const mtuMargin = 300 minMTU = max(maxPossibleMTU-mtuMargin, minMTU) } mtu, err = tcp.PathMTUDiscover(ctx, tcpAddrs, minMTU, maxPossibleMTU, tryTimeout, fw, logger) @@ -77,7 +77,8 @@ func PathMTUDiscover(ctx context.Context, icmpAddrs []netip.Addr, tcpAddrs []net return maxPossibleMTU, nil // only rely on ICMP PMTUD results } } - return 0, fmt.Errorf("%w", ErrPMTUDFailICMPAndTCP) + return 0, fmt.Errorf("%w - ignoring ICMP obtained MTU %d", + ErrPMTUDFailICMPAndTCP, maxPossibleMTU) } logger.Debugf("TCP path MTU discovery found maximum valid MTU %d", mtu) return mtu, nil diff --git a/internal/pmtud/test/mtu.go b/internal/pmtud/test/mtu.go index e66976fb..9d3acaa0 100644 --- a/internal/pmtud/test/mtu.go +++ b/internal/pmtud/test/mtu.go @@ -1,6 +1,9 @@ package test -import "math" +import ( + "fmt" + "math" +) // MakeMTUsToTest determines a slice of MTU values to test // between minMTU and maxMTU inclusive. It creates an MTU @@ -17,7 +20,7 @@ func MakeMTUsToTest(minMTU, maxMTU uint32) (mtus []uint32) { diff := maxMTU - minMTU switch { case minMTU > maxMTU: - panic("minMTU > maxMTU") + panic(fmt.Sprintf("minMTU %d is greater than maxMTU %d", minMTU, maxMTU)) case diff <= mtusLength: mtus = make([]uint32, 0, diff) for mtu := minMTU; mtu <= maxMTU; mtu++ {