Skip to content

Commit e956a95

Browse files
fix(net/netmon): skip RTM_MISS route messages on Darwin (#113)
On Darwin, the AF_ROUTE socket delivers RTM_MISS on every failed route lookup. When a STUN probe targets an IPv6 address with no route (common on machines without global v6 connectivity), each probe generates an RTM_MISS that netmon treats as a LinkChange. The LinkChange triggers ReSTUN, which fires another probe, creating a self-sustaining loop (~1.3 events/s vs the normal ~1/30s cadence). RTM_MISS is emitted from the route lookup path, not the table mutation path. Route withdrawals always emit RTM_DELETE before any subsequent lookup can miss, so RTM_MISS is never the leading signal for a real topology change. Every mature BSD route-socket consumer (bird, dhcpcd, frr) ignores it for table-change purposes.
1 parent d5fe431 commit e956a95

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

net/netmon/netmon_darwin.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@ func (m *darwinRouteMon) skipInterfaceAddrMessage(msg *route.InterfaceAddrMessag
132132
}
133133

134134
func (m *darwinRouteMon) skipRouteMessage(msg *route.RouteMessage) bool {
135+
// RTM_MISS fires on every failed route lookup (no matching
136+
// entry in the routing table). It scales with traffic volume,
137+
// not network-state changes, and is never the leading signal
138+
// for a topology change — route withdrawals emit RTM_DELETE
139+
// synchronously before any subsequent lookup can miss.
140+
// Letting these through causes netmon to report spurious
141+
// LinkChange events, which trigger a ReSTUN/netcheck loop
142+
// when the destination is unreachable (e.g. STUN probes to
143+
// an IPv6 address with no route).
144+
if msg.Type == unix.RTM_MISS {
145+
return true
146+
}
135147
if ip := ipOfAddr(addrType(msg.Addrs, unix.RTAX_DST)); ip.IsLinkLocalUnicast() {
136148
// Skip those like:
137149
// dst = fe80::b476:66ff:fe30:c8f6%15

0 commit comments

Comments
 (0)