Add API functions for manipulating maximum session MTU, fix TUN/TAP to use that

This commit is contained in:
Neil Alexander 2019-11-21 00:02:39 +00:00
parent 789307d52b
commit e90be6f569
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 24 additions and 3 deletions

View file

@ -35,6 +35,7 @@ const tun_ETHER_HEADER_LENGTH = 14
// you should pass this object to the yggdrasil.SetRouterAdapter() function
// before calling yggdrasil.Start().
type TunAdapter struct {
core *yggdrasil.Core
writer tunWriter
reader tunReader
config *config.NodeState
@ -131,6 +132,7 @@ func (tun *TunAdapter) Init(core *yggdrasil.Core, config *config.NodeState, log
if !ok {
return fmt.Errorf("invalid options supplied to TunAdapter module")
}
tun.core = core
tun.config = config
tun.log = log
tun.listener = tunoptions.Listener
@ -181,6 +183,7 @@ func (tun *TunAdapter) _start() error {
if tun.MTU() != current.IfMTU {
tun.log.Warnf("Warning: Interface MTU %d automatically adjusted to %d (supported range is 1280-%d)", current.IfMTU, tun.MTU(), MaximumMTU(tun.IsTAP()))
}
tun.core.SetMaximumSessionMTU(uint16(tun.MTU()))
tun.isOpen = true
go tun.handler()
tun.reader.Act(nil, tun.reader._read) // Start the reader