From b48962a69a37fc0f74b29a0a1c33525f963c6e0d Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sun, 9 May 2021 11:27:37 -0500 Subject: [PATCH] limit MTU to no more than what the packetconn claims to support --- go.mod | 2 +- go.sum | 4 ++++ src/tuntap/tun.go | 8 ++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c1c1ab6a..0f3bce55 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/yggdrasil-network/yggdrasil-go go 1.16 require ( - github.com/Arceliar/ironwood v0.0.0-20210508165109-414e0b35fc84 + github.com/Arceliar/ironwood v0.0.0-20210509162436-68a5d50e0d8f github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979 github.com/cheggaaa/pb/v3 v3.0.6 github.com/fatih/color v1.10.0 // indirect diff --git a/go.sum b/go.sum index 233eb143..93e4b3a8 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,10 @@ github.com/Arceliar/ironwood v0.0.0-20210508094446-74a68e4f5970 h1:sKiz18LynwIny github.com/Arceliar/ironwood v0.0.0-20210508094446-74a68e4f5970/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk= github.com/Arceliar/ironwood v0.0.0-20210508165109-414e0b35fc84 h1:hhgFLxGnMXtr1TwnFQcUudSphe7g8i0qB/xgfNlLmHE= github.com/Arceliar/ironwood v0.0.0-20210508165109-414e0b35fc84/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk= +github.com/Arceliar/ironwood v0.0.0-20210509152840-bc3ec5afa1ed h1:LXo+ZsQIx2xI6pbojnhK7PenYNMi3edKI9xSdoX/iSw= +github.com/Arceliar/ironwood v0.0.0-20210509152840-bc3ec5afa1ed/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk= +github.com/Arceliar/ironwood v0.0.0-20210509162436-68a5d50e0d8f h1:kjCfDzlGtM3BD9X5kF8SxvFhghCncYyJb/rxA/NZwK4= +github.com/Arceliar/ironwood v0.0.0-20210509162436-68a5d50e0d8f/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk= github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979 h1:WndgpSW13S32VLQ3ugUxx2EnnWmgba1kCqPkd4Gk1yQ= github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979/go.mod h1:6Lkn+/zJilRMsKmbmG1RPoamiArC6HS73xbwRyp3UyI= github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM= diff --git a/src/tuntap/tun.go b/src/tuntap/tun.go index ba444814..68785cc1 100644 --- a/src/tuntap/tun.go +++ b/src/tuntap/tun.go @@ -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())