mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
types/netmap: remove redundant Netmap.Hostinfo
It was in SelfNode.Hostinfo anyway. The redundant copy was just costing us an allocation per netmap (a Hostinfo.Clone). Updates #1909 Change-Id: Ifac568aa5f8054d9419828489442a0f4559bc099 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
50b558de74
commit
947def7688
@ -467,9 +467,6 @@ func (ms *mapSession) netmap() *netmap.NetworkMap {
|
||||
nm.Expiry = node.KeyExpiry()
|
||||
nm.Name = node.Name()
|
||||
nm.Addresses = filterSelfAddresses(node.Addresses().AsSlice())
|
||||
if node.Hostinfo().Valid() {
|
||||
nm.Hostinfo = *node.Hostinfo().AsStruct()
|
||||
}
|
||||
if node.MachineAuthorized() {
|
||||
nm.MachineStatus = tailcfg.MachineAuthorized
|
||||
} else {
|
||||
|
@ -704,7 +704,9 @@ func (b *LocalBackend) updateStatus(sb *ipnstate.StatusBuilder, extraLocked func
|
||||
ss.Online = health.GetInPollNetMap()
|
||||
if b.netMap != nil {
|
||||
ss.InNetworkMap = true
|
||||
ss.HostName = b.netMap.Hostinfo.Hostname
|
||||
if hi := b.netMap.SelfNode.Hostinfo(); hi.Valid() {
|
||||
ss.HostName = hi.Hostname()
|
||||
}
|
||||
ss.DNSName = b.netMap.Name
|
||||
ss.UserID = b.netMap.User()
|
||||
if sn := b.netMap.SelfNode; sn.Valid() {
|
||||
|
@ -23,8 +23,6 @@
|
||||
// The fields should all be considered read-only. They might
|
||||
// alias parts of previous NetworkMap values.
|
||||
type NetworkMap struct {
|
||||
// Core networking
|
||||
|
||||
SelfNode tailcfg.NodeView
|
||||
NodeKey key.NodePublic
|
||||
PrivateKey key.NodePrivate
|
||||
@ -44,10 +42,10 @@ type NetworkMap struct {
|
||||
MachineStatus tailcfg.MachineStatus
|
||||
|
||||
MachineKey key.MachinePublic
|
||||
Peers []tailcfg.NodeView // sorted by Node.ID
|
||||
DNS tailcfg.DNSConfig
|
||||
// TODO(maisem) : replace with View.
|
||||
Hostinfo tailcfg.Hostinfo
|
||||
|
||||
Peers []tailcfg.NodeView // sorted by Node.ID
|
||||
DNS tailcfg.DNSConfig
|
||||
|
||||
PacketFilter []filter.Match
|
||||
PacketFilterRules views.Slice[tailcfg.FilterRule]
|
||||
SSHPolicy *tailcfg.SSHPolicy // or nil, if not enabled/allowed
|
||||
|
@ -41,6 +41,7 @@
|
||||
"tailscale.com/types/key"
|
||||
"tailscale.com/types/logger"
|
||||
"tailscale.com/types/netmap"
|
||||
"tailscale.com/types/views"
|
||||
"tailscale.com/util/clientmetric"
|
||||
"tailscale.com/util/deephash"
|
||||
"tailscale.com/util/mak"
|
||||
@ -755,12 +756,11 @@ func (e *userspaceEngine) updateActivityMapsLocked(trackNodes []key.NodePublic,
|
||||
|
||||
// hasOverlap checks if there is a IPPrefix which is common amongst the two
|
||||
// provided slices.
|
||||
func hasOverlap(aips, rips []netip.Prefix) bool {
|
||||
for _, aip := range aips {
|
||||
for _, rip := range rips {
|
||||
if aip == rip {
|
||||
return true
|
||||
}
|
||||
func hasOverlap(aips, rips views.Slice[netip.Prefix]) bool {
|
||||
for i := range aips.LenIter() {
|
||||
aip := aips.At(i)
|
||||
if views.SliceContains(rips, aip) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
@ -800,9 +800,9 @@ func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, routerCfg *router.Config,
|
||||
|
||||
isSubnetRouter := false
|
||||
if e.birdClient != nil && nm != nil && nm.SelfNode.Valid() {
|
||||
isSubnetRouter = hasOverlap(nm.SelfNode.PrimaryRoutes().AsSlice(), nm.Hostinfo.RoutableIPs)
|
||||
isSubnetRouter = hasOverlap(nm.SelfNode.PrimaryRoutes(), nm.SelfNode.Hostinfo().RoutableIPs())
|
||||
e.logf("[v1] Reconfig: hasOverlap(%v, %v) = %v; isSubnetRouter=%v lastIsSubnetRouter=%v",
|
||||
nm.SelfNode.PrimaryRoutes, nm.Hostinfo.RoutableIPs,
|
||||
nm.SelfNode.PrimaryRoutes(), nm.SelfNode.Hostinfo().RoutableIPs(),
|
||||
isSubnetRouter, isSubnetRouter, e.lastIsSubnetRouter)
|
||||
}
|
||||
isSubnetRouterChanged := isSubnetRouter != e.lastIsSubnetRouter
|
||||
|
Loading…
Reference in New Issue
Block a user