ipn/{ipnlocal,localapi}, cli: add debug force-netmap-update

For loading testing & profiling the cost of full netmap updates.

Updates #1909

Change-Id: I0afdf5de9967f8d95c7f81d5b531ed1c92c3208f
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/8946/head^2
Brad Fitzpatrick 1 year ago committed by Brad Fitzpatrick
parent 75dbd71f49
commit 04fabcd359

@ -138,6 +138,11 @@ var debugCmd = &ffcli.Command{
Exec: localAPIAction("break-derp-conns"), Exec: localAPIAction("break-derp-conns"),
ShortHelp: "break any open DERP connections from the daemon", ShortHelp: "break any open DERP connections from the daemon",
}, },
{
Name: "force-netmap-update",
Exec: localAPIAction("force-netmap-update"),
ShortHelp: "force a full no-op netmap update (for load testing)",
},
{ {
Name: "control-knobs", Name: "control-knobs",
Exec: debugControlKnobs, Exec: debugControlKnobs,

@ -2133,6 +2133,23 @@ func (b *LocalBackend) DebugNotify(n ipn.Notify) {
b.send(n) b.send(n)
} }
// DebugForceNetmapUpdate forces a full no-op netmap update of the current
// netmap in all the various subsystems (wireguard, magicsock, LocalBackend).
//
// It exists for load testing reasons (for issue 1909), doing what would happen
// if a new MapResponse came in from the control server that couldn't be handled
// incrementally.
func (b *LocalBackend) DebugForceNetmapUpdate() {
b.mu.Lock()
defer b.mu.Unlock()
nm := b.netMap
b.e.SetNetworkMap(nm)
if nm != nil {
b.magicConn().SetDERPMap(nm.DERPMap)
}
b.setNetMapLocked(nm)
}
// send delivers n to the connected frontend and any API watchers from // send delivers n to the connected frontend and any API watchers from
// LocalBackend.WatchNotifications (via the LocalAPI). // LocalBackend.WatchNotifications (via the LocalAPI).
// //

@ -557,6 +557,8 @@ func (h *Handler) serveDebug(w http.ResponseWriter, r *http.Request) {
err = h.b.DebugBreakTCPConns() err = h.b.DebugBreakTCPConns()
case "break-derp-conns": case "break-derp-conns":
err = h.b.DebugBreakDERPConns() err = h.b.DebugBreakDERPConns()
case "force-netmap-update":
h.b.DebugForceNetmapUpdate()
case "control-knobs": case "control-knobs":
k := h.b.ControlKnobs() k := h.b.ControlKnobs()
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")

Loading…
Cancel
Save