mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-03 22:21:17 +00:00
ipn/ipnlocal: return old hwaddrs if missing
If we previously knew of macaddresses of a node, and they suddenly goes to zero, ignore them and return the previous hardware addresses. Updates tailscale/corp#25168 Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
2a12e634bf
commit
cdde301ca5
@ -360,7 +360,7 @@ func handleC2NPostureIdentityGet(b *LocalBackend, w http.ResponseWriter, r *http
|
|||||||
// and looks good in client metrics, remove this parameter and always report MAC
|
// and looks good in client metrics, remove this parameter and always report MAC
|
||||||
// addresses.
|
// addresses.
|
||||||
if r.FormValue("hwaddrs") == "true" {
|
if r.FormValue("hwaddrs") == "true" {
|
||||||
res.IfaceHardwareAddrs, err = posture.GetHardwareAddrs()
|
res.IfaceHardwareAddrs, err = b.getHardwareAddrs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.logf("c2n: GetHardwareAddrs returned error: %v", err)
|
b.logf("c2n: GetHardwareAddrs returned error: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,7 @@ import (
|
|||||||
"tailscale.com/net/tsdial"
|
"tailscale.com/net/tsdial"
|
||||||
"tailscale.com/paths"
|
"tailscale.com/paths"
|
||||||
"tailscale.com/portlist"
|
"tailscale.com/portlist"
|
||||||
|
"tailscale.com/posture"
|
||||||
"tailscale.com/syncs"
|
"tailscale.com/syncs"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
"tailscale.com/taildrop"
|
"tailscale.com/taildrop"
|
||||||
@ -433,6 +434,12 @@ type LocalBackend struct {
|
|||||||
// notified about.
|
// notified about.
|
||||||
lastNotifiedDriveShares *views.SliceView[*drive.Share, drive.ShareView]
|
lastNotifiedDriveShares *views.SliceView[*drive.Share, drive.ShareView]
|
||||||
|
|
||||||
|
// lastKnownHardwareAddrs is a list of the previous known hardware addrs.
|
||||||
|
// Previously known hwaddrs are kept to work around an issue on Windows
|
||||||
|
// where all addresses might disappear.
|
||||||
|
// http://go/corp/25168
|
||||||
|
lastKnownHardwareAddrs syncs.AtomicValue[[]string]
|
||||||
|
|
||||||
// outgoingFiles keeps track of Taildrop outgoing files keyed to their OutgoingFile.ID
|
// outgoingFiles keeps track of Taildrop outgoing files keyed to their OutgoingFile.ID
|
||||||
outgoingFiles map[string]*ipn.OutgoingFile
|
outgoingFiles map[string]*ipn.OutgoingFile
|
||||||
|
|
||||||
@ -7619,6 +7626,25 @@ func (b *LocalBackend) notifyProfileChangeLocked(profile ipn.LoginProfileView, p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getHardwareAddrs returns the hardware addresses for the machine. If the list
|
||||||
|
// of hardware addresses is empty, it will return the previously known hardware
|
||||||
|
// addresses. Both the current, and previously known hardware addresses might be
|
||||||
|
// empty.
|
||||||
|
func (b *LocalBackend) getHardwareAddrs() ([]string, error) {
|
||||||
|
addrs, err := posture.GetHardwareAddrs()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(addrs) == 0 {
|
||||||
|
b.logf("getHardwareAddrs: got empty list of hwaddrs, returning previous list")
|
||||||
|
return b.lastKnownHardwareAddrs.Load(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
b.lastKnownHardwareAddrs.Store(addrs)
|
||||||
|
return addrs, nil
|
||||||
|
}
|
||||||
|
|
||||||
// resetForProfileChangeLockedOnEntry resets the backend for a profile change.
|
// resetForProfileChangeLockedOnEntry resets the backend for a profile change.
|
||||||
//
|
//
|
||||||
// b.mu must held on entry. It is released on exit.
|
// b.mu must held on entry. It is released on exit.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user