limit MTU to no more than what the packetconn claims to support

This commit is contained in:
Arceliar 2021-05-09 11:27:37 -05:00
parent 3bfd891fd4
commit b48962a69a
3 changed files with 11 additions and 3 deletions

View file

@ -156,10 +156,14 @@ func (tun *TunAdapter) _start() error {
tun.log.Debugln("Not starting TUN as ifname is none or dummy")
return nil
}
if err := tun.setup(current.IfName, addr, current.IfMTU); err != nil {
mtu := current.IfMTU
if tun.core.MTU() < uint64(mtu) {
mtu = MTU(tun.core.MTU())
}
if err := tun.setup(current.IfName, addr, mtu); err != nil {
return err
}
if tun.MTU() != current.IfMTU {
if tun.MTU() != mtu {
tun.log.Warnf("Warning: Interface MTU %d automatically adjusted to %d (supported range is 1280-%d)", current.IfMTU, tun.MTU(), MaximumMTU())
}
// TODO tun.core.SetMaximumSessionMTU(tun.MTU())