summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-03-19 17:18:16 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-03-19 17:18:16 +0900
commit9152c24906d712ab1334e22df6d9b48c38cdf665 (patch)
tree99201b7e5bfb8097fa999b4da701b4182986d79c /table
parent0076c6d4104c1c03715683b11766c69ebfeaee87 (diff)
table: remove unnecessary distinction of paths
struct Path has a flag which can tell whether the path is withdrawal path or not. so table.ProcessPaths() needs not to return withdrawal path and non-withdrawal path separetly. this removes such unnecessary distinction. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/table_manager.go21
-rw-r--r--table/table_manager_test.go228
2 files changed, 130 insertions, 119 deletions
diff --git a/table/table_manager.go b/table/table_manager.go
index f2ff1ee6..c8ff0833 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -146,9 +146,8 @@ func NewTableManager(owner string, rfList []bgp.RouteFamily) *TableManager {
return t
}
-func (manager *TableManager) calculate(destinationList []Destination) ([]Path, []Path, error) {
- bestPaths := make([]Path, 0)
- lostPaths := make([]Path, 0)
+func (manager *TableManager) calculate(destinationList []Destination) ([]Path, error) {
+ newPaths := make([]Path, 0)
for _, destination := range destinationList {
// compute best path
@@ -202,7 +201,7 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, [
p := destination.getBestPath()
destination.setOldBestPath(p)
- lostPaths = append(lostPaths, p.clone(true))
+ newPaths = append(newPaths, p.clone(true))
}
destination.setBestPath(nil)
} else {
@@ -223,7 +222,7 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, [
"reason": reason,
}).Debug("new best path")
- bestPaths = append(bestPaths, newBestPath)
+ newPaths = append(newPaths, newBestPath)
destination.setBestPath(newBestPath)
}
@@ -239,18 +238,18 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, [
}).Debug("destination removed")
}
}
- return bestPaths, lostPaths, nil
+ return newPaths, nil
}
-func (manager *TableManager) DeletePathsforPeer(peerInfo *PeerInfo, rf bgp.RouteFamily) ([]Path, []Path, error) {
+func (manager *TableManager) DeletePathsforPeer(peerInfo *PeerInfo, rf bgp.RouteFamily) ([]Path, error) {
if _, ok := manager.Tables[rf]; ok {
destinationList := manager.Tables[rf].DeleteDestByPeer(peerInfo)
return manager.calculate(destinationList)
}
- return []Path{}, []Path{}, nil
+ return []Path{}, nil
}
-func (manager *TableManager) ProcessPaths(pathList []Path) ([]Path, []Path, error) {
+func (manager *TableManager) ProcessPaths(pathList []Path) ([]Path, error) {
destinationList := make([]Destination, 0)
for _, path := range pathList {
rf := path.GetRouteFamily()
@@ -264,7 +263,7 @@ func (manager *TableManager) ProcessPaths(pathList []Path) ([]Path, []Path, erro
// process BGPUpdate message
// this function processes only BGPUpdate
-func (manager *TableManager) ProcessUpdate(fromPeer *PeerInfo, message *bgp.BGPMessage) ([]Path, []Path, error) {
+func (manager *TableManager) ProcessUpdate(fromPeer *PeerInfo, message *bgp.BGPMessage) ([]Path, error) {
// check msg's type if it's BGPUpdate
if message.Header.Type != bgp.BGP_MSG_UPDATE {
log.WithFields(log.Fields{
@@ -273,7 +272,7 @@ func (manager *TableManager) ProcessUpdate(fromPeer *PeerInfo, message *bgp.BGPM
"key": fromPeer.Address.String(),
"Type": message.Header.Type,
}).Warn("message is not BGPUpdate")
- return []Path{}, []Path{}, nil
+ return []Path{}, nil
}
msg := &ProcessMessage{
diff --git a/table/table_manager_test.go b/table/table_manager_test.go
index fecee20a..5d3ed1b8 100644
--- a/table/table_manager_test.go
+++ b/table/table_manager_test.go
@@ -71,9 +71,9 @@ func TestProcessBGPUpdate_0_select_onlypath_ipv4(t *testing.T) {
bgpMessage := update_fromR1()
peer := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer, bgpMessage)
+ pList, err := tm.ProcessUpdate(peer, bgpMessage)
assert.Equal(t, len(pList), 1)
- assert.Equal(t, len(wList), 0)
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -122,9 +122,9 @@ func TestProcessBGPUpdate_0_select_onlypath_ipv6(t *testing.T) {
bgpMessage := update_fromR1_ipv6()
peer := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer, bgpMessage)
+ pList, err := tm.ProcessUpdate(peer, bgpMessage)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -202,15 +202,15 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv4(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
peer2 := peerR2()
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -288,15 +288,15 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv6(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
peer2 := peerR2()
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -374,17 +374,17 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv4(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
var peer2 *PeerInfo = &PeerInfo{
Address: net.ParseIP("0.0.0.0"),
}
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -462,18 +462,18 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv6(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
var peer2 *PeerInfo = &PeerInfo{
Address: net.ParseIP("0.0.0.0"),
}
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -524,15 +524,15 @@ func TestProcessBGPUpdate_3_select_aspath_ipv4(t *testing.T) {
bgpMessage1 := update_fromR2viaR1()
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
bgpMessage2 := update_fromR2()
peer2 := peerR2()
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -581,15 +581,15 @@ func TestProcessBGPUpdate_3_select_aspath_ipv6(t *testing.T) {
bgpMessage1 := update_fromR2viaR1_ipv6()
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
bgpMessage2 := update_fromR2_ipv6()
peer2 := peerR2()
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -667,15 +667,15 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv4(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
peer2 := peerR2()
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -753,15 +753,15 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv6(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
peer2 := peerR2()
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -839,15 +839,15 @@ func TestProcessBGPUpdate_5_select_low_med_ipv4(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
peer2 := peerR2()
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -925,15 +925,15 @@ func TestProcessBGPUpdate_5_select_low_med_ipv6(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
peer2 := peerR2()
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -1013,15 +1013,15 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv4(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
peer2 := peerR2()
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -1100,15 +1100,15 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv6(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
peer2 := peerR2()
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -1190,15 +1190,15 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv4(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
peer3 := peerR3()
- pList, wList, err = tm.ProcessUpdate(peer3, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer3, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -1277,15 +1277,15 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv6(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
peer3 := peerR3()
- pList, wList, err = tm.ProcessUpdate(peer3, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer3, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -1364,15 +1364,15 @@ func TestProcessBGPUpdate_8_withdraw_path_ipv4(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
peer2 := peerR2()
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -1419,9 +1419,9 @@ func TestProcessBGPUpdate_8_withdraw_path_ipv4(t *testing.T) {
w := []bgp.WithdrawnRoute{w1}
bgpMessage3 := bgp.NewBGPUpdateMessage(w, []bgp.PathAttributeInterface{}, []bgp.NLRInfo{})
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage3)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage3)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
path = pList[0]
@@ -1474,15 +1474,15 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
peer2 := peerR2()
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -1554,9 +1554,9 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
bgpMessage3 := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{},
[]bgp.PathAttributeInterface{mp_unreach}, []bgp.NLRInfo{})
- pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage3)
+ pList, err = tm.ProcessUpdate(peer2, bgpMessage3)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
path = pList[0]
@@ -1599,18 +1599,18 @@ func TestProcessBGPUpdate_bestpath_lost_ipv4(t *testing.T) {
bgpMessage1_w := bgp.NewBGPUpdateMessage(w, []bgp.PathAttributeInterface{}, []bgp.NLRInfo{})
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
- pList, wList, err = tm.ProcessUpdate(peer1, bgpMessage1_w)
- assert.Equal(t, 0, len(pList))
- assert.Equal(t, 1, len(wList))
+ pList, err = tm.ProcessUpdate(peer1, bgpMessage1_w)
+ assert.Equal(t, 1, len(pList))
+ assert.Equal(t, pList[0].IsWithdraw(), true)
assert.NoError(t, err)
// check old best path
- path := wList[0]
+ path := pList[0]
expectedType := "*table.IPv4Path"
assert.Equal(t, reflect.TypeOf(path).String(), expectedType)
@@ -1668,9 +1668,9 @@ func TestProcessBGPUpdate_bestpath_lost_ipv6(t *testing.T) {
bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// path1 mpunreach
@@ -1678,13 +1678,13 @@ func TestProcessBGPUpdate_bestpath_lost_ipv6(t *testing.T) {
bgpMessage1_w := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{},
[]bgp.PathAttributeInterface{mp_unreach}, []bgp.NLRInfo{})
- pList, wList, err = tm.ProcessUpdate(peer1, bgpMessage1_w)
- assert.Equal(t, 0, len(pList))
- assert.Equal(t, 1, len(wList))
+ pList, err = tm.ProcessUpdate(peer1, bgpMessage1_w)
+ assert.Equal(t, 1, len(pList))
+ assert.Equal(t, pList[0].IsWithdraw(), true)
assert.NoError(t, err)
// check old best path
- path := wList[0]
+ path := pList[0]
expectedType := "*table.IPv6Path"
assert.Equal(t, reflect.TypeOf(path).String(), expectedType)
@@ -1758,14 +1758,14 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv4(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
- pList, wList, err = tm.ProcessUpdate(peer1, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer1, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -1845,14 +1845,14 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv6(t *testing.T) {
bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
- pList, wList, err = tm.ProcessUpdate(peer1, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer1, bgpMessage2)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check type
@@ -2013,9 +2013,11 @@ func TestProcessBGPUpdate_multiple_nlri_ipv4(t *testing.T) {
bgpMessage4 := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttributes4, nlri4)
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 5, len(pList))
- assert.Equal(t, 0, len(wList))
+ for _, p := range pList {
+ assert.Equal(t, p.IsWithdraw(), false)
+ }
assert.NoError(t, err)
checkBestPathResult("*table.IPv4Path", "10.10.10.0/24", "192.168.50.1", pList[0], bgpMessage1)
@@ -2024,9 +2026,11 @@ func TestProcessBGPUpdate_multiple_nlri_ipv4(t *testing.T) {
checkBestPathResult("*table.IPv4Path", "40.40.40.0/24", "192.168.50.1", pList[3], bgpMessage1)
checkBestPathResult("*table.IPv4Path", "50.50.50.0/24", "192.168.50.1", pList[4], bgpMessage1)
- pList, wList, err = tm.ProcessUpdate(peer1, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer1, bgpMessage2)
assert.Equal(t, 5, len(pList))
- assert.Equal(t, 0, len(wList))
+ for _, p := range pList {
+ assert.Equal(t, p.IsWithdraw(), false)
+ }
assert.NoError(t, err)
checkBestPathResult("*table.IPv4Path", "11.11.11.0/24", "192.168.50.1", pList[0], bgpMessage2)
@@ -2035,14 +2039,16 @@ func TestProcessBGPUpdate_multiple_nlri_ipv4(t *testing.T) {
checkBestPathResult("*table.IPv4Path", "44.44.44.0/24", "192.168.50.1", pList[3], bgpMessage2)
checkBestPathResult("*table.IPv4Path", "55.55.55.0/24", "192.168.50.1", pList[4], bgpMessage2)
- pList, wList, err = tm.ProcessUpdate(peer1, bgpMessage3)
+ pList, err = tm.ProcessUpdate(peer1, bgpMessage3)
assert.Equal(t, 2, len(pList))
- assert.Equal(t, 0, len(wList))
+ for _, p := range pList {
+ assert.Equal(t, p.IsWithdraw(), false)
+ }
assert.NoError(t, err)
- pList, wList, err = tm.ProcessUpdate(peer1, bgpMessage4)
+ pList, err = tm.ProcessUpdate(peer1, bgpMessage4)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check table
@@ -2154,9 +2160,11 @@ func TestProcessBGPUpdate_multiple_nlri_ipv6(t *testing.T) {
bgpMessage4 := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttributes4, []bgp.NLRInfo{})
peer1 := peerR1()
- pList, wList, err := tm.ProcessUpdate(peer1, bgpMessage1)
+ pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 5, len(pList))
- assert.Equal(t, 0, len(wList))
+ for _, p := range pList {
+ assert.Equal(t, p.IsWithdraw(), false)
+ }
assert.NoError(t, err)
checkBestPathResult("*table.IPv6Path", "2001:123:1210:11::/64", "2001::192:168:50:1", pList[0], bgpMessage1)
@@ -2165,9 +2173,11 @@ func TestProcessBGPUpdate_multiple_nlri_ipv6(t *testing.T) {
checkBestPathResult("*table.IPv6Path", "2001:123:1240:11::/64", "2001::192:168:50:1", pList[3], bgpMessage1)
checkBestPathResult("*table.IPv6Path", "2001:123:1250:11::/64", "2001::192:168:50:1", pList[4], bgpMessage1)
- pList, wList, err = tm.ProcessUpdate(peer1, bgpMessage2)
+ pList, err = tm.ProcessUpdate(peer1, bgpMessage2)
assert.Equal(t, 5, len(pList))
- assert.Equal(t, 0, len(wList))
+ for _, p := range pList {
+ assert.Equal(t, p.IsWithdraw(), false)
+ }
assert.NoError(t, err)
checkBestPathResult("*table.IPv6Path", "2001:123:1211:11::/64", "2001::192:168:50:1", pList[0], bgpMessage2)
@@ -2176,14 +2186,16 @@ func TestProcessBGPUpdate_multiple_nlri_ipv6(t *testing.T) {
checkBestPathResult("*table.IPv6Path", "2001:123:1244:11::/64", "2001::192:168:50:1", pList[3], bgpMessage2)
checkBestPathResult("*table.IPv6Path", "2001:123:1255:11::/64", "2001::192:168:50:1", pList[4], bgpMessage2)
- pList, wList, err = tm.ProcessUpdate(peer1, bgpMessage3)
+ pList, err = tm.ProcessUpdate(peer1, bgpMessage3)
assert.Equal(t, 2, len(pList))
- assert.Equal(t, 0, len(wList))
+ for _, p := range pList {
+ assert.Equal(t, p.IsWithdraw(), false)
+ }
assert.NoError(t, err)
- pList, wList, err = tm.ProcessUpdate(peer1, bgpMessage4)
+ pList, err = tm.ProcessUpdate(peer1, bgpMessage4)
assert.Equal(t, 1, len(pList))
- assert.Equal(t, 0, len(wList))
+ assert.Equal(t, pList[0].IsWithdraw(), false)
assert.NoError(t, err)
// check table