f-81: watchdog: VRF sans route unreachable default signalée #81
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
cc8ddfe882
commit
45b226f0bc
2 changed files with 51 additions and 0 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue