multiport: validate the peer's port range, warn when a lane never comes up

- Ignore a lane advert with a zero base port or a range running past 65535,
  with a warning, instead of aiming lanes at ports that wrapped.
- Warn once when a lane that has never come up misses 3 probes in a row.
  Until now that was silent above debug, including the common case of a
  firewall that only opens the base port.
This commit is contained in:
Wade Simmons committed 2026-10-01 16:50:49 -05:00
1 parent b93c3bfed6
commit a7e407181a
5 files changed
+100 -6

No files matched your search

+16
View File
@@ -64,6 +64,11 @@ const (
// laneMaxFails caps the failure counter; the backoff saturates well before.
laneMaxFails = 8
// laneWarnFails is how many unanswered probes a lane that has never come up
// takes before it is worth a warning. One or two can be loss; this many in a
// row is usually a firewall that only opens the base port.
laneWarnFails = 3
// laneProbeTimeout is how long a probe may go unacked before it counts as a
// failure. It is shorter than the connection manager's check interval on
// purpose: an outstanding probe is judged on the next tick either way, and a
@@ -170,6 +175,12 @@ type laneProbeState struct {
retryAt time.Time
}
// validLaneAdvert reports whether a peer's advertised port range is one we can
// aim lanes at: a real base port, and every port in the range a valid one.
func validLaneAdvert(basePort, portCount uint32) bool {
return basePort != 0 && portCount != 0 && basePort+portCount-1 <= 0xffff
}
// newLaneSet sets up the lanes for a freshly completed base handshake. It
// returns nil when the pair has no lane beyond the base tunnel, which is the
// normal answer for a peer running without multiport. No session is derived
@@ -592,6 +603,11 @@ func (f *Interface) probeLanes(hostinfo *HostInfo, now time.Time, nb, out []byte
if up {
ls.txAddr[s].Store(nil)
hostinfo.logger(f.l).Info("Multiport lane demoted, probe unanswered", "lane", s, "udpAddr", p.target)
} else if p.lastAck.IsZero() && p.fails == laneWarnFails {
// Said once per lane: fails only passes through this value again
// after an ack or a reset clears it.
hostinfo.logger(f.l).Warn("Multiport lane not coming up, probes unanswered; check that the peer's lane ports are reachable",
"lane", s, "udpAddr", p.target, "fails", p.fails)
}
continue
}