mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-10 04:30:20 +02:00
chore(pmtud): clarify debug logs and fix log error message
This commit is contained in:
@@ -20,17 +20,17 @@ func PathMTUDiscover(ctx context.Context, ip netip.Addr,
|
|||||||
physicalLinkMTU uint32, timeout time.Duration, logger Logger,
|
physicalLinkMTU uint32, timeout time.Duration, logger Logger,
|
||||||
) (mtu uint32, err error) {
|
) (mtu uint32, err error) {
|
||||||
if ip.Is4() {
|
if ip.Is4() {
|
||||||
logger.Debug("finding IPv4 next hop MTU")
|
logger.Debugf("finding IPv4 next hop MTU to %s", ip)
|
||||||
mtu, err = findIPv4NextHopMTU(ctx, ip, physicalLinkMTU, timeout, logger)
|
mtu, err = findIPv4NextHopMTU(ctx, ip, physicalLinkMTU, timeout, logger)
|
||||||
switch {
|
switch {
|
||||||
case err == nil:
|
case err == nil:
|
||||||
return mtu, nil
|
return mtu, nil
|
||||||
case errors.Is(err, errTimeout) || errors.Is(err, ErrCommunicationAdministrativelyProhibited): // blackhole
|
case errors.Is(err, errTimeout) || errors.Is(err, ErrCommunicationAdministrativelyProhibited): // blackhole
|
||||||
default:
|
default:
|
||||||
return 0, fmt.Errorf("finding IPv4 next hop MTU: %w", err)
|
return 0, fmt.Errorf("finding IPv4 next hop MTU to %s: %w", ip, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.Debug("requesting IPv6 ICMP packet-too-big reply")
|
logger.Debugf("requesting IPv6 ICMP packet-too-big reply from %s", ip)
|
||||||
mtu, err = getIPv6PacketTooBig(ctx, ip, physicalLinkMTU, timeout, logger)
|
mtu, err = getIPv6PacketTooBig(ctx, ip, physicalLinkMTU, timeout, logger)
|
||||||
switch {
|
switch {
|
||||||
case err == nil:
|
case err == nil:
|
||||||
@@ -43,7 +43,7 @@ func PathMTUDiscover(ctx context.Context, ip netip.Addr,
|
|||||||
|
|
||||||
// Fall back method: send echo requests with different packet
|
// Fall back method: send echo requests with different packet
|
||||||
// sizes and check which ones succeed to find the maximum MTU.
|
// sizes and check which ones succeed to find the maximum MTU.
|
||||||
logger.Debug("falling back to sending different sized echo packets")
|
logger.Debugf("falling back to sending different sized echo packets to %s", ip)
|
||||||
minMTU := constants.MinIPv4MTU
|
minMTU := constants.MinIPv4MTU
|
||||||
if ip.Is6() {
|
if ip.Is6() {
|
||||||
minMTU = constants.MinIPv6MTU
|
minMTU = constants.MinIPv6MTU
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/pmtud/tcp"
|
"github.com/qdm12/gluetun/internal/pmtud/tcp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrPMTUDFailICMPAndTCP = errors.New("PMTUD succeeded with ICMP but failed with TCP")
|
var (
|
||||||
|
ErrICMPOkTCPFail = errors.New("PMTUD succeeded with ICMP but failed with TCP")
|
||||||
|
ErrICMPFailTCPFail = errors.New("PMTUD failed with both ICMP and TCP")
|
||||||
|
)
|
||||||
|
|
||||||
// PathMTUDiscover discovers the maximum MTU using both ICMP and TCP.
|
// PathMTUDiscover discovers the maximum MTU using both ICMP and TCP.
|
||||||
// Multiple ICMP addresses and TCP addresses can be specified for redundancy.
|
// Multiple ICMP addresses and TCP addresses can be specified for redundancy.
|
||||||
@@ -77,8 +80,11 @@ func PathMTUDiscover(ctx context.Context, icmpAddrs []netip.Addr, tcpAddrs []net
|
|||||||
return maxPossibleMTU, nil // only rely on ICMP PMTUD results
|
return maxPossibleMTU, nil // only rely on ICMP PMTUD results
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%w - ignoring ICMP obtained MTU %d",
|
if icmpSuccess {
|
||||||
ErrPMTUDFailICMPAndTCP, maxPossibleMTU)
|
return 0, fmt.Errorf("%w - discarding ICMP obtained MTU %d",
|
||||||
|
ErrICMPOkTCPFail, maxPossibleMTU)
|
||||||
|
}
|
||||||
|
return 0, fmt.Errorf("%w", ErrICMPFailTCPFail)
|
||||||
}
|
}
|
||||||
logger.Debugf("TCP path MTU discovery found maximum valid MTU %d", mtu)
|
logger.Debugf("TCP path MTU discovery found maximum valid MTU %d", mtu)
|
||||||
return mtu, nil
|
return mtu, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user