[client] Detect default route changes in the Linux network monitor (#8216)

The Linux network monitor skipped every route update whose Dst was not
nil, treating a nil Dst as the default route. Since the bump to
vishvananda/netlink v1.3 (v0.43.0) the default route arrives as an
explicit 0.0.0.0/0 or ::/0, so every default route change was filtered
out and the monitor never fired on Linux, no matter how the underlay
moved.

Treat both a nil Dst and a zero-length prefix as the default route.
This commit is contained in:
Riccardo Manfrin
2026-10-15 12:19:57 +02:00
committed by GitHub
parent 9d837c6ae6
commit 547dd1f177
2 changed files with 55 additions and 1 deletions
@@ -6,6 +6,7 @@ import (
"context"
"errors"
"fmt"
"net"
"syscall"
log "github.com/sirupsen/logrus"
@@ -35,7 +36,7 @@ func checkChange(ctx context.Context, nexthopv4, nexthopv6 systemops.Nexthop) er
// handle route changes
case route := <-routeChan:
// default route and main table
if route.Dst != nil || route.Table != syscall.RT_TABLE_MAIN {
if !isDefaultRoute(route.Dst) || route.Table != syscall.RT_TABLE_MAIN {
continue
}
switch route.Type {
@@ -52,3 +53,13 @@ func checkChange(ctx context.Context, nexthopv4, nexthopv6 systemops.Nexthop) er
}
}
}
// isDefaultRoute reports whether dst is a default route. netlink v1.3 reports
// the default as 0.0.0.0/0 or ::/0, older versions as a nil Dst.
func isDefaultRoute(dst *net.IPNet) bool {
if dst == nil {
return true
}
ones, _ := dst.Mask.Size()
return ones == 0
}