mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-10 06:20:26 +00:00
Merge pull request #163 from neilalexander/tapmtu
Cap MTU on Linux in TAP mode
This commit is contained in:
commit
549d6f9dd2
@ -29,6 +29,18 @@ func (tun *tunDevice) setup(ifname string, iftapmode bool, addr string, mtu int)
|
||||
}
|
||||
tun.iface = iface
|
||||
tun.mtu = getSupportedMTU(mtu)
|
||||
// The following check is specific to Linux, as the TAP driver only supports
|
||||
// an MTU of 65535-14 to make room for the ethernet headers. This makes sure
|
||||
// that the MTU gets rounded down to 65521 instead of causing a panic.
|
||||
if iftapmode {
|
||||
if tun.mtu > 65535-tun_ETHER_HEADER_LENGTH {
|
||||
tun.mtu = 65535-tun_ETHER_HEADER_LENGTH
|
||||
}
|
||||
}
|
||||
// Friendly output
|
||||
tun.core.log.Printf("Interface name: %s", tun.iface.Name())
|
||||
tun.core.log.Printf("Interface IPv6: %s", addr)
|
||||
tun.core.log.Printf("Interface MTU: %d", tun.mtu)
|
||||
return tun.setupAddress(addr)
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,10 @@ func (tun *tunDevice) setup(ifname string, iftapmode bool, addr string, mtu int)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// Friendly output
|
||||
tun.core.log.Printf("Interface name: %s", tun.iface.Name())
|
||||
tun.core.log.Printf("Interface IPv6: %s", addr)
|
||||
tun.core.log.Printf("Interface MTU: %d", tun.mtu)
|
||||
return tun.setupAddress(addr)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user