Skip to content

Commit

Permalink
ipn/wg: on hop, reset inner wg tunnel to min mtu
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Nov 13, 2024
1 parent 04b9070 commit 9d01b2c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions intra/ipn/wgproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ func (h *wgproxy) Hop(p Proxy) (err error) {
}()

if p == nil {
// TODO: undo MTU enforced due to any prior hops
old = h.via.Tango(nil)
log.I("wg: %s hop: %s removed", h.id, idhandle(old))
return nil
Expand All @@ -1010,8 +1011,17 @@ func (h *wgproxy) Hop(p Proxy) (err error) {
mtuNeeded := calcNetMtu(int(h.ep.MTU()))

// mtu affordable by this hop
if mtuAvail, err := p.Router().MTU(); err != nil || mtuNeeded > mtuAvail {
return core.OneErr(err, errHopMtuInsufficient)
if mtuAvail, err := p.Router().MTU(); err != nil {
return err
} else if mtuNeeded > mtuAvail {
if mtuNeeded > minmtu6 && mtuAvail > minmtu6 {
tunmtu := calcTunMtu(minmtu6)
h.ep.SetMTU(uint32(tunmtu))
log.I("wg: %s hop: mtu(needed: %d >> avail: %d); set to min: %d",
h.id, mtuNeeded, mtuAvail, tunmtu)
} else {
return errHopMtuInsufficient
}
}

// todo: check if all routes for p & h overlap
Expand Down

0 comments on commit 9d01b2c

Please sign in to comment.