From 5b1dc295fea6d0f51c73798e92e0a98b914b94f1 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Thu, 2 Oct 2025 16:47:31 +0000 Subject: [PATCH] Return an error if all MTUs failed to test --- internal/pmtud/pmtud.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/pmtud/pmtud.go b/internal/pmtud/pmtud.go index 1cdabe2c..9ad90e35 100644 --- a/internal/pmtud/pmtud.go +++ b/internal/pmtud/pmtud.go @@ -12,6 +12,8 @@ import ( "golang.org/x/net/icmp" ) +var ErrICMPAllMTUsFailed = errors.New("all MTU sizes tested failed") + // PathMTUDiscover discovers the maximum MTU for the path to the given ip address. // If the physicalLinkMTU is zero, it defaults to 1500 which is the ethernet standard MTU. // If the pingTimeout is zero, it defaults to 1 second. @@ -138,7 +140,7 @@ func pmtudMultiSizes(ctx context.Context, ip netip.Addr, } if tests[0].mtu == minMTU+1 { // All MTUs failed. - return minMTU, nil + return 0, fmt.Errorf("%w", ErrICMPAllMTUsFailed) } // Re-test with MTUs between the minimum MTU // and the smallest next MTU we tested.