Skip to content

Commit 04fabcd

Browse files
committed
ipn/{ipnlocal,localapi}, cli: add debug force-netmap-update
For loading testing & profiling the cost of full netmap updates. Updates tailscale#1909 Change-Id: I0afdf5de9967f8d95c7f81d5b531ed1c92c3208f Signed-off-by: Brad Fitzpatrick <[email protected]>
1 parent 75dbd71 commit 04fabcd

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

cmd/tailscale/cli/debug.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ var debugCmd = &ffcli.Command{
138138
Exec: localAPIAction("break-derp-conns"),
139139
ShortHelp: "break any open DERP connections from the daemon",
140140
},
141+
{
142+
Name: "force-netmap-update",
143+
Exec: localAPIAction("force-netmap-update"),
144+
ShortHelp: "force a full no-op netmap update (for load testing)",
145+
},
141146
{
142147
Name: "control-knobs",
143148
Exec: debugControlKnobs,

ipn/ipnlocal/local.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,6 +2133,23 @@ func (b *LocalBackend) DebugNotify(n ipn.Notify) {
21332133
b.send(n)
21342134
}
21352135

2136+
// DebugForceNetmapUpdate forces a full no-op netmap update of the current
2137+
// netmap in all the various subsystems (wireguard, magicsock, LocalBackend).
2138+
//
2139+
// It exists for load testing reasons (for issue 1909), doing what would happen
2140+
// if a new MapResponse came in from the control server that couldn't be handled
2141+
// incrementally.
2142+
func (b *LocalBackend) DebugForceNetmapUpdate() {
2143+
b.mu.Lock()
2144+
defer b.mu.Unlock()
2145+
nm := b.netMap
2146+
b.e.SetNetworkMap(nm)
2147+
if nm != nil {
2148+
b.magicConn().SetDERPMap(nm.DERPMap)
2149+
}
2150+
b.setNetMapLocked(nm)
2151+
}
2152+
21362153
// send delivers n to the connected frontend and any API watchers from
21372154
// LocalBackend.WatchNotifications (via the LocalAPI).
21382155
//

ipn/localapi/localapi.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,8 @@ func (h *Handler) serveDebug(w http.ResponseWriter, r *http.Request) {
557557
err = h.b.DebugBreakTCPConns()
558558
case "break-derp-conns":
559559
err = h.b.DebugBreakDERPConns()
560+
case "force-netmap-update":
561+
h.b.DebugForceNetmapUpdate()
560562
case "control-knobs":
561563
k := h.b.ControlKnobs()
562564
w.Header().Set("Content-Type", "application/json")

0 commit comments

Comments
 (0)