Commit Graph

5 Commits (dd952713eee8017d1471f2cd2e2ade7b6eda88d3)

Author SHA1 Message Date
Jonathan Nobels 0699f847b9 net/netmon: remove ChangeDelta.Major and start the TODOs
updates tailscale/corp#33891

We've had some TODO's in netmon for ages related to asking
more pointed questions of ChangeDelta.  We're also seeing
a lot of ChangeDelta's being flagged as "Major" when they are
not interesting, triggering rebinds in wgengine that are not needed.

This removes the "Major" flag and replaces it with a set of
precomputed values that hint at what the ChangeDelta means.

 The dependencies are cleaned up a bit,
notably removing dependency on netmon itself for calculating
what is interesting, and what is not.  This includes letting
individual platforms set a bespoke global "IsInterestingInterface"
function.  This was only used on Darwin.

RebindRequired roughly flows from how "Major" was historically
calculated but includes some additional checks for various
uninteresting events such as changes in interface addresses that
shouldn't trigger a rebind to minimize thrashing.   The individual
values that we roll  into RebindRequired are also exposed so that
components consuming netmap.ChangeDelta can ask more
targeted questions.

Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>

wgengine/userspace: skip rebind and restun if all of our interfaces are down

updates tailscale/corp#33891

Skip rebind and restun if we have called SetNetworkUp with false.  Neither
cares about this state and it's just flappy to try to reStun and rebind if
there are no usable interfaces available.

Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>

Add viability flag and fix bug in state
1 week ago
David Anderson 5399fa159a net/netmon: publish events to event bus
Updates #15160

Signed-off-by: David Anderson <dave@tailscale.com>
8 months ago
Andrew Lytvynov 2716250ee8
all: cleanup unused code, part 2 (#10670)
And enable U1000 check in staticcheck.

Updates #cleanup

Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
2 years ago
Nick Khyl c9836b454d net/netmon: fix goroutine leak in winMon if the monitor is never started
When the portable Monitor creates a winMon via newOSMon, we register
address and route change callbacks with Windows. Once a callback is hit,
it starts a goroutine that attempts to send the event into messagec and returns.
The newly started goroutine then blocks until it can send to the channel.
However, if the monitor is never started and winMon.Receive is never called,
the goroutines remain indefinitely blocked, leading to goroutine leaks and
significant memory consumption in the tailscaled service process on Windows.
Unlike the tailscaled subprocess, the service process creates but never starts
a Monitor.

This PR adds a check within the callbacks to confirm the monitor's active status,
and exits immediately if the monitor hasn't started.

Updates #9864

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2 years ago
Mihai Parparita 4722f7e322 all: move network monitoring from wgengine/monitor to net/netmon
We're using it in more and more places, and it's not really specific to
our use of Wireguard (and does more just link/interface monitoring).

Also removes the separate interface we had for it in sockstats -- it's
a small enough package (we already pull in all of its dependencies
via other paths) that it's not worth the extra complexity.

Updates #7621
Updates #7850

Signed-off-by: Mihai Parparita <mihai@tailscale.com>
3 years ago