net/{interfaces,netmon}: remove "interesting", EqualFiltered API

This removes a lot of API from net/interfaces (including all the
filter types, EqualFiltered, active Tailscale interface func, etc) and
moves the "major" change detection to net/netmon which knows more
about the world and the previous/new states.

Updates #9040

Change-Id: I7fe66a23039c6347ae5458745b709e7ebdcce245
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2023-08-23 11:48:05 -07:00
committed by Brad Fitzpatrick
parent 6dfa403e6b
commit 11ece02f52
7 changed files with 476 additions and 196 deletions

View File

@@ -8,13 +8,14 @@ package dns
import (
"context"
"fmt"
"net"
"net/netip"
"sort"
"time"
"github.com/godbus/dbus/v5"
"github.com/josharian/native"
"tailscale.com/net/interfaces"
"tailscale.com/net/tsaddr"
"tailscale.com/util/dnsname"
)
@@ -139,14 +140,18 @@ func (m *nmManager) trySet(ctx context.Context, config OSConfig) error {
// tell it explicitly to keep it. Read out the current interface
// settings and mirror them out to NetworkManager.
var addrs6 []map[string]any
addrs, _, err := interfaces.Tailscale()
if err == nil {
if tsIf, err := net.InterfaceByName(m.interfaceName); err == nil {
addrs, _ := tsIf.Addrs()
for _, a := range addrs {
if a.Is6() {
addrs6 = append(addrs6, map[string]any{
"address": a.String(),
"prefix": uint32(128),
})
if ipnet, ok := a.(*net.IPNet); ok {
nip, ok := netip.AddrFromSlice(ipnet.IP)
nip = nip.Unmap()
if ok && tsaddr.IsTailscaleIP(nip) && nip.Is6() {
addrs6 = append(addrs6, map[string]any{
"address": nip.String(),
"prefix": uint32(128),
})
}
}
}
}