merge nodes when update discovers mac belongs to different node

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ian Gulliver
2026-01-18 14:47:46 -08:00
parent 9bcda6b96c
commit 2262e8d3bf

View File

@@ -98,11 +98,15 @@ func (n *Nodes) Update(target *Node, mac net.HardwareAddr, ips []net.IP, ifaceNa
}
}
if targetID == -1 && mac != nil {
if mac != nil {
macKey := mac.String()
if id, exists := n.macIndex[macKey]; exists {
if _, nodeExists := n.nodes[id]; nodeExists {
if targetID == -1 {
targetID = id
} else if id != targetID {
n.mergeNodes(targetID, id)
}
} else {
delete(n.macIndex, macKey)
}