multiport: say when lanes are on and what was negotiated

Every multiport log line so far was a reason it turned itself off, so a node
running it looked identical to one that never tried. Add the other half:

- an Info at startup with the lane count and port range
- the negotiated lanes on both "Handshake message received" lines, which
  required allocating the lane set before the log rather than after; it still
  lands before CheckAndComplete/Complete, which was the ordering requirement
- multiport.lanes.up and multiport.lanes.tunnels gauges

The lane field is a slog.Attr so it vanishes on a node without multiport, and
reads zeros when we offered lanes and the peer had none - the case an operator
is actually looking for.

The gauges walk the hostmap instead of keeping a counter at promote/demote: a
tunnel torn down while its lanes are up never demotes them, so a counter would
drift upward forever. Only a multiport node pays for the walk.
This commit is contained in:
Wade Simmons committed 2026-09-02 16:38:49 -04:00
1 parent e3efe0c53d
commit a304f370f4
5 files changed
+100 -5

No files matched your search

+24
View File
@@ -1,6 +1,7 @@
package nebula
import (
"log/slog"
"net/netip"
"testing"
"time"
@@ -182,6 +183,29 @@ func TestNewLaneSetSizing(t *testing.T) {
assert.Len(t, ls.sessions, 8)
}
// The handshake log lines carry the negotiated lanes, so an operator can tell a
// peer that got none from one that was never asked.
func TestLaneLogAttr(t *testing.T) {
initR, _ := runTestHandshake(t)
// Not running multiport: an empty attr, which slog drops entirely.
assert.Equal(t, slog.Attr{}, laneLogAttr(0, nil))
// Running multiport against a peer that isn't: zeros, not silence.
assert.Equal(t, m{"tx": 0, "sessions": 0}, laneLogAttr(4, nil).Value.Any())
ls := newTestLaneSet(t, initR, 2, 8, 4242, 6)
attr := laneLogAttr(2, ls)
assert.Equal(t, "lanes", attr.Key)
assert.Equal(t, m{
"tx": 2,
"sessions": 6,
"peerBasePort": uint16(4242),
"peerPorts": uint16(8),
"portOffset": ls.portOffset,
}, attr.Value.Any())
}
// The RX path must not cache a session for a lane until a packet on it has
// actually decrypted, or a spoofer naming lanes at random could make us hold a
// replay window and two cipher states per lane without authenticating anything.