diff options
author | Magesh GV <mageshgv@gmail.com> | 2019-09-30 10:36:54 -0700 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2019-10-02 20:45:44 +0900 |
commit | 6f3cb401644fcba0353ac06de261dd40100daa84 (patch) | |
tree | 0602d523c17bccf5ebf5ee15eb8c5c07bd19d39a /internal/pkg/table/adj_test.go | |
parent | 93beafeec5ec667602afe506f2692db81344d5a7 (diff) |
Update adjrib for LLGR and preserve aslooped attr
Fixes LLGR community cleared on softreset.
Fixes AS Path looped routes added back to rib on Graceful Restart.
Diffstat (limited to 'internal/pkg/table/adj_test.go')
-rw-r--r-- | internal/pkg/table/adj_test.go | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/internal/pkg/table/adj_test.go b/internal/pkg/table/adj_test.go index 8513bc97..9e48538f 100644 --- a/internal/pkg/table/adj_test.go +++ b/internal/pkg/table/adj_test.go @@ -69,14 +69,19 @@ func TestStale(t *testing.T) { p1 := NewPath(pi, nlri1, false, attrs, time.Now(), false) nlri2 := bgp.NewIPAddrPrefix(24, "20.20.20.0") p2 := NewPath(pi, nlri2, false, attrs, time.Now(), false) + p2.SetAsLooped(true) + family := p1.GetRouteFamily() families := []bgp.RouteFamily{family} adj := NewAdjRib(families) adj.Update([]*Path{p1, p2}) assert.Equal(t, adj.Count([]bgp.RouteFamily{family}), 2) + assert.Equal(t, adj.Accepted([]bgp.RouteFamily{family}), 1) - adj.StaleAll(families) + stalePathList := adj.StaleAll(families) + // As looped path should not be returned + assert.Equal(t, 1, len(stalePathList)) for _, p := range adj.PathList([]bgp.RouteFamily{family}, false) { assert.True(t, p.IsStale()) @@ -86,7 +91,45 @@ func TestStale(t *testing.T) { p3 := NewPath(pi, nlri3, false, attrs, time.Now(), false) adj.Update([]*Path{p1, p3}) - adj.DropStale(families) + droppedPathList := adj.DropStale(families) + assert.Equal(t, 2, len(droppedPathList)) assert.Equal(t, adj.Count([]bgp.RouteFamily{family}), 1) assert.Equal(t, 1, len(adj.table[family].destinations)) } + +func TestLLGRStale(t *testing.T) { + pi := &PeerInfo{} + attrs := []bgp.PathAttributeInterface{bgp.NewPathAttributeOrigin(0)} + + nlri1 := bgp.NewIPAddrPrefix(24, "20.20.10.0") + p1 := NewPath(pi, nlri1, false, attrs, time.Now(), false) + + nlri2 := bgp.NewIPAddrPrefix(24, "20.20.20.0") + p2 := NewPath(pi, nlri2, false, attrs, time.Now(), false) + p2.SetAsLooped(true) // Not accepted + + nlri3 := bgp.NewIPAddrPrefix(24, "20.20.30.0") + p3 := NewPath(pi, nlri3, false, attrs, time.Now(), false) + p3.SetAsLooped(true) + // Not accepted and then dropped on MarkLLGRStaleOrDrop + p3.SetCommunities([]uint32{uint32(bgp.COMMUNITY_NO_LLGR)}, false) + + nlri4 := bgp.NewIPAddrPrefix(24, "20.20.40.0") + p4 := NewPath(pi, nlri4, false, attrs, time.Now(), false) + // dropped on MarkLLGRStaleOrDrop + p4.SetCommunities([]uint32{uint32(bgp.COMMUNITY_NO_LLGR)}, false) + + family := p1.GetRouteFamily() + families := []bgp.RouteFamily{family} + + adj := NewAdjRib(families) + adj.Update([]*Path{p1, p2, p3, p4}) + assert.Equal(t, adj.Count([]bgp.RouteFamily{family}), 4) + assert.Equal(t, adj.Accepted([]bgp.RouteFamily{family}), 2) + + pathList := adj.MarkLLGRStaleOrDrop(families) + assert.Equal(t, 3, len(pathList)) // Does not return aslooped path that is retained in adjrib + assert.Equal(t, adj.Count([]bgp.RouteFamily{family}), 2) + assert.Equal(t, adj.Accepted([]bgp.RouteFamily{family}), 1) + assert.Equal(t, 2, len(adj.table[family].destinations)) +} |