diff options
-rw-r--r-- | table/table_manager.go | 3 | ||||
-rw-r--r-- | table/table_manager_test.go | 60 |
2 files changed, 20 insertions, 43 deletions
diff --git a/table/table_manager.go b/table/table_manager.go index cb54906e..3d52fce7 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -215,9 +215,6 @@ 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 c21299da..d65db21f 100644 --- a/table/table_manager_test.go +++ b/table/table_manager_test.go @@ -209,9 +209,8 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv4(t *testing.T) { peer2 := peerR2() pList, err = tm.ProcessUpdate(peer2, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -296,9 +295,8 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv6(t *testing.T) { peer2 := peerR2() pList, err = tm.ProcessUpdate(peer2, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -385,9 +383,8 @@ 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, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -475,9 +472,8 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv6(t *testing.T) { } pList, err = tm.ProcessUpdate(peer2, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -535,9 +531,8 @@ func TestProcessBGPUpdate_3_select_aspath_ipv4(t *testing.T) { bgpMessage2 := update_fromR2() peer2 := peerR2() pList, err = tm.ProcessUpdate(peer2, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -593,9 +588,8 @@ func TestProcessBGPUpdate_3_select_aspath_ipv6(t *testing.T) { bgpMessage2 := update_fromR2_ipv6() peer2 := peerR2() pList, err = tm.ProcessUpdate(peer2, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -680,9 +674,8 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv4(t *testing.T) { peer2 := peerR2() pList, err = tm.ProcessUpdate(peer2, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -767,9 +760,8 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv6(t *testing.T) { peer2 := peerR2() pList, err = tm.ProcessUpdate(peer2, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -854,9 +846,8 @@ func TestProcessBGPUpdate_5_select_low_med_ipv4(t *testing.T) { peer2 := peerR2() pList, err = tm.ProcessUpdate(peer2, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -941,9 +932,8 @@ func TestProcessBGPUpdate_5_select_low_med_ipv6(t *testing.T) { peer2 := peerR2() pList, err = tm.ProcessUpdate(peer2, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -1030,9 +1020,8 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv4(t *testing.T) { peer2 := peerR2() pList, err = tm.ProcessUpdate(peer2, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -1118,9 +1107,8 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv6(t *testing.T) { peer2 := peerR2() pList, err = tm.ProcessUpdate(peer2, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -1209,9 +1197,8 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv4(t *testing.T) { peer3 := peerR3() pList, err = tm.ProcessUpdate(peer3, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -1297,9 +1284,8 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv6(t *testing.T) { peer3 := peerR3() pList, err = tm.ProcessUpdate(peer3, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -1385,9 +1371,8 @@ func TestProcessBGPUpdate_8_withdraw_path_ipv4(t *testing.T) { peer2 := peerR2() pList, err = tm.ProcessUpdate(peer2, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -1435,9 +1420,8 @@ 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, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) path = pList[0] @@ -1497,9 +1481,8 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) { peer2 := peerR2() pList, err = tm.ProcessUpdate(peer2, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -1572,9 +1555,8 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) { []bgp.PathAttributeInterface{mp_unreach}, []bgp.NLRInfo{}) pList, err = tm.ProcessUpdate(peer2, bgpMessage3) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) path = pList[0] @@ -1782,9 +1764,8 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv4(t *testing.T) { assert.NoError(t, err) pList, err = tm.ProcessUpdate(peer1, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type @@ -1870,9 +1851,8 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv6(t *testing.T) { assert.NoError(t, err) pList, err = tm.ProcessUpdate(peer1, bgpMessage2) - assert.Equal(t, 2, len(pList)) + assert.Equal(t, 1, len(pList)) assert.Equal(t, pList[0].IsWithdraw(), false) - assert.Equal(t, pList[1].IsWithdraw(), true) assert.NoError(t, err) // check type |