net/{interfaces,netmon}, all: merge net/interfaces package into net/netmon

In prep for most of the package funcs in net/interfaces to become
methods in a long-lived netmon.Monitor that can cache things.  (Many
of the funcs are very heavy to call regularly, whereas the long-lived
netmon.Monitor can subscribe to things from the OS and remember
answers to questions it's asked regularly later)

Updates tailscale/corp#10910
Updates tailscale/corp#18960
Updates #7967
Updates #3299

Change-Id: Ie4e8dedb70136af2d611b990b865a822cd1797e5
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2024-04-27 21:18:18 -07:00
committed by Brad Fitzpatrick
parent 6b95219e3a
commit b9adbe2002
45 changed files with 846 additions and 874 deletions

View File

@@ -32,8 +32,8 @@ import (
"tailscale.com/drive/driveimpl"
"tailscale.com/ipn"
"tailscale.com/ipn/store/mem"
"tailscale.com/net/interfaces"
"tailscale.com/net/netcheck"
"tailscale.com/net/netmon"
"tailscale.com/net/tsaddr"
"tailscale.com/tailcfg"
"tailscale.com/tsd"
@@ -603,7 +603,7 @@ func TestFileTargets(t *testing.T) {
func TestInternalAndExternalInterfaces(t *testing.T) {
type interfacePrefix struct {
i interfaces.Interface
i netmon.Interface
pfx netip.Prefix
}
@@ -613,7 +613,7 @@ func TestInternalAndExternalInterfaces(t *testing.T) {
}
return pfxs
}
iList := func(ips ...interfacePrefix) (il interfaces.List) {
iList := func(ips ...interfacePrefix) (il netmon.InterfaceList) {
for _, ip := range ips {
il = append(il, ip.i)
}
@@ -621,7 +621,7 @@ func TestInternalAndExternalInterfaces(t *testing.T) {
}
newInterface := func(name, pfx string, wsl2, loopback bool) interfacePrefix {
ippfx := netip.MustParsePrefix(pfx)
ip := interfaces.Interface{
ip := netmon.Interface{
Interface: &net.Interface{},
AltAddrs: []net.Addr{
netipx.PrefixIPNet(ippfx),
@@ -645,7 +645,7 @@ func TestInternalAndExternalInterfaces(t *testing.T) {
tests := []struct {
name string
goos string
il interfaces.List
il netmon.InterfaceList
wantInt []netip.Prefix
wantExt []netip.Prefix
}{