diff --git a/src/tuntap/tun.go b/src/tuntap/tun.go index 6feb533b..1e994ea5 100644 --- a/src/tuntap/tun.go +++ b/src/tuntap/tun.go @@ -233,6 +233,12 @@ func (tun *TunAdapter) UpdateConfig(config *config.NodeConfig) { // Replace the active configuration with the supplied one tun.config.Replace(*config) + // If the MTU has changed in the TUN/TAP module then this is where we would + // tell the router so that updated session pings can be sent. However, we + // don't currently update the MTU of the adapter once it has been created so + // this doesn't actually happen in the real world yet. + // tun.core.SetMaximumSessionMTU(...) + // Notify children about the configuration change tun.Act(nil, tun.ckr.configure) } diff --git a/src/yggdrasil/api.go b/src/yggdrasil/api.go index e6b32e68..7f82c260 100644 --- a/src/yggdrasil/api.go +++ b/src/yggdrasil/api.go @@ -364,19 +364,23 @@ func (c *Core) SetNodeInfo(nodeinfo interface{}, nodeinfoprivacy bool) { } // GetMaximumSessionMTU returns the maximum allowed session MTU size. -func (c *Core) GetMaximumSessionMTU(mtu uint16) uint16 { - mtu := 0 - phony.Block(c.router, func() { +func (c *Core) GetMaximumSessionMTU() uint16 { + var mtu uint16 + phony.Block(&c.router, func() { mtu = c.router.sessions.myMaximumMTU }) return mtu } // SetMaximumSessionMTU sets the maximum allowed session MTU size. The default -// value is 65535 bytes. +// value is 65535 bytes. Session pings will be sent to update all open sessions +// if the MTU has changed. func (c *Core) SetMaximumSessionMTU(mtu uint16) { - phony.Block(c.router, func() { - c.router.sessions.myMaximumMTU = mtu + phony.Block(&c.router, func() { + if c.router.sessions.myMaximumMTU != mtu { + c.router.sessions.myMaximumMTU = mtu + c.router.sessions.reconfigure() + } }) } diff --git a/src/yggdrasil/session.go b/src/yggdrasil/session.go index 78b0a3b2..c203fe2f 100644 --- a/src/yggdrasil/session.go +++ b/src/yggdrasil/session.go @@ -55,10 +55,6 @@ type sessionInfo struct { callbacks []chan func() // Finished work from crypto workers } -func (sinfo *sessionInfo) reconfigure() { - // This is where reconfiguration would go, if we had anything to do -} - // Represents a session ping/pong packet, andincludes information like public keys, a session handle, coords, a timestamp to prevent replays, and the tun/tap MTU. type sessionPing struct { SendPermPub crypto.BoxPubKey // Sender's permanent key @@ -138,9 +134,12 @@ func (ss *sessions) init(r *router) { } func (ss *sessions) reconfigure() { - for _, session := range ss.sinfos { - session.reconfigure() - } + ss.router.Act(nil, func() { + for _, session := range ss.sinfos { + session.myMTU = ss.myMaximumMTU + session.ping(ss.router) + } + }) } // Determines whether the session with a given publickey is allowed based on