summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-04-27 14:53:46 +0000
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-04-27 15:20:53 +0000
commitf8832eb4811f57d16211fe31986b395ffb3c6ff0 (patch)
tree566d589ac4184bc0180457f018263aaa64493147 /table
parent6c32d42632df7b36459b6575b9c193f940a87865 (diff)
table: withdraw an old best path when best path changed
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/table_manager.go3
-rw-r--r--table/table_manager_test.go60
2 files changed, 43 insertions, 20 deletions
diff --git a/table/table_manager.go b/table/table_manager.go
index 37452e65..d4da1735 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -213,6 +213,9 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, e
}).Debug("new best path")
newPaths = append(newPaths, newBestPath)
+ if currentBestPath != nil {
+ newPaths = append(newPaths, currentBestPath.Clone(true))
+ }
destination.setBestPath(newBestPath)
}
diff --git a/table/table_manager_test.go b/table/table_manager_test.go
index d65db21f..c21299da 100644
--- a/table/table_manager_test.go
+++ b/table/table_manager_test.go
@@ -209,8 +209,9 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv4(t *testing.T) {
peer2 := peerR2()
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -295,8 +296,9 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv6(t *testing.T) {
peer2 := peerR2()
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -383,8 +385,9 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv4(t *testing.T) {
Address: net.ParseIP("0.0.0.0"),
}
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -472,8 +475,9 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv6(t *testing.T) {
}
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -531,8 +535,9 @@ func TestProcessBGPUpdate_3_select_aspath_ipv4(t *testing.T) {
bgpMessage2 := update_fromR2()
peer2 := peerR2()
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -588,8 +593,9 @@ func TestProcessBGPUpdate_3_select_aspath_ipv6(t *testing.T) {
bgpMessage2 := update_fromR2_ipv6()
peer2 := peerR2()
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -674,8 +680,9 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv4(t *testing.T) {
peer2 := peerR2()
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -760,8 +767,9 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv6(t *testing.T) {
peer2 := peerR2()
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -846,8 +854,9 @@ func TestProcessBGPUpdate_5_select_low_med_ipv4(t *testing.T) {
peer2 := peerR2()
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -932,8 +941,9 @@ func TestProcessBGPUpdate_5_select_low_med_ipv6(t *testing.T) {
peer2 := peerR2()
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -1020,8 +1030,9 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv4(t *testing.T) {
peer2 := peerR2()
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -1107,8 +1118,9 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv6(t *testing.T) {
peer2 := peerR2()
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -1197,8 +1209,9 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv4(t *testing.T) {
peer3 := peerR3()
pList, err = tm.ProcessUpdate(peer3, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -1284,8 +1297,9 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv6(t *testing.T) {
peer3 := peerR3()
pList, err = tm.ProcessUpdate(peer3, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -1371,8 +1385,9 @@ func TestProcessBGPUpdate_8_withdraw_path_ipv4(t *testing.T) {
peer2 := peerR2()
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -1420,8 +1435,9 @@ func TestProcessBGPUpdate_8_withdraw_path_ipv4(t *testing.T) {
bgpMessage3 := bgp.NewBGPUpdateMessage(w, []bgp.PathAttributeInterface{}, []bgp.NLRInfo{})
pList, err = tm.ProcessUpdate(peer2, bgpMessage3)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
path = pList[0]
@@ -1481,8 +1497,9 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
peer2 := peerR2()
pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -1555,8 +1572,9 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
[]bgp.PathAttributeInterface{mp_unreach}, []bgp.NLRInfo{})
pList, err = tm.ProcessUpdate(peer2, bgpMessage3)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
path = pList[0]
@@ -1764,8 +1782,9 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv4(t *testing.T) {
assert.NoError(t, err)
pList, err = tm.ProcessUpdate(peer1, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type
@@ -1851,8 +1870,9 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv6(t *testing.T) {
assert.NoError(t, err)
pList, err = tm.ProcessUpdate(peer1, bgpMessage2)
- assert.Equal(t, 1, len(pList))
+ assert.Equal(t, 2, len(pList))
assert.Equal(t, pList[0].IsWithdraw(), false)
+ assert.Equal(t, pList[1].IsWithdraw(), true)
assert.NoError(t, err)
// check type