diff options
author | Jordan Whited <jwhited@subspace.com> | 2020-08-10 09:43:54 -0700 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2020-08-12 20:56:11 +0900 |
commit | a4d5d004cc3d97c90de0c2d91f2312525e055d68 (patch) | |
tree | 88f5d6ed07117fa3ebd048c70db03ace2e5a6f1b /internal/pkg/table/destination_test.go | |
parent | c6f0eba8f4d8544ede83c70d6b5f07560ff6c7ce (diff) |
best path selection - compare neigh addr
Diffstat (limited to 'internal/pkg/table/destination_test.go')
-rw-r--r-- | internal/pkg/table/destination_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/pkg/table/destination_test.go b/internal/pkg/table/destination_test.go index b1c1b2e8..3534cb6c 100644 --- a/internal/pkg/table/destination_test.go +++ b/internal/pkg/table/destination_test.go @@ -118,6 +118,28 @@ func TestCalculate2(t *testing.T) { assert.Equal(t, len(d.knownPathList), 3) } +func TestNeighAddrTieBreak(t *testing.T) { + nlri := bgp.NewIPAddrPrefix(24, "10.10.0.0") + + peer0 := &PeerInfo{AS: 65001, LocalAS: 1, Address: net.IP{2, 2, 2, 2}, ID: net.IP{2, 2, 2, 2}} + + p0 := func() *Path { + aspath := bgp.NewPathAttributeAsPath([]bgp.AsPathParamInterface{bgp.NewAs4PathParam(bgp.BGP_ASPATH_ATTR_TYPE_SEQ, []uint32{65001})}) + attrs := []bgp.PathAttributeInterface{aspath, bgp.NewPathAttributeMultiExitDisc(0)} + return NewPath(peer0, nlri, false, attrs, time.Now(), false) + }() + + peer1 := &PeerInfo{AS: 65001, LocalAS: 1, Address: net.IP{3, 3, 3, 3}, ID: net.IP{2, 2, 2, 2}} // same ID as peer0, separate eBGP session + + p1 := func() *Path { + aspath := bgp.NewPathAttributeAsPath([]bgp.AsPathParamInterface{bgp.NewAs4PathParam(bgp.BGP_ASPATH_ATTR_TYPE_SEQ, []uint32{65001})}) + attrs := []bgp.PathAttributeInterface{aspath, bgp.NewPathAttributeMultiExitDisc(0)} + return NewPath(peer1, nlri, false, attrs, time.Now(), false) + }() + + assert.Equal(t, compareByNeighborAddress(p0, p1), p0) +} + func TestMedTieBreaker(t *testing.T) { nlri := bgp.NewIPAddrPrefix(24, "10.10.0.0") |