net/dns, ipn/ipnlocal: fix regressions from change moving away from deephash

I got sidetracked apparently and never finished writing this Clone
code in 316afe7d02 (#17448). (It really should use views instead.)

And then I missed one of the users of "routerChanged" that was broken up
into "routerChanged" vs "dnsChanged".

This broke integration tests elsewhere.

Fixes #17506

Change-Id: I533bf0fcf3da9ac6eb4a6cdef03b8df2c1fb4c8e
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2025-10-08 09:27:41 -07:00
committed by Brad Fitzpatrick
parent 7edb5b7d43
commit f270c3158a
4 changed files with 94 additions and 7 deletions
+9 -2
View File
@@ -7,6 +7,7 @@ package dns
import (
"bufio"
"fmt"
"maps"
"net/netip"
"reflect"
"slices"
@@ -190,15 +191,21 @@ func sameResolverNames(a, b []*dnstype.Resolver) bool {
return true
}
// Clone makes a shallow clone of c.
//
// The returned Config still references slices and maps from c.
//
// TODO(bradfitz): use cmd/{viewer,cloner} for these and make the
// caller use views instead.
func (c *Config) Clone() *Config {
if c == nil {
return nil
}
return &Config{
DefaultResolvers: slices.Clone(c.DefaultResolvers),
Routes: make(map[dnsname.FQDN][]*dnstype.Resolver, len(c.Routes)),
Routes: maps.Clone(c.Routes),
SearchDomains: slices.Clone(c.SearchDomains),
Hosts: make(map[dnsname.FQDN][]netip.Addr, len(c.Hosts)),
Hosts: maps.Clone(c.Hosts),
OnlyIPv6: c.OnlyIPv6,
}
}