Skip to content

Commit

Permalink
ipn/wg: test mtu compat for hops
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Nov 2, 2024
1 parent 2c6d00c commit 34dc257
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
55 changes: 28 additions & 27 deletions intra/ipn/proxies.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,34 @@ const (
)

var (
errProxyScheme = errors.New("proxy: unsupported scheme")
errUnexpectedProxy = errors.New("proxy: unexpected type")
errAddProxy = errors.New("proxy: add failed")
errProxyNotFound = errors.New("proxy: not found")
errGetProxyTimeout = errors.New("proxy: get timeout")
errProxyAllDown = errors.New("proxy: all down")
errNoProxyHealthy = errors.New("proxy: no chosen healthy")
errMissingProxyOpt = errors.New("proxy: opts nil")
errNoProxyConn = errors.New("proxy: not a tcp/udp conn")
errNotUDPConn = errors.New("proxy: not a udp conn")
errProxyStopped = errors.New("proxy: stopped")
errProxyConfig = errors.New("proxy: invalid config")
errNoProxyResponse = errors.New("proxy: no response from upstream")
errNoSig = errors.New("proxy: auth missing sig")
errNoMtu = errors.New("proxy: missing mtu")
errNoOpts = errors.New("proxy: no opts")
errMissingRev = errors.New("proxy: missing reverse proxy")
errNoAuto464XLAT = errors.New("auto: no 464xlat")
errNotPinned = errors.New("auto: another proxy pinned")
errInvalidAddr = errors.New("proxy: invaild ip:port")
errUnreachable = errors.New("proxy: destination unreachable")
errNoRouteToHost = errors.New("proxy: no route to host")
errMissingProxyID = errors.New("proxy: missing proxy id")
errHopDefaultRoutes = errors.New("proxy: hop must route all ip4/ip6")
errNoHop = errors.New("proxy: no hop")
errHopWireGuard = errors.New("proxy: hop must be wireguard")
errHopGlobalProxy = errors.New("proxy: hop must be global proxy")
errProxyScheme = errors.New("proxy: unsupported scheme")
errUnexpectedProxy = errors.New("proxy: unexpected type")
errAddProxy = errors.New("proxy: add failed")
errProxyNotFound = errors.New("proxy: not found")
errGetProxyTimeout = errors.New("proxy: get timeout")
errProxyAllDown = errors.New("proxy: all down")
errNoProxyHealthy = errors.New("proxy: no chosen healthy")
errMissingProxyOpt = errors.New("proxy: opts nil")
errNoProxyConn = errors.New("proxy: not a tcp/udp conn")
errNotUDPConn = errors.New("proxy: not a udp conn")
errProxyStopped = errors.New("proxy: stopped")
errProxyConfig = errors.New("proxy: invalid config")
errNoProxyResponse = errors.New("proxy: no response from upstream")
errNoSig = errors.New("proxy: auth missing sig")
errNoMtu = errors.New("proxy: missing mtu")
errNoOpts = errors.New("proxy: no opts")
errMissingRev = errors.New("proxy: missing reverse proxy")
errNoAuto464XLAT = errors.New("auto: no 464xlat")
errNotPinned = errors.New("auto: another proxy pinned")
errInvalidAddr = errors.New("proxy: invaild ip:port")
errUnreachable = errors.New("proxy: destination unreachable")
errNoRouteToHost = errors.New("proxy: no route to host")
errMissingProxyID = errors.New("proxy: missing proxy id")
errHopDefaultRoutes = errors.New("proxy: hop must route all ip4/ip6")
errNoHop = errors.New("proxy: no hop")
errHopWireGuard = errors.New("proxy: hop must be wireguard")
errHopMtuInsufficient = errors.New("proxy: hop mtu insufficient")
errHopGlobalProxy = errors.New("proxy: hop must be global proxy")
)

const (
Expand Down
7 changes: 7 additions & 0 deletions intra/ipn/wgproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,13 @@ func (h *wgproxy) Hop(p Proxy) error {
if !isWG(p.ID()) { // for now, only wg can hop another wg
return errHopWireGuard
}
// mtu needed to tunnel this wg
mtuNeeded := calcNetMtu(h.mtu)
// mtu affordable by this hop
if mtuAvail, err := p.Router().MTU(); err != nil || mtuNeeded > mtuAvail {
return core.OneErr(err, errHopMtuInsufficient)
}

// todo: check if all routes for p & h overlap
old = h.via.Tango(p)
return nil
Expand Down

0 comments on commit 34dc257

Please sign in to comment.