Skip to content

Commit 24b6c48

Browse files
authored
libtailscale: use b.netmon and sys.Bus consistently (#717)
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 <[email protected]>
1 parent 6f3d188 commit 24b6c48

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

libtailscale/backend.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ func (a *App) runBackend(ctx context.Context, hardwareAttestation bool) error {
249249
vpnService.service = nil
250250
}
251251
case i := <-onDNSConfigChanged:
252+
// TODO (barnstar): Consider using [dns.Manager.RecompileDNSConfig] here.
253+
// NetworkChanged injects a netmon event that has the side effect
254+
// regenerating the DNS config but have the means to do
255+
// that independently of userspace engine network changes which may
256+
// eliminate some unnecessary work.
252257
go b.NetworkChanged(i)
253258
}
254259
}
@@ -265,7 +270,7 @@ func (a *App) newBackend(dataDir string, appCtx AppContext, store *stateStore,
265270
devices: newTUNDevices(),
266271
settings: settings,
267272
appCtx: appCtx,
268-
bus: eventbus.New(),
273+
bus: sys.Bus.Get(),
269274
}
270275

271276
var logID logid.PrivateID

libtailscale/net.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,10 @@ func (b *backend) NetworkChanged(ifname string) {
275275

276276
// Set the interface name and alert the monitor.
277277
netmon.UpdateLastKnownDefaultRouteInterface(ifname)
278-
if b.sys != nil {
279-
if nm, ok := b.sys.NetMon.GetOK(); ok {
280-
nm.InjectEvent()
281-
}
278+
if b.netMon != nil {
279+
b.netMon.InjectEvent()
280+
} else {
281+
log.Printf("NetworkChanged: netMon is nil")
282282
}
283283
}
284284

0 commit comments

Comments
 (0)