wgengine/router: add debug logging component logs

This uses the "component logging" feature to allow turning on additional
debug logs for the Router at runtime. Currently, it's only implemented
on Linux and with the CallbackRouter at this time.

Updates #13887

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: I251a7705765f950d118850f1e14f465729ba45c5
This commit is contained in:
Andrew Dunham
2024-10-22 15:25:12 -05:00
parent b2665d9b89
commit 43dd4d1626
7 changed files with 69 additions and 6 deletions

View File

@@ -566,7 +566,9 @@ func componentStateKey(component string) ipn.StateKey {
// The following components are recognized:
//
// - magicsock
// - router
// - sockstats
// - syspolicy
func (b *LocalBackend) SetComponentDebugLogging(component string, until time.Time) error {
b.mu.Lock()
defer b.mu.Unlock()
@@ -575,6 +577,12 @@ func (b *LocalBackend) SetComponentDebugLogging(component string, until time.Tim
switch component {
case "magicsock":
setEnabled = b.MagicConn().SetDebugLoggingEnabled
case "router":
if r, ok := b.sys.Router.GetOK(); ok {
setEnabled = r.SetDebugLoggingEnabled
} else {
return fmt.Errorf("no router available")
}
case "sockstats":
if b.sockstatLogger != nil {
setEnabled = func(v bool) {