Don't allow exceeding maximum MTU for a given platform

This commit is contained in:
Neil Alexander 2018-03-03 11:47:14 +00:00
parent 7c0102e43d
commit bec898a326
6 changed files with 46 additions and 5 deletions

View file

@ -9,6 +9,12 @@ import "strings"
import water "github.com/neilalexander/water"
func defaultTUNParameters() tunDefaultParameters {
return tunDefaultParameters{
maxMTU: 65535,
}
}
func (tun *tunDevice) setup(ifname string, iftapmode bool, addr string, mtu int) error {
var config water.Config
if iftapmode {
@ -24,7 +30,7 @@ func (tun *tunDevice) setup(ifname string, iftapmode bool, addr string, mtu int)
panic(err)
}
tun.iface = iface
tun.mtu = mtu //1280 // Lets default to the smallest thing allowed for now
tun.mtu = getMTUFromMax(mtu)
return tun.setupAddress(addr)
}