summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-12-17 21:49:32 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-12-17 21:49:32 -0800
commitf8929462982c77f6be2022c9cf42fe05bf3a4b92 (patch)
tree30ecff2ee8c45274c515ba7d38b74db9b6b8cfbe /table
parent52ce66ef711d4f2cd356ec654e57ad6e2732981d (diff)
bmp: fix post-policy bmp message creation
post-policy code creates paths from bgp update and then create the message from the modified paths. MP_UNREACH needs to be handled diffently. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/message.go11
-rw-r--r--table/message_test.go23
2 files changed, 32 insertions, 2 deletions
diff --git a/table/message.go b/table/message.go
index 97ec3b16..ee31f18d 100644
--- a/table/message.go
+++ b/table/message.go
@@ -160,8 +160,15 @@ func createUpdateMsgFromPath(path *Path, msg *bgp.BGPMessage) *bgp.BGPMessage {
} else {
clonedAttrs := cloneAttrSlice(path.GetPathAttrs())
idx, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
- reach := attr.(*bgp.PathAttributeMpReachNLRI)
- clonedAttrs[idx] = bgp.NewPathAttributeMpUnreachNLRI(reach.Value)
+ if attr == nil {
+ // for bmp post-policy
+ idx, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_UNREACH_NLRI)
+ reach := attr.(*bgp.PathAttributeMpUnreachNLRI)
+ clonedAttrs[idx] = bgp.NewPathAttributeMpUnreachNLRI(reach.Value)
+ } else {
+ reach := attr.(*bgp.PathAttributeMpReachNLRI)
+ clonedAttrs[idx] = bgp.NewPathAttributeMpUnreachNLRI(reach.Value)
+ }
return bgp.NewBGPUpdateMessage(nil, clonedAttrs, nil)
}
} else {
diff --git a/table/message_test.go b/table/message_test.go
index 67a1da87..5d1e50a9 100644
--- a/table/message_test.go
+++ b/table/message_test.go
@@ -20,6 +20,7 @@ import (
"github.com/stretchr/testify/assert"
"reflect"
"testing"
+ "time"
)
func updateMsg1(as []uint16) *bgp.BGPMessage {
@@ -99,3 +100,25 @@ func TestAs4PathUnchanged(t *testing.T) {
}
}
}
+
+func TestBMP(t *testing.T) {
+ aspath1 := []bgp.AsPathParamInterface{
+ bgp.NewAs4PathParam(2, []uint32{1000000}),
+ bgp.NewAs4PathParam(1, []uint32{1000001, 1002}),
+ bgp.NewAs4PathParam(2, []uint32{1003, 100004}),
+ }
+ mp_nlri := []bgp.AddrPrefixInterface{bgp.NewIPv6AddrPrefix(100,
+ "fe80:1234:1234:5667:8967:af12:8912:1023")}
+
+ p := []bgp.PathAttributeInterface{
+ bgp.NewPathAttributeOrigin(3),
+ bgp.NewPathAttributeAsPath(aspath1),
+ bgp.NewPathAttributeMpUnreachNLRI(mp_nlri),
+ }
+ w := []*bgp.IPAddrPrefix{}
+ n := []*bgp.IPAddrPrefix{}
+
+ msg := bgp.NewBGPUpdateMessage(w, p, n)
+ pList := ProcessMessage(msg, peerR1(), time.Now())
+ CreateUpdateMsgFromPaths(pList)
+}