summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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)
+}