From 32da723b2cb7445fb06eea8796f1da639fddd29f Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sat, 31 Jan 2026 13:20:20 -0800 Subject: [PATCH] Clear MAC table on each SNMP poll and reduce ping threshold Co-Authored-By: Claude Opus 4.5 --- .claude/settings.local.json | 6 +++++- .gitignore | 2 +- config.yaml | 3 +++ nodes.go | 7 +++++++ ping.go | 2 +- snmp.go | 2 ++ types.go | 2 +- 7 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index ca5e438..30ed05e 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -94,7 +94,11 @@ "Bash(go test:*)", "Bash(git stash:*)", "Bash(git revert:*)", - "Bash(done)" + "Bash(done)", + "Bash(while read id)", + "Bash(do cat /home/flamingcow/tendrils/status)", + "Bash(for id in node_01kgay2wynew8tjh1bpr9sd11e node_01kgay2wynew2t7qmfvtkrq2nb node_01kgay2wykevgbkxfvavxgpq30 node_01kgay2wynew5b80p45h8mdtpj node_01kgay2wynevtsrw26tprvqysw node_01kgay2wynevy9gp10a6rr4y2d)", + "Bash(do)" ], "ask": [ "Bash(rm *)" diff --git a/.gitignore b/.gitignore index dc866f2..b49eee4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ log *~ cert.pem key.pem -status +status* diff --git a/config.yaml b/config.yaml index a23d098..5ff27db 100644 --- a/config.yaml +++ b/config.yaml @@ -217,3 +217,6 @@ locations: nodes: - names: ["sunset"] - names: ["RX-CONTROL-1"] + +shared_names: + - "ULXD4Q G50 REV5" diff --git a/nodes.go b/nodes.go index d9c0125..bb4e123 100644 --- a/nodes.go +++ b/nodes.go @@ -503,6 +503,13 @@ func (n *Nodes) UpdateMACTable(node *Node, peerMAC net.HardwareAddr, ifaceName s node.MACTable[peerMAC.String()] = ifaceName } +func (n *Nodes) ClearMACTable(node *Node) { + n.mu.Lock() + defer n.mu.Unlock() + + node.MACTable = map[string]string{} +} + func (n *Nodes) SetDanteClockMaster(ip net.IP) { n.Update(nil, nil, []net.IP{ip}, "", "", "ptp") diff --git a/ping.go b/ping.go index e6b8b44..d382c3c 100644 --- a/ping.go +++ b/ping.go @@ -24,7 +24,7 @@ type PingManager struct { failures map[string]int } -const pingFailureThreshold = 5 +const pingFailureThreshold = 3 func NewPingManager() *PingManager { pm := &PingManager{ diff --git a/snmp.go b/snmp.go index 684f012..0d430b3 100644 --- a/snmp.go +++ b/snmp.go @@ -544,6 +544,8 @@ func (t *Tendrils) queryBridgeMIB(snmp *gosnmp.GoSNMP, node *Node, ifNames map[i bridgePortToIfIndex := t.getBridgePortMapping(snmp) + t.nodes.ClearMACTable(node) + for _, entry := range macPorts { mac := entry.mac diff --git a/types.go b/types.go index 04de840..dbf225e 100644 --- a/types.go +++ b/types.go @@ -453,7 +453,7 @@ type Node struct { ID string `json:"id"` Names NameSet `json:"names"` Interfaces InterfaceMap `json:"interfaces"` - MACTable map[string]string `json:"-"` + MACTable map[string]string `json:"mac_table,omitempty"` PoEBudget *PoEBudget `json:"poe_budget,omitempty"` DanteTxChannels int `json:"dante_tx_channels,omitempty"` DanteClockMasterSeen time.Time `json:"-"`