libtailscale: use b.netmon and sys.Bus consistently

fixes tailscale/android#17747

There was a mismatch between the netmon into which we
were injecting network change events, and the netmon that
the eventBus registered with in the userspace engine.

The switch from directly registering callbacks with netmon
to using the eventBus caused a regression where the
injected events would no longer trigger interface rebinds based
on feedback from the Android network monitoring APIs.

Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
pull/717/head
Jonathan Nobels 2 weeks ago
parent 6f3d1881a8
commit c1b1cad633

@ -249,6 +249,11 @@ func (a *App) runBackend(ctx context.Context, hardwareAttestation bool) error {
vpnService.service = nil vpnService.service = nil
} }
case i := <-onDNSConfigChanged: case i := <-onDNSConfigChanged:
// TODO (barnstar): Consider using [dns.Manager.RecompileDNSConfig] here.
// NetworkChanged injects a netmon event that has the side effect
// regenerating the DNS config but have the means to do
// that independently of userspace engine network changes which may
// eliminate some unnecessary work.
go b.NetworkChanged(i) go b.NetworkChanged(i)
} }
} }
@ -265,7 +270,7 @@ func (a *App) newBackend(dataDir string, appCtx AppContext, store *stateStore,
devices: newTUNDevices(), devices: newTUNDevices(),
settings: settings, settings: settings,
appCtx: appCtx, appCtx: appCtx,
bus: eventbus.New(), bus: sys.Bus.Get(),
} }
var logID logid.PrivateID var logID logid.PrivateID

@ -275,10 +275,10 @@ func (b *backend) NetworkChanged(ifname string) {
// Set the interface name and alert the monitor. // Set the interface name and alert the monitor.
netmon.UpdateLastKnownDefaultRouteInterface(ifname) netmon.UpdateLastKnownDefaultRouteInterface(ifname)
if b.sys != nil { if b.netMon != nil {
if nm, ok := b.sys.NetMon.GetOK(); ok { b.netMon.InjectEvent()
nm.InjectEvent() } else {
} log.Printf("NetworkChanged: netMon is nil")
} }
} }

Loading…
Cancel
Save