Fix setting up of MTU when value is outside of acceptable bounds, also account for ethernet headers in calculations, notify about clipping to stdout

This commit is contained in:
Neil Alexander 2019-11-19 14:20:11 +00:00
parent 17a711ab8a
commit f49d9de421
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
6 changed files with 32 additions and 16 deletions

View file

@ -21,13 +21,13 @@ func (tun *TunAdapter) setup(ifname string, iftapmode bool, addr string, mtu int
panic(err)
}
tun.iface = iface
tun.mtu = getSupportedMTU(mtu)
tun.mtu = getSupportedMTU(mtu, iftapmode)
return tun.setupAddress(addr)
}
// We don't know how to set the IPv6 address on an unknown platform, therefore
// write about it to stdout and don't try to do anything further.
func (tun *TunAdapter) setupAddress(addr string) error {
tun.log.Warnln("Platform not supported, you must set the address of", tun.iface.Name(), "to", addr)
tun.log.Warnln("Warning: Platform not supported, you must set the address of", tun.iface.Name(), "to", addr)
return nil
}