summaryrefslogtreecommitdiffhomepage
path: root/table/destination_test.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-04-20 08:03:54 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-04-21 15:37:11 +0900
commitc6ddfb1d8ecc5944a775a458fbce648713ae3b02 (patch)
tree74b7b07a95211518df1b5225c76f79c813defef8 /table/destination_test.go
parent8ab34acd769fbeb1647bf5161f349388df73c013 (diff)
table: use received time as tie-breaker
older path get preference can be disabled by `global.route-selection-options.external-compare-router-id = true` close #806 Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/destination_test.go')
-rw-r--r--table/destination_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/table/destination_test.go b/table/destination_test.go
index 32316f5f..c0666e21 100644
--- a/table/destination_test.go
+++ b/table/destination_test.go
@@ -217,6 +217,42 @@ func TestImplicitWithdrawCalculate(t *testing.T) {
assert.Equal(t, len(d.knownPathList), 1)
}
+func TestTimeTieBreaker(t *testing.T) {
+ origin := bgp.NewPathAttributeOrigin(0)
+ aspathParam := []bgp.AsPathParamInterface{bgp.NewAs4PathParam(2, []uint32{65001})}
+ aspath := bgp.NewPathAttributeAsPath(aspathParam)
+ nexthop := bgp.NewPathAttributeNextHop("10.0.0.1")
+ med := bgp.NewPathAttributeMultiExitDisc(0)
+ pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med}
+ nlri := bgp.NewIPAddrPrefix(24, "10.10.0.0")
+ updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, []*bgp.IPAddrPrefix{nlri})
+ peer1 := &PeerInfo{AS: 2, LocalAS: 1, Address: net.IP{1, 1, 1, 1}, ID: net.IP{1, 1, 1, 1}}
+ path1 := ProcessMessage(updateMsg, peer1, time.Now())[0]
+
+ peer2 := &PeerInfo{AS: 2, LocalAS: 1, Address: net.IP{2, 2, 2, 2}, ID: net.IP{2, 2, 2, 2}} // weaker router-id
+ path2 := ProcessMessage(updateMsg, peer2, time.Now().Add(-1*time.Hour))[0] // older than path1
+
+ d := NewDestination(nlri)
+ d.addNewPath(path1)
+ d.addNewPath(path2)
+
+ d.Calculate(nil)
+
+ assert.Equal(t, len(d.knownPathList), 2)
+ assert.Equal(t, true, d.GetBestPath("").GetSource().ID.Equal(net.IP{2, 2, 2, 2})) // path from peer2 win
+
+ // this option disables tie breaking by age
+ SelectionOptions.ExternalCompareRouterId = true
+ d = NewDestination(nlri)
+ d.addNewPath(path1)
+ d.addNewPath(path2)
+
+ d.Calculate(nil)
+
+ assert.Equal(t, len(d.knownPathList), 2)
+ assert.Equal(t, true, d.GetBestPath("").GetSource().ID.Equal(net.IP{1, 1, 1, 1})) // path from peer1 win
+}
+
func DestCreatePeer() []*PeerInfo {
peerD1 := &PeerInfo{AS: 65000}
peerD2 := &PeerInfo{AS: 65001}