summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-09-08 10:57:43 +0900
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-09-08 13:13:34 +0900
commit9298e5eeca78e8bb02ff34b500add622b73b4f5f (patch)
tree857f7646d93ba770527e61edd76dd1838b440249 /table
parent89b904b7417932e78c8c6fea2ad5d8a35891b0a4 (diff)
*: kill bgp.NLRInfo and bgp.WithdrawnRoute
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/destination_test.go22
-rw-r--r--table/message.go15
-rw-r--r--table/message_test.go4
-rw-r--r--table/path.go11
-rw-r--r--table/path_test.go64
-rw-r--r--table/table_manager.go14
-rw-r--r--table/table_manager_test.go256
-rw-r--r--table/table_test.go18
8 files changed, 157 insertions, 247 deletions
diff --git a/table/destination_test.go b/table/destination_test.go
index f46851f9..abf1c652 100644
--- a/table/destination_test.go
+++ b/table/destination_test.go
@@ -51,14 +51,14 @@ func TestDestinationGetRouteFamily(t *testing.T) {
}
func TestDestinationSetNlri(t *testing.T) {
dd := &Destination{}
- nlri := bgp.NewNLRInfo(24, "13.2.3.1")
+ nlri := bgp.NewIPAddrPrefix(24, "13.2.3.1")
dd.setNlri(nlri)
r_nlri := dd.GetNlri()
assert.Equal(t, r_nlri, nlri)
}
func TestDestinationGetNlri(t *testing.T) {
dd := &Destination{}
- nlri := bgp.NewNLRInfo(24, "10.110.123.1")
+ nlri := bgp.NewIPAddrPrefix(24, "10.110.123.1")
dd.setNlri(nlri)
r_nlri := dd.GetNlri()
assert.Equal(t, r_nlri, nlri)
@@ -124,7 +124,7 @@ func DestCreatePath(peerD []*PeerInfo) []*Path {
nlriList := updateMsgD.NLRI
pathAttributes := updateMsgD.PathAttributes
nlri_info := nlriList[0]
- pathD[i] = NewPath(peerD[i], &nlri_info, false, pathAttributes, false, time.Now(), false)
+ pathD[i] = NewPath(peerD[i], nlri_info, false, pathAttributes, false, time.Now(), false)
}
return pathD
}
@@ -144,9 +144,8 @@ func updateMsgD1() *bgp.BGPMessage {
med,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- updateMsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
UpdatePathAttrs4ByteAs(updateMsg.Body.(*bgp.BGPUpdate))
return updateMsg
}
@@ -166,9 +165,8 @@ func updateMsgD2() *bgp.BGPMessage {
med,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "20.20.20.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- updateMsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "20.20.20.0")}
+ updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
UpdatePathAttrs4ByteAs(updateMsg.Body.(*bgp.BGPUpdate))
return updateMsg
}
@@ -186,9 +184,9 @@ func updateMsgD3() *bgp.BGPMessage {
med,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "30.30.30.0")}
- w1 := bgp.WithdrawnRoute{*bgp.NewIPAddrPrefix(23, "40.40.40.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{w1}
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "30.30.30.0")}
+ w1 := bgp.NewIPAddrPrefix(23, "40.40.40.0")
+ withdrawnRoutes := []*bgp.IPAddrPrefix{w1}
updateMsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
UpdatePathAttrs4ByteAs(updateMsg.Body.(*bgp.BGPUpdate))
return updateMsg
diff --git a/table/message.go b/table/message.go
index 0066fc36..3ec0ef62 100644
--- a/table/message.go
+++ b/table/message.go
@@ -132,23 +132,22 @@ func createUpdateMsgFromPath(path *Path, msg *bgp.BGPMessage) *bgp.BGPMessage {
rf := path.GetRouteFamily()
if rf == bgp.RF_IPv4_UC {
+ nlri := path.GetNlri().(*bgp.IPAddrPrefix)
if path.IsWithdraw {
- draw := path.GetNlri().(*bgp.WithdrawnRoute)
if msg != nil {
u := msg.Body.(*bgp.BGPUpdate)
- u.WithdrawnRoutes = append(u.WithdrawnRoutes, *draw)
+ u.WithdrawnRoutes = append(u.WithdrawnRoutes, nlri)
return nil
} else {
- return bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{*draw}, []bgp.PathAttributeInterface{}, []bgp.NLRInfo{})
+ return bgp.NewBGPUpdateMessage([]*bgp.IPAddrPrefix{nlri}, nil, nil)
}
} else {
- nlri := path.GetNlri().(*bgp.NLRInfo)
if msg != nil {
u := msg.Body.(*bgp.BGPUpdate)
- u.NLRI = append(u.NLRI, *nlri)
+ u.NLRI = append(u.NLRI, nlri)
} else {
pathAttrs := path.GetPathAttrs()
- return bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttrs, []bgp.NLRInfo{*nlri})
+ return bgp.NewBGPUpdateMessage(nil, pathAttrs, []*bgp.IPAddrPrefix{nlri})
}
}
} else {
@@ -163,7 +162,7 @@ func createUpdateMsgFromPath(path *Path, msg *bgp.BGPMessage) *bgp.BGPMessage {
idx, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
reach := attr.(*bgp.PathAttributeMpReachNLRI)
clonedAttrs[idx] = bgp.NewPathAttributeMpUnreachNLRI(reach.Value)
- return bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, clonedAttrs, []bgp.NLRInfo{})
+ return bgp.NewBGPUpdateMessage(nil, clonedAttrs, nil)
}
} else {
if msg != nil {
@@ -177,7 +176,7 @@ func createUpdateMsgFromPath(path *Path, msg *bgp.BGPMessage) *bgp.BGPMessage {
// might merge path to this message in
// the future so let's clone anyway.
clonedAttrs := cloneAttrSlice(path.GetPathAttrs())
- return bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, clonedAttrs, []bgp.NLRInfo{})
+ return bgp.NewBGPUpdateMessage(nil, clonedAttrs, nil)
}
}
}
diff --git a/table/message_test.go b/table/message_test.go
index d72fa833..67a1da87 100644
--- a/table/message_test.go
+++ b/table/message_test.go
@@ -36,8 +36,8 @@ func updateMsg1(as []uint16) *bgp.BGPMessage {
med,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- return bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttributes, nlri)
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ return bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
}
func TestAsPathAsTrans(t *testing.T) {
diff --git a/table/path.go b/table/path.go
index eba3340a..386d39c3 100644
--- a/table/path.go
+++ b/table/path.go
@@ -207,21 +207,12 @@ func (path *Path) MarshalJSON() ([]byte, error) {
// create new PathAttributes
func (path *Path) Clone(isWithdraw bool) *Path {
- nlri := path.nlri
- if path.GetRouteFamily() == bgp.RF_IPv4_UC && isWithdraw {
- if path.IsWithdraw {
- nlri = path.nlri
- } else {
- nlri = &bgp.WithdrawnRoute{path.nlri.(*bgp.NLRInfo).IPAddrPrefix}
- }
- }
-
newPathAttrs := make([]bgp.PathAttributeInterface, len(path.pathAttrs))
for i, v := range path.pathAttrs {
newPathAttrs[i] = v
}
- p := NewPath(path.source, nlri, isWithdraw, newPathAttrs, false, path.timestamp, path.NoImplicitWithdraw)
+ p := NewPath(path.source, path.nlri, isWithdraw, newPathAttrs, false, path.timestamp, path.NoImplicitWithdraw)
p.Validation = path.Validation
return p
}
diff --git a/table/path_test.go b/table/path_test.go
index 7fca310f..1f2311f5 100644
--- a/table/path_test.go
+++ b/table/path_test.go
@@ -41,7 +41,7 @@ func TestPathGetSource(t *testing.T) {
}
func TestPathGetNlri(t *testing.T) {
- nlri := bgp.NewNLRInfo(24, "13.2.3.2")
+ nlri := bgp.NewIPAddrPrefix(24, "13.2.3.2")
pd := &Path{
nlri: nlri,
}
@@ -72,7 +72,7 @@ func TestPathCreatePath(t *testing.T) {
nlriList := updateMsgP.NLRI
pathAttributes := updateMsgP.PathAttributes
nlri_info := nlriList[0]
- path := NewPath(peerP[0], &nlri_info, false, pathAttributes, false, time.Now(), false)
+ path := NewPath(peerP[0], nlri_info, false, pathAttributes, false, time.Now(), false)
assert.NotNil(t, path)
}
@@ -112,13 +112,12 @@ func TestASPathLen(t *testing.T) {
med,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- bgpmsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpmsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
update := bgpmsg.Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(update)
peer := PathCreatePeer()
- p := NewPath(peer[0], &update.NLRI[0], false, update.PathAttributes, false, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, false, time.Now(), false)
assert.Equal(10, p.GetAsPathLen())
}
@@ -139,13 +138,12 @@ func TestPathPrependAsnToExistingSeqAttr(t *testing.T) {
nexthop,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- bgpmsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpmsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
update := bgpmsg.Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(update)
peer := PathCreatePeer()
- p := NewPath(peer[0], &update.NLRI[0], false, update.PathAttributes, false, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, false, time.Now(), false)
p.PrependAsn(65000, 1)
assert.Equal([]uint32{65000, 65001, 65002, 65003, 65004, 65005}, p.GetAsSeqList())
@@ -162,13 +160,12 @@ func TestPathPrependAsnToNewAsPathAttr(t *testing.T) {
nexthop,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- bgpmsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpmsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
update := bgpmsg.Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(update)
peer := PathCreatePeer()
- p := NewPath(peer[0], &update.NLRI[0], false, update.PathAttributes, false, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, false, time.Now(), false)
asn := uint32(65000)
p.PrependAsn(asn, 1)
@@ -191,13 +188,12 @@ func TestPathPrependAsnToNewAsPathSeq(t *testing.T) {
nexthop,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- bgpmsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpmsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
update := bgpmsg.Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(update)
peer := PathCreatePeer()
- p := NewPath(peer[0], &update.NLRI[0], false, update.PathAttributes, false, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, false, time.Now(), false)
asn := uint32(65000)
p.PrependAsn(asn, 1)
@@ -222,13 +218,12 @@ func TestPathPrependAsnToEmptyAsPathAttr(t *testing.T) {
nexthop,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- bgpmsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpmsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
update := bgpmsg.Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(update)
peer := PathCreatePeer()
- p := NewPath(peer[0], &update.NLRI[0], false, update.PathAttributes, false, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, false, time.Now(), false)
asn := uint32(65000)
p.PrependAsn(asn, 1)
@@ -259,13 +254,12 @@ func TestPathPrependAsnToFullPathAttr(t *testing.T) {
nexthop,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- bgpmsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ bgpmsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
update := bgpmsg.Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(update)
peer := PathCreatePeer()
- p := NewPath(peer[0], &update.NLRI[0], false, update.PathAttributes, false, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, false, time.Now(), false)
expected := []uint32{65000, 65000}
for _, v := range asns {
@@ -294,7 +288,7 @@ func PathCreatePath(peerP []*PeerInfo) []*Path {
nlriList := updateMsgP.NLRI
pathAttributes := updateMsgP.PathAttributes
nlri_info := nlriList[0]
- pathP[i] = NewPath(peerP[i], &nlri_info, false, pathAttributes, false, time.Now(), false)
+ pathP[i] = NewPath(peerP[i], nlri_info, false, pathAttributes, false, time.Now(), false)
}
return pathP
}
@@ -314,9 +308,8 @@ func updateMsgP1() *bgp.BGPMessage {
med,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- return bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ return bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
}
func updateMsgP2() *bgp.BGPMessage {
@@ -334,9 +327,8 @@ func updateMsgP2() *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 updateMsgP3() *bgp.BGPMessage {
origin := bgp.NewPathAttributeOrigin(0)
@@ -352,8 +344,8 @@ func updateMsgP3() *bgp.BGPMessage {
med,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "30.30.30.0")}
- w1 := bgp.WithdrawnRoute{*bgp.NewIPAddrPrefix(23, "40.40.40.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{w1}
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "30.30.30.0")}
+ w1 := bgp.NewIPAddrPrefix(23, "40.40.40.0")
+ withdrawnRoutes := []*bgp.IPAddrPrefix{w1}
return bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
}
diff --git a/table/table_manager.go b/table/table_manager.go
index 75b68b03..4477182b 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -29,11 +29,8 @@ func nlri2Path(m *bgp.BGPMessage, p *PeerInfo, now time.Time) []*Path {
updateMsg := m.Body.(*bgp.BGPUpdate)
pathAttributes := updateMsg.PathAttributes
pathList := make([]*Path, 0)
- for _, nlri_info := range updateMsg.NLRI {
- // define local variable to pass nlri's address to CreatePath
- var nlri bgp.NLRInfo = nlri_info
- // create Path object
- path := NewPath(p, &nlri, false, pathAttributes, false, now, false)
+ for _, nlri := range updateMsg.NLRI {
+ path := NewPath(p, nlri, false, pathAttributes, false, now, false)
pathList = append(pathList, path)
}
return pathList
@@ -43,11 +40,8 @@ func withdraw2Path(m *bgp.BGPMessage, p *PeerInfo, now time.Time) []*Path {
updateMsg := m.Body.(*bgp.BGPUpdate)
pathAttributes := updateMsg.PathAttributes
pathList := make([]*Path, 0)
- for _, nlriWithdraw := range updateMsg.WithdrawnRoutes {
- // define local variable to pass nlri's address to CreatePath
- var w bgp.WithdrawnRoute = nlriWithdraw
- // create withdrawn Path object
- path := NewPath(p, &w, true, pathAttributes, false, now, false)
+ for _, nlri := range updateMsg.WithdrawnRoutes {
+ path := NewPath(p, nlri, true, pathAttributes, false, now, false)
pathList = append(pathList, path)
}
return pathList
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)
}
diff --git a/table/table_test.go b/table/table_test.go
index 0ece7568..f957cef1 100644
--- a/table/table_test.go
+++ b/table/table_test.go
@@ -107,7 +107,7 @@ func TableCreatePath(peerT []*PeerInfo) []*Path {
nlriList := updateMsgT.NLRI
pathAttributes := updateMsgT.PathAttributes
nlri_info := nlriList[0]
- pathT[i] = NewPath(peerT[i], &nlri_info, false, pathAttributes, false, time.Now(), false)
+ pathT[i] = NewPath(peerT[i], nlri_info, false, pathAttributes, false, time.Now(), false)
}
return pathT
}
@@ -127,9 +127,8 @@ func updateMsgT1() *bgp.BGPMessage {
med,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{}
- return bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.10.0")}
+ return bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
}
func updateMsgT2() *bgp.BGPMessage {
@@ -147,9 +146,8 @@ func updateMsgT2() *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 updateMsgT3() *bgp.BGPMessage {
origin := bgp.NewPathAttributeOrigin(0)
@@ -165,8 +163,8 @@ func updateMsgT3() *bgp.BGPMessage {
med,
}
- nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "30.30.30.0")}
- w1 := bgp.WithdrawnRoute{*bgp.NewIPAddrPrefix(23, "40.40.40.0")}
- withdrawnRoutes := []bgp.WithdrawnRoute{w1}
+ nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "30.30.30.0")}
+ w1 := bgp.NewIPAddrPrefix(23, "40.40.40.0")
+ withdrawnRoutes := []*bgp.IPAddrPrefix{w1}
return bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri)
}