Fix switch-to-switch link detection for downstream nodes

This commit is contained in:
Ian Gulliver
2026-01-24 11:48:24 -08:00
parent bf787209a5
commit 7c0d4ad05a
2 changed files with 22 additions and 2 deletions

23
link.go
View File

@@ -93,6 +93,13 @@ func (n *Nodes) findLastHop(target *Node, mac string, macToNode map[string]*Node
} }
func (n *Nodes) hasCloserNode(node, target *Node, mac, port string, macToNode map[string]*Node) bool { func (n *Nodes) hasCloserNode(node, target *Node, mac, port string, macToNode map[string]*Node) bool {
nodeMACs := map[string]bool{}
for _, iface := range node.Interfaces {
if iface.MAC != "" {
nodeMACs[string(iface.MAC)] = true
}
}
for otherMAC, otherPort := range node.MACTable { for otherMAC, otherPort := range node.MACTable {
if otherPort != port { if otherPort != port {
continue continue
@@ -101,7 +108,21 @@ func (n *Nodes) hasCloserNode(node, target *Node, mac, port string, macToNode ma
if otherNode == nil || otherNode == node || otherNode == target { if otherNode == nil || otherNode == node || otherNode == target {
continue continue
} }
if _, alsoSees := otherNode.MACTable[mac]; alsoSees {
targetPort, alsoSees := otherNode.MACTable[mac]
if !alsoSees {
continue
}
seesNodeOnSamePort := false
for nodeMAC := range nodeMACs {
if nodePort, seesNode := otherNode.MACTable[nodeMAC]; seesNode && nodePort == targetPort {
seesNodeOnSamePort = true
break
}
}
if !seesNodeOnSamePort {
return true return true
} }
} }

View File

@@ -113,7 +113,6 @@
} }
fetchAndRender(); fetchAndRender();
setInterval(fetchAndRender, 30000);
</script> </script>
</body> </body>
</html> </html>