mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 13:05:46 +00:00
wgengine/monitor: ignore OS-specific uninteresting interfaces
Currently we ignore these interfaces in the darwin osMon but then would consider it interesting when checking if anything had changed. Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
1b89662eff
commit
8e40bfc6ea
@ -42,6 +42,10 @@ type osMon interface {
|
|||||||
// until the osMon is closed. After a Close, the returned
|
// until the osMon is closed. After a Close, the returned
|
||||||
// error is ignored.
|
// error is ignored.
|
||||||
Receive() (message, error)
|
Receive() (message, error)
|
||||||
|
|
||||||
|
// IsInterestingInterface reports whether the provided interface should
|
||||||
|
// be considered for network change events.
|
||||||
|
IsInterestingInterface(iface string) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeFunc is a callback function that's called when the network
|
// ChangeFunc is a callback function that's called when the network
|
||||||
@ -282,6 +286,13 @@ func (m *Mon) notifyRuleDeleted(rdm ipRuleDeletedMessage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isInterestingInterface reports whether the provided interface should be
|
||||||
|
// considered when checking for network state changes.
|
||||||
|
// The ips parameter should be the IPs of the provided interface.
|
||||||
|
func (m *Mon) isInterestingInterface(i interfaces.Interface, ips []netaddr.IPPrefix) bool {
|
||||||
|
return m.om.IsInterestingInterface(i.Name) && interfaces.UseInterestingInterfaces(i, ips)
|
||||||
|
}
|
||||||
|
|
||||||
// debounce calls the callback function with a delay between events
|
// debounce calls the callback function with a delay between events
|
||||||
// and exits when a stop is issued.
|
// and exits when a stop is issued.
|
||||||
func (m *Mon) debounce() {
|
func (m *Mon) debounce() {
|
||||||
@ -299,7 +310,7 @@ func (m *Mon) debounce() {
|
|||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
|
|
||||||
oldState := m.ifState
|
oldState := m.ifState
|
||||||
changed := !curState.EqualFiltered(oldState, interfaces.UseInterestingInterfaces, interfaces.UseInterestingIPs)
|
changed := !curState.EqualFiltered(oldState, m.isInterestingInterface, interfaces.UseInterestingIPs)
|
||||||
if changed {
|
if changed {
|
||||||
m.gwValid = false
|
m.gwValid = false
|
||||||
m.ifState = curState
|
m.ifState = curState
|
||||||
|
@ -112,11 +112,18 @@ func addrType(addrs []route.Addr, rtaxType int) route.Addr {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *darwinRouteMon) IsInterestingInterface(iface string) bool {
|
||||||
|
baseName := strings.TrimRight(iface, "0123456789")
|
||||||
|
switch baseName {
|
||||||
|
case "llw", "awdl", "pdp_ip", "ipsec":
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (m *darwinRouteMon) skipInterfaceAddrMessage(msg *route.InterfaceAddrMessage) bool {
|
func (m *darwinRouteMon) skipInterfaceAddrMessage(msg *route.InterfaceAddrMessage) bool {
|
||||||
if la, ok := addrType(msg.Addrs, unix.RTAX_IFP).(*route.LinkAddr); ok {
|
if la, ok := addrType(msg.Addrs, unix.RTAX_IFP).(*route.LinkAddr); ok {
|
||||||
baseName := strings.TrimRight(la.Name, "0123456789")
|
if !m.IsInterestingInterface(la.Name) {
|
||||||
switch baseName {
|
|
||||||
case "llw", "awdl", "pdp_ip", "ipsec":
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ func newOSMon(logf logger.Logf, m *Mon) (osMon, error) {
|
|||||||
return &devdConn{conn}, nil
|
return &devdConn{conn}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *devdConn) IsInterestingInterface(iface string) bool { return true }
|
||||||
|
|
||||||
func (c *devdConn) Close() error {
|
func (c *devdConn) Close() error {
|
||||||
return c.conn.Close()
|
return c.conn.Close()
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,8 @@ func newOSMon(logf logger.Logf, m *Mon) (osMon, error) {
|
|||||||
return &nlConn{logf: logf, conn: conn, addrCache: make(map[uint32]map[netaddr.IP]bool)}, nil
|
return &nlConn{logf: logf, conn: conn, addrCache: make(map[uint32]map[netaddr.IP]bool)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *nlConn) IsInterestingInterface(iface string) bool { return true }
|
||||||
|
|
||||||
func (c *nlConn) Close() error { return c.conn.Close() }
|
func (c *nlConn) Close() error { return c.conn.Close() }
|
||||||
|
|
||||||
func (c *nlConn) Receive() (message, error) {
|
func (c *nlConn) Receive() (message, error) {
|
||||||
|
@ -72,6 +72,8 @@ func newOSMon(logf logger.Logf, _ *Mon) (osMon, error) {
|
|||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *winMon) IsInterestingInterface(iface string) bool { return true }
|
||||||
|
|
||||||
func (m *winMon) Close() (ret error) {
|
func (m *winMon) Close() (ret error) {
|
||||||
m.cancel()
|
m.cancel()
|
||||||
m.noDeadlockTicker.Stop()
|
m.noDeadlockTicker.Stop()
|
||||||
|
@ -38,6 +38,10 @@ type pollingMon struct {
|
|||||||
stop chan struct{}
|
stop chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pm *pollingMon) IsInterestingInterface(iface string) bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (pm *pollingMon) Close() error {
|
func (pm *pollingMon) Close() error {
|
||||||
pm.closeOnce.Do(func() {
|
pm.closeOnce.Do(func() {
|
||||||
close(pm.stop)
|
close(pm.stop)
|
||||||
|
Loading…
Reference in New Issue
Block a user