From 45b226f0bccb2f9f4080fd01f8bb54728e7b2fc3 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Sun, 25 Oct 2026 11:53:45 +0100 Subject: [PATCH] =?UTF-8?q?f-81:=20watchdog:=20VRF=20sans=20route=20unreac?= =?UTF-8?q?hable=20default=20signal=C3=A9e=20#81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: GnomeZworc --- internal/watchdog/check_l3.go | 13 ++++++++++ internal/watchdog/check_l3_test.go | 38 ++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/internal/watchdog/check_l3.go b/internal/watchdog/check_l3.go index 0fee453..fae7759 100644 --- a/internal/watchdog/check_l3.go +++ b/internal/watchdog/check_l3.go @@ -25,6 +25,7 @@ type l3Probe interface { NeighborEstablished(peer net.IP) (bool, error) VNI(vni uint32) (frr.VNIState, error) ExportedRoutes(table uint32, iface string) ([]*net.IPNet, error) + UnreachableDefault(table uint32) (bool, error) LinkProblem(ns, iface string) string } @@ -44,6 +45,10 @@ func (systemProbe) ExportedRoutes(table uint32, iface string) ([]*net.IPNet, err return netif.TableRoutesVia(int(table), iface) } +func (systemProbe) UnreachableDefault(table uint32) (bool, error) { + return netif.HasUnreachableDefault(int(table), l3vni.UnreachableMetric) +} + func (systemProbe) LinkProblem(ns, iface string) string { if ns == "" { return linkProblem(iface) @@ -145,6 +150,14 @@ func checkL3VPC(db *badger.DB, name string, r l3vni.Routing, rmac string, p l3Pr n.Notify(kindVPC, name, fmt.Sprintf("l3vni %d has router mac %q in frr, expected %s", r.VNI, s.RouterMAC, rmac)) } + present, err := p.UnreachableDefault(r.VNI) + switch { + case err != nil: + n.Notify(kindVPC, name, fmt.Sprintf("unreachable default of %s unreadable: %v", r.VRF, err)) + case !present: + n.Notify(kindVPC, name, fmt.Sprintf("no unreachable default in %s: traffic to an unknown destination leaves through the host routing table", r.VRF)) + } + actual, err := p.ExportedRoutes(r.VNI, r.VethHost) if err != nil { n.Notify(kindVPC, name, fmt.Sprintf("routes of %s unreadable: %v", r.VRF, err)) diff --git a/internal/watchdog/check_l3_test.go b/internal/watchdog/check_l3_test.go index c307b30..f84a6a3 100644 --- a/internal/watchdog/check_l3_test.go +++ b/internal/watchdog/check_l3_test.go @@ -19,6 +19,8 @@ type fakeProbe struct { routesErr error links map[string]string vtepErr error + unreachable map[uint32]bool + unreachErr error } func (f *fakeProbe) VTEPAddress(string) (net.IP, error) { @@ -49,6 +51,13 @@ func (f *fakeProbe) ExportedRoutes(table uint32, _ string) ([]*net.IPNet, error) return out, f.routesErr } +func (f *fakeProbe) UnreachableDefault(table uint32) (bool, error) { + if f.unreachable == nil { + return true, f.unreachErr + } + return f.unreachable[table], f.unreachErr +} + func (f *fakeProbe) LinkProblem(ns, iface string) string { return f.links[ns+"/"+iface] } @@ -240,3 +249,32 @@ func TestCheckL3VPCsReportsUnreadableRoutesAndVTEP(t *testing.T) { t.Errorf("RMAC comparée sans VTEP : %q", notified(r)) } } + +func TestCheckL3VPCsReportsAVRFWithoutUnreachableDefault(t *testing.T) { + db := newTestDB(t) + seedResource(t, db, prefixVPC, "vp-s7", state.Running) + seedKV(t, db, "vpc/vp-s7/cidr", "10.241.0.0/16") + seedKV(t, db, "vpc/vp-s7/l3vni", "2700") + seedResource(t, db, prefixVPC, "vp-s8", state.Running) + seedKV(t, db, "vpc/vp-s8/cidr", "10.242.0.0/16") + seedKV(t, db, "vpc/vp-s8/l3vni", "2800") + p := seedRoutedVPC(t) + p.vni[2800] = frr.VNIState{Type: "L3", State: "Up", RouterMAC: "02:02:c0:a8:0e:0b"} + p.unreachable = map[uint32]bool{2700: true} + r := &recorder{} + if err := CheckL3VPCs(db, bgpCfg(), p, r); err != nil { + t.Fatal(err) + } + want := []string{"vpc vp-s8: no unreachable default in vrf-s8: traffic to an unknown destination leaves through the host routing table"} + if got := notified(r); !reflect.DeepEqual(got, want) { + t.Errorf("notifications :\n%q\nattendu :\n%q", got, want) + } + + p.unreachable = map[uint32]bool{2700: true, 2800: true} + p.unreachErr = errors.New("netlink refused") + r = &recorder{} + CheckL3VPCs(db, bgpCfg(), p, r) + if !r.hasProblemContaining("unreachable default of vrf-s7 unreadable: netlink refused") || r.hasProblemContaining("no unreachable default") { + t.Errorf("notifications %q", notified(r)) + } +}