summaryrefslogtreecommitdiffhomepage
path: root/table/table_manager_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'table/table_manager_test.go')
-rw-r--r--table/table_manager_test.go256
1 files changed, 97 insertions, 159 deletions
diff --git a/table/table_manager_test.go b/table/table_manager_test.go
index 08791867..404ab553 100644
--- a/table/table_manager_test.go
+++ b/table/table_manager_test.go
@@ -183,9 +183,8 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv4(t *testing.T) {
pathAttributes1 := []bgp.PathAttributeInterface{
origin1, aspath1, nexthop1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ nlri1 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nlri1)
// high localpref message
origin2 := bgp.NewPathAttributeOrigin(0)
@@ -197,9 +196,8 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv4(t *testing.T) {
pathAttributes2 := []bgp.PathAttributeInterface{
origin2, aspath2, nexthop2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ nlri2 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nlri2)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -267,9 +265,7 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv6(t *testing.T) {
mp_reach1, origin1, aspath1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nil)
origin2 := bgp.NewPathAttributeOrigin(0)
aspath2 := createAsPathAttribute([]uint32{65100, 65000})
@@ -282,9 +278,7 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv6(t *testing.T) {
mp_reach2, origin2, aspath2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nil)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -353,9 +347,8 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv4(t *testing.T) {
pathAttributes1 := []bgp.PathAttributeInterface{
origin1, aspath1, nexthop1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ nlri1 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nlri1)
// high localpref message
origin2 := bgp.NewPathAttributeOrigin(0)
@@ -367,9 +360,8 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv4(t *testing.T) {
pathAttributes2 := []bgp.PathAttributeInterface{
origin2, aspath2, nexthop2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ nlri2 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nlri2)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -439,9 +431,7 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv6(t *testing.T) {
mp_reach1, origin1, aspath1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nil)
origin2 := bgp.NewPathAttributeOrigin(0)
aspath2 := createAsPathAttribute([]uint32{})
@@ -454,9 +444,7 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv6(t *testing.T) {
mp_reach2, origin2, aspath2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nil)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -642,9 +630,8 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv4(t *testing.T) {
pathAttributes1 := []bgp.PathAttributeInterface{
origin1, aspath1, nexthop1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ nlri1 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nlri1)
// high origin message
origin2 := bgp.NewPathAttributeOrigin(0)
@@ -656,9 +643,8 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv4(t *testing.T) {
pathAttributes2 := []bgp.PathAttributeInterface{
origin2, aspath2, nexthop2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ nlri2 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nlri2)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -726,9 +712,7 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv6(t *testing.T) {
mp_reach1, origin1, aspath1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nil)
origin2 := bgp.NewPathAttributeOrigin(0)
aspath2 := createAsPathAttribute([]uint32{65100, 65000})
@@ -741,9 +725,7 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv6(t *testing.T) {
mp_reach2, origin2, aspath2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nil)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -812,9 +794,8 @@ func TestProcessBGPUpdate_5_select_low_med_ipv4(t *testing.T) {
pathAttributes1 := []bgp.PathAttributeInterface{
origin1, aspath1, nexthop1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ nlri1 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nlri1)
// high origin message
origin2 := bgp.NewPathAttributeOrigin(0)
@@ -826,9 +807,8 @@ func TestProcessBGPUpdate_5_select_low_med_ipv4(t *testing.T) {
pathAttributes2 := []bgp.PathAttributeInterface{
origin2, aspath2, nexthop2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ nlri2 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nlri2)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -896,9 +876,7 @@ func TestProcessBGPUpdate_5_select_low_med_ipv6(t *testing.T) {
mp_reach1, origin1, aspath1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nil)
origin2 := bgp.NewPathAttributeOrigin(0)
aspath2 := createAsPathAttribute([]uint32{65100, 65000})
@@ -911,9 +889,7 @@ func TestProcessBGPUpdate_5_select_low_med_ipv6(t *testing.T) {
mp_reach2, origin2, aspath2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nil)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -983,9 +959,8 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv4(t *testing.T) {
pathAttributes1 := []bgp.PathAttributeInterface{
origin1, aspath1, nexthop1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ nlri1 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nlri1)
// high origin message
origin2 := bgp.NewPathAttributeOrigin(0)
@@ -997,9 +972,8 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv4(t *testing.T) {
pathAttributes2 := []bgp.PathAttributeInterface{
origin2, aspath2, nexthop2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ nlri2 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nlri2)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -1067,9 +1041,7 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv6(t *testing.T) {
mp_reach1, origin1, aspath1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nil)
origin2 := bgp.NewPathAttributeOrigin(0)
aspath2 := createAsPathAttribute([]uint32{65100, 65200})
@@ -1082,9 +1054,7 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv6(t *testing.T) {
mp_reach2, origin2, aspath2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nil)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -1156,9 +1126,8 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv4(t *testing.T) {
pathAttributes1 := []bgp.PathAttributeInterface{
origin1, aspath1, nexthop1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ nlri1 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nlri1)
// high origin message
origin2 := bgp.NewPathAttributeOrigin(0)
@@ -1170,9 +1139,8 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv4(t *testing.T) {
pathAttributes2 := []bgp.PathAttributeInterface{
origin2, aspath2, nexthop2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ nlri2 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nlri2)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -1240,9 +1208,7 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv6(t *testing.T) {
mp_reach1, origin1, aspath1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nil)
origin2 := bgp.NewPathAttributeOrigin(0)
aspath2 := createAsPathAttribute([]uint32{65100, 65200})
@@ -1255,9 +1221,7 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv6(t *testing.T) {
mp_reach2, origin2, aspath2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nil)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -1327,9 +1291,8 @@ func TestProcessBGPUpdate_8_withdraw_path_ipv4(t *testing.T) {
pathAttributes1 := []bgp.PathAttributeInterface{
origin1, aspath1, nexthop1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ nlri1 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nlri1)
// path 2
origin2 := bgp.NewPathAttributeOrigin(0)
@@ -1341,9 +1304,8 @@ func TestProcessBGPUpdate_8_withdraw_path_ipv4(t *testing.T) {
pathAttributes2 := []bgp.PathAttributeInterface{
origin2, aspath2, nexthop2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ nlri2 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nlri2)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -1396,9 +1358,9 @@ func TestProcessBGPUpdate_8_withdraw_path_ipv4(t *testing.T) {
assert.Equal(t, expectedNexthop, path.GetNexthop().String())
//withdraw path
- w1 := bgp.WithdrawnRoute{*bgp.NewIPAddrPrefix(24, "10.10.10.0")}
- w := []bgp.WithdrawnRoute{w1}
- bgpMessage3 := bgp.NewBGPUpdateMessage(w, []bgp.PathAttributeInterface{}, []bgp.NLRInfo{})
+ w1 := bgp.NewIPAddrPrefix(24, "10.10.10.0")
+ w := []*bgp.IPAddrPrefix{w1}
+ bgpMessage3 := bgp.NewBGPUpdateMessage(w, nil, nil)
pList, err = tm.ProcessUpdate(peer2, bgpMessage3)
assert.Equal(t, 1, len(pList))
@@ -1434,9 +1396,7 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
mp_reach1, origin1, aspath1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nil)
origin2 := bgp.NewPathAttributeOrigin(0)
aspath2 := createAsPathAttribute([]uint32{65100, 65000})
@@ -1449,9 +1409,7 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
mp_reach2, origin2, aspath2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nil)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -1530,8 +1488,7 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
//mpunreach path
mp_unreach := createMpUNReach("2001:123:123:1::", 64)
- bgpMessage3 := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{},
- []bgp.PathAttributeInterface{mp_unreach}, []bgp.NLRInfo{})
+ bgpMessage3 := bgp.NewBGPUpdateMessage(nil, []bgp.PathAttributeInterface{mp_unreach}, nil)
pList, err = tm.ProcessUpdate(peer2, bgpMessage3)
assert.Equal(t, 1, len(pList))
@@ -1568,13 +1525,13 @@ func TestProcessBGPUpdate_bestpath_lost_ipv4(t *testing.T) {
pathAttributes1 := []bgp.PathAttributeInterface{
origin1, aspath1, nexthop1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- bgpMessage1 := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttributes1, nlri1)
+ nlri1 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nlri1)
// path 1 withdraw
- w1 := bgp.WithdrawnRoute{*bgp.NewIPAddrPrefix(24, "10.10.10.0")}
- w := []bgp.WithdrawnRoute{w1}
- bgpMessage1_w := bgp.NewBGPUpdateMessage(w, []bgp.PathAttributeInterface{}, []bgp.NLRInfo{})
+ w1 := bgp.NewIPAddrPrefix(24, "10.10.10.0")
+ w := []*bgp.IPAddrPrefix{w1}
+ bgpMessage1_w := bgp.NewBGPUpdateMessage(w, nil, nil)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -1640,9 +1597,7 @@ func TestProcessBGPUpdate_bestpath_lost_ipv6(t *testing.T) {
mp_reach1, origin1, aspath1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nil)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -1652,8 +1607,7 @@ func TestProcessBGPUpdate_bestpath_lost_ipv6(t *testing.T) {
// path1 mpunreach
mp_unreach := createMpUNReach("2001:123:123:1::", 64)
- bgpMessage1_w := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{},
- []bgp.PathAttributeInterface{mp_unreach}, []bgp.NLRInfo{})
+ bgpMessage1_w := bgp.NewBGPUpdateMessage(nil, []bgp.PathAttributeInterface{mp_unreach}, nil)
pList, err = tm.ProcessUpdate(peer1, bgpMessage1_w)
assert.Equal(t, 1, len(pList))
@@ -1715,9 +1669,8 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv4(t *testing.T) {
pathAttributes1 := []bgp.PathAttributeInterface{
origin1, aspath1, nexthop1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ nlri1 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nlri1)
// path 1 from same peer but short AS_PATH
origin2 := bgp.NewPathAttributeOrigin(0)
@@ -1729,9 +1682,8 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv4(t *testing.T) {
pathAttributes2 := []bgp.PathAttributeInterface{
origin2, aspath2, nexthop2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ nlri2 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nlri2)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -1800,9 +1752,7 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv6(t *testing.T) {
mp_reach1, origin1, aspath1, med1, localpref1,
}
- nlri1 := []bgp.NLRInfo{}
- withdrawnRoutes1 := []bgp.WithdrawnRoute{}
- bgpMessage1 := bgp.NewBGPUpdateMessage(withdrawnRoutes1, pathAttributes1, nlri1)
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nil)
origin2 := bgp.NewPathAttributeOrigin(0)
aspath2 := createAsPathAttribute([]uint32{65000, 65100})
@@ -1815,9 +1765,7 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv6(t *testing.T) {
mp_reach2, origin2, aspath2, med2, localpref2,
}
- nlri2 := []bgp.NLRInfo{}
- withdrawnRoutes2 := []bgp.WithdrawnRoute{}
- bgpMessage2 := bgp.NewBGPUpdateMessage(withdrawnRoutes2, pathAttributes2, nlri2)
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nil)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -1952,38 +1900,38 @@ func TestProcessBGPUpdate_multiple_nlri_ipv4(t *testing.T) {
// path1
pathAttributes1 := createPathAttr([]uint32{65000, 65100, 65200}, "192.168.50.1")
- nlri1 := []bgp.NLRInfo{
- *bgp.NewNLRInfo(24, "10.10.10.0"),
- *bgp.NewNLRInfo(24, "20.20.20.0"),
- *bgp.NewNLRInfo(24, "30.30.30.0"),
- *bgp.NewNLRInfo(24, "40.40.40.0"),
- *bgp.NewNLRInfo(24, "50.50.50.0")}
- bgpMessage1 := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttributes1, nlri1)
+ nlri1 := []*bgp.IPAddrPrefix{
+ bgp.NewIPAddrPrefix(24, "10.10.10.0"),
+ bgp.NewIPAddrPrefix(24, "20.20.20.0"),
+ bgp.NewIPAddrPrefix(24, "30.30.30.0"),
+ bgp.NewIPAddrPrefix(24, "40.40.40.0"),
+ bgp.NewIPAddrPrefix(24, "50.50.50.0")}
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nlri1)
// path2
pathAttributes2 := createPathAttr([]uint32{65000, 65100, 65300}, "192.168.50.1")
- nlri2 := []bgp.NLRInfo{
- *bgp.NewNLRInfo(24, "11.11.11.0"),
- *bgp.NewNLRInfo(24, "22.22.22.0"),
- *bgp.NewNLRInfo(24, "33.33.33.0"),
- *bgp.NewNLRInfo(24, "44.44.44.0"),
- *bgp.NewNLRInfo(24, "55.55.55.0")}
- bgpMessage2 := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttributes2, nlri2)
+ nlri2 := []*bgp.IPAddrPrefix{
+ bgp.NewIPAddrPrefix(24, "11.11.11.0"),
+ bgp.NewIPAddrPrefix(24, "22.22.22.0"),
+ bgp.NewIPAddrPrefix(24, "33.33.33.0"),
+ bgp.NewIPAddrPrefix(24, "44.44.44.0"),
+ bgp.NewIPAddrPrefix(24, "55.55.55.0")}
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nlri2)
// path3
pathAttributes3 := createPathAttr([]uint32{65000, 65100, 65400}, "192.168.50.1")
- nlri3 := []bgp.NLRInfo{
- *bgp.NewNLRInfo(24, "77.77.77.0"),
- *bgp.NewNLRInfo(24, "88.88.88.0"),
+ nlri3 := []*bgp.IPAddrPrefix{
+ bgp.NewIPAddrPrefix(24, "77.77.77.0"),
+ bgp.NewIPAddrPrefix(24, "88.88.88.0"),
}
- bgpMessage3 := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttributes3, nlri3)
+ bgpMessage3 := bgp.NewBGPUpdateMessage(nil, pathAttributes3, nlri3)
// path4
pathAttributes4 := createPathAttr([]uint32{65000, 65100, 65500}, "192.168.50.1")
- nlri4 := []bgp.NLRInfo{
- *bgp.NewNLRInfo(24, "99.99.99.0"),
+ nlri4 := []*bgp.IPAddrPrefix{
+ bgp.NewIPAddrPrefix(24, "99.99.99.0"),
}
- bgpMessage4 := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttributes4, nlri4)
+ bgpMessage4 := bgp.NewBGPUpdateMessage(nil, pathAttributes4, nlri4)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -2100,7 +2048,7 @@ func TestProcessBGPUpdate_multiple_nlri_ipv6(t *testing.T) {
bgp.NewIPv6AddrPrefix(64, "2001:123:1250:11::"),
})
pathAttributes1 = append(pathAttributes1, mpreach1)
- bgpMessage1 := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttributes1, []bgp.NLRInfo{})
+ bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nil)
// path2
pathAttributes2 := createPathAttr([]uint32{65000, 65100, 65300})
@@ -2112,7 +2060,7 @@ func TestProcessBGPUpdate_multiple_nlri_ipv6(t *testing.T) {
bgp.NewIPv6AddrPrefix(64, "2001:123:1255:11::"),
})
pathAttributes2 = append(pathAttributes2, mpreach2)
- bgpMessage2 := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttributes2, []bgp.NLRInfo{})
+ bgpMessage2 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nil)
// path3
pathAttributes3 := createPathAttr([]uint32{65000, 65100, 65400})
@@ -2121,7 +2069,7 @@ func TestProcessBGPUpdate_multiple_nlri_ipv6(t *testing.T) {
bgp.NewIPv6AddrPrefix(64, "2001:123:1288:11::"),
})
pathAttributes3 = append(pathAttributes3, mpreach3)
- bgpMessage3 := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttributes3, []bgp.NLRInfo{})
+ bgpMessage3 := bgp.NewBGPUpdateMessage(nil, pathAttributes3, nil)
// path4
pathAttributes4 := createPathAttr([]uint32{65000, 65100, 65500})
@@ -2129,7 +2077,7 @@ func TestProcessBGPUpdate_multiple_nlri_ipv6(t *testing.T) {
bgp.NewIPv6AddrPrefix(64, "2001:123:1299:11::"),
})
pathAttributes4 = append(pathAttributes4, mpreach4)
- bgpMessage4 := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttributes4, []bgp.NLRInfo{})
+ bgpMessage4 := bgp.NewBGPUpdateMessage(nil, pathAttributes4, nil)
peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
@@ -2190,18 +2138,17 @@ func TestProcessBGPUpdate_Timestamp(t *testing.T) {
med,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
adjRib := NewAdjRib([]bgp.RouteFamily{bgp.RF_IPv4_UC, bgp.RF_IPv6_UC})
- m1 := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ m1 := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
peer := peerR1()
pList1 := ProcessMessage(m1, peer)
path1 := pList1[0]
t1 := path1.timestamp
adjRib.UpdateIn(pList1)
- m2 := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ m2 := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
pList2 := ProcessMessage(m2, peer)
//path2 := pList2[0].(*IPv4Path)
//t2 = path2.timestamp
@@ -2219,7 +2166,7 @@ func TestProcessBGPUpdate_Timestamp(t *testing.T) {
med2,
}
- m3 := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes2, nlri)
+ m3 := bgp.NewBGPUpdateMessage(nil, pathAttributes2, nlri)
pList3 := ProcessMessage(m3, peer)
t3 := pList3[0].GetTimestamp()
adjRib.UpdateIn(pList3)
@@ -2244,10 +2191,9 @@ func update_fromR1() *bgp.BGPMessage {
med,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
- return bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ return bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
}
func update_fromR1_ipv6() *bgp.BGPMessage {
@@ -2266,9 +2212,7 @@ func update_fromR1_ipv6() *bgp.BGPMessage {
aspath,
med,
}
- nlri := []bgp.NLRInfo{}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- return bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ return bgp.NewBGPUpdateMessage(nil, pathAttributes, nil)
}
func update_fromR2() *bgp.BGPMessage {
@@ -2286,9 +2230,8 @@ func update_fromR2() *bgp.BGPMessage {
med,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "20.20.20.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- return bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "20.20.20.0")}
+ return bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
}
func update_fromR2_ipv6() *bgp.BGPMessage {
@@ -2305,9 +2248,7 @@ func update_fromR2_ipv6() *bgp.BGPMessage {
aspath,
med,
}
- nlri := []bgp.NLRInfo{}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- return bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ return bgp.NewBGPUpdateMessage(nil, pathAttributes, nil)
}
func createAsPathAttribute(ases []uint32) *bgp.PathAttributeAsPath {
@@ -2340,9 +2281,8 @@ func update_fromR2viaR1() *bgp.BGPMessage {
nexthop,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "20.20.20.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- return bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "20.20.20.0")}
+ return bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
}
func update_fromR2viaR1_ipv6() *bgp.BGPMessage {
@@ -2359,8 +2299,6 @@ func update_fromR2viaR1_ipv6() *bgp.BGPMessage {
aspath,
med,
}
- nlri := []bgp.NLRInfo{}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- return bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ return bgp.NewBGPUpdateMessage(nil, pathAttributes, nil)
}