wgengine/netlog: add support for magicsock statistics (#5913)

This sets up Logger to handle statistics at the magicsock layer,
where we can correlate traffic between a particular tailscale IP address
and any number of physical endpoints used to contact the node
that hosts that tailscale address.

We also export Message and TupleCounts to better document the JSON format
that is being sent to the logging infrastructure.

This commit does NOT yet enable the actual logging of magicsock statistics.
That will be a future commit.

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
Joe Tsai
2022-10-13 10:46:29 -07:00
committed by GitHub
parent db863bf00f
commit a1a43ed266
3 changed files with 87 additions and 34 deletions

View File

@@ -953,7 +953,7 @@ func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, routerCfg *router.Config,
nid := cfg.NetworkLogging.NodeID
tid := cfg.NetworkLogging.DomainID
e.logf("wgengine: Reconfig: starting up network logger (node:%s tailnet:%s)", nid.Public(), tid.Public())
if err := e.networkLogger.Startup(nid, tid, e.tundev); err != nil {
if err := e.networkLogger.Startup(nid, tid, e.tundev, nil); err != nil {
e.logf("wgengine: Reconfig: error starting up network logger: %v", err)
}
}