From 70d78c593668bd35a1c08a991f26ba090b705a5e Mon Sep 17 00:00:00 2001 From: Maisem Ali Date: Tue, 7 May 2024 23:57:04 +0000 Subject: [PATCH] ipn/ipnlocal: call SetNetInfoCallback from NewLocalBackend Instead of calling it from Start everytime, call it from NewLocalBackend once. Updates #11649 Signed-off-by: Maisem Ali --- ipn/ipnlocal/local.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 4942d164d..30eabb9c6 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -368,7 +368,7 @@ func NewLocalBackend(logf logger.Logf, logID logid.PublicID, sys *tsd.System, lo if dialer.NetMon() == nil { return nil, errors.New("dialer to NewLocalBackend must have a NetMon") } - _ = sys.MagicSock.Get() // or panic + mConn := sys.MagicSock.Get() goos := envknob.GOOS() if loginFlags&controlclient.LocalBackendStartKeyOSNeutral != 0 { @@ -428,6 +428,7 @@ func NewLocalBackend(logf logger.Logf, logID logid.PublicID, sys *tsd.System, lo selfUpdateProgress: make([]ipnstate.UpdateProgress, 0), lastSelfUpdateState: ipnstate.UpdateFinished, } + mConn.SetNetInfoCallback(b.setNetInfo) netMon := sys.NetMon.Get() b.sockstatLogger, err = sockstatlog.NewLogger(logpolicy.LogsDir(logf), logf, logID, netMon, sys.HealthTracker()) @@ -1816,8 +1817,6 @@ func (b *LocalBackend) Start(opts ipn.Options) error { } cc.SetTKAHead(tkaHead) - b.MagicConn().SetNetInfoCallback(b.setNetInfo) - blid := b.backendLogID.String() b.logf("Backend: logs: be:%v fe:%v", blid, opts.FrontendLogID) b.send(ipn.Notify{BackendLogID: &blid})