Revert to VPN original MTU (set by WIREGUARD_MTU for example) if ICMP fails
This commit is contained in:
@@ -45,6 +45,7 @@ type Wireguard struct {
|
|||||||
// It has been lowered to 1320 following quite a bit of
|
// It has been lowered to 1320 following quite a bit of
|
||||||
// investigation in the issue:
|
// investigation in the issue:
|
||||||
// https://github.com/qdm12/gluetun/issues/2533.
|
// https://github.com/qdm12/gluetun/issues/2533.
|
||||||
|
// Note this should now be replaced with the PMTUD feature.
|
||||||
MTU uint16 `json:"mtu"`
|
MTU uint16 `json:"mtu"`
|
||||||
// Implementation is the Wireguard implementation to use.
|
// Implementation is the Wireguard implementation to use.
|
||||||
// It can be "auto", "userspace" or "kernelspace".
|
// It can be "auto", "userspace" or "kernelspace".
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ func updateToMaxMTU(ctx context.Context, vpnInterface string,
|
|||||||
return fmt.Errorf("getting VPN interface by name: %w", err)
|
return fmt.Errorf("getting VPN interface by name: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
originalMTU := link.MTU
|
||||||
|
|
||||||
// Note: no point testing for an MTU of 1500, it will never work due to the VPN
|
// Note: no point testing for an MTU of 1500, it will never work due to the VPN
|
||||||
// protocol overhead, so start lower than 1500 according to the protocol used.
|
// protocol overhead, so start lower than 1500 according to the protocol used.
|
||||||
const physicalLinkMTU = 1500
|
const physicalLinkMTU = 1500
|
||||||
@@ -123,10 +125,9 @@ func updateToMaxMTU(ctx context.Context, vpnInterface string,
|
|||||||
case err == nil:
|
case err == nil:
|
||||||
logger.Infof("Setting VPN interface %s MTU to maximum valid MTU %d", vpnInterface, vpnLinkMTU)
|
logger.Infof("Setting VPN interface %s MTU to maximum valid MTU %d", vpnInterface, vpnLinkMTU)
|
||||||
case errors.Is(err, pmtud.ErrMTUNotFound):
|
case errors.Is(err, pmtud.ErrMTUNotFound):
|
||||||
const conservativeMTU = 1300
|
vpnLinkMTU = int(originalMTU)
|
||||||
vpnLinkMTU = conservativeMTU
|
logger.Infof("Reverting VPN interface %s MTU to %d (due to: %s)",
|
||||||
logger.Infof("Setting VPN interface %s MTU to a conservative MTU of %d (due to: %s)",
|
vpnInterface, originalMTU, err)
|
||||||
vpnInterface, conservativeMTU, err)
|
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("path MTU discovering: %w", err)
|
return fmt.Errorf("path MTU discovering: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user