mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-23 17:31:43 +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.Expiry = node.KeyExpiry()
|
||||||
nm.Name = node.Name()
|
nm.Name = node.Name()
|
||||||
nm.Addresses = filterSelfAddresses(node.Addresses().AsSlice())
|
nm.Addresses = filterSelfAddresses(node.Addresses().AsSlice())
|
||||||
if node.Hostinfo().Valid() {
|
|
||||||
nm.Hostinfo = *node.Hostinfo().AsStruct()
|
|
||||||
}
|
|
||||||
if node.MachineAuthorized() {
|
if node.MachineAuthorized() {
|
||||||
nm.MachineStatus = tailcfg.MachineAuthorized
|
nm.MachineStatus = tailcfg.MachineAuthorized
|
||||||
} else {
|
} else {
|
||||||
|
@ -704,7 +704,9 @@ func (b *LocalBackend) updateStatus(sb *ipnstate.StatusBuilder, extraLocked func
|
|||||||
ss.Online = health.GetInPollNetMap()
|
ss.Online = health.GetInPollNetMap()
|
||||||
if b.netMap != nil {
|
if b.netMap != nil {
|
||||||
ss.InNetworkMap = true
|
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.DNSName = b.netMap.Name
|
||||||
ss.UserID = b.netMap.User()
|
ss.UserID = b.netMap.User()
|
||||||
if sn := b.netMap.SelfNode; sn.Valid() {
|
if sn := b.netMap.SelfNode; sn.Valid() {
|
||||||
|
@ -23,8 +23,6 @@ import (
|
|||||||
// The fields should all be considered read-only. They might
|
// The fields should all be considered read-only. They might
|
||||||
// alias parts of previous NetworkMap values.
|
// alias parts of previous NetworkMap values.
|
||||||
type NetworkMap struct {
|
type NetworkMap struct {
|
||||||
// Core networking
|
|
||||||
|
|
||||||
SelfNode tailcfg.NodeView
|
SelfNode tailcfg.NodeView
|
||||||
NodeKey key.NodePublic
|
NodeKey key.NodePublic
|
||||||
PrivateKey key.NodePrivate
|
PrivateKey key.NodePrivate
|
||||||
@ -44,10 +42,10 @@ type NetworkMap struct {
|
|||||||
MachineStatus tailcfg.MachineStatus
|
MachineStatus tailcfg.MachineStatus
|
||||||
|
|
||||||
MachineKey key.MachinePublic
|
MachineKey key.MachinePublic
|
||||||
|
|
||||||
Peers []tailcfg.NodeView // sorted by Node.ID
|
Peers []tailcfg.NodeView // sorted by Node.ID
|
||||||
DNS tailcfg.DNSConfig
|
DNS tailcfg.DNSConfig
|
||||||
// TODO(maisem) : replace with View.
|
|
||||||
Hostinfo tailcfg.Hostinfo
|
|
||||||
PacketFilter []filter.Match
|
PacketFilter []filter.Match
|
||||||
PacketFilterRules views.Slice[tailcfg.FilterRule]
|
PacketFilterRules views.Slice[tailcfg.FilterRule]
|
||||||
SSHPolicy *tailcfg.SSHPolicy // or nil, if not enabled/allowed
|
SSHPolicy *tailcfg.SSHPolicy // or nil, if not enabled/allowed
|
||||||
|
@ -41,6 +41,7 @@ import (
|
|||||||
"tailscale.com/types/key"
|
"tailscale.com/types/key"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
"tailscale.com/types/netmap"
|
"tailscale.com/types/netmap"
|
||||||
|
"tailscale.com/types/views"
|
||||||
"tailscale.com/util/clientmetric"
|
"tailscale.com/util/clientmetric"
|
||||||
"tailscale.com/util/deephash"
|
"tailscale.com/util/deephash"
|
||||||
"tailscale.com/util/mak"
|
"tailscale.com/util/mak"
|
||||||
@ -755,14 +756,13 @@ func (e *userspaceEngine) updateActivityMapsLocked(trackNodes []key.NodePublic,
|
|||||||
|
|
||||||
// hasOverlap checks if there is a IPPrefix which is common amongst the two
|
// hasOverlap checks if there is a IPPrefix which is common amongst the two
|
||||||
// provided slices.
|
// provided slices.
|
||||||
func hasOverlap(aips, rips []netip.Prefix) bool {
|
func hasOverlap(aips, rips views.Slice[netip.Prefix]) bool {
|
||||||
for _, aip := range aips {
|
for i := range aips.LenIter() {
|
||||||
for _, rip := range rips {
|
aip := aips.At(i)
|
||||||
if aip == rip {
|
if views.SliceContains(rips, aip) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,9 +800,9 @@ func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, routerCfg *router.Config,
|
|||||||
|
|
||||||
isSubnetRouter := false
|
isSubnetRouter := false
|
||||||
if e.birdClient != nil && nm != nil && nm.SelfNode.Valid() {
|
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",
|
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)
|
isSubnetRouter, isSubnetRouter, e.lastIsSubnetRouter)
|
||||||
}
|
}
|
||||||
isSubnetRouterChanged := isSubnetRouter != e.lastIsSubnetRouter
|
isSubnetRouterChanged := isSubnetRouter != e.lastIsSubnetRouter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user