summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-05-31 09:49:00 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-05-31 09:49:00 +0900
commit315a553ec1f5931d479f5ca3c14bf660bc4796fb (patch)
treea5bf034bc63760f4e95434f3c6f332037fa03a0a
parent7444507f225dd8b04c287e4c72ec0431a4376ca4 (diff)
table: fix creation of update message from path with multiple NLRIs
Fix a bug that gobgp creates a wrong update message from path having MP_REACH with multiple NLRIs. gobgp always allocates a path per NRLI (that is, multiple paths from an update message having MP_REACH with multiple NLRIs). Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--table/message.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/table/message.go b/table/message.go
index 3d1d7e8d..5cf9b5b6 100644
--- a/table/message.go
+++ b/table/message.go
@@ -238,7 +238,7 @@ func createUpdateMsgFromPath(path *Path, msg *bgp.BGPMessage) *bgp.BGPMessage {
attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_UNREACH_NLRI)
nlris = attr.(*bgp.PathAttributeMpUnreachNLRI).Value
} else {
- nlris = attr.(*bgp.PathAttributeMpReachNLRI).Value
+ nlris = []bgp.AddrPrefixInterface{path.GetNlri()}
}
clonedAttrs := path.GetPathAttrs()
@@ -260,10 +260,20 @@ func createUpdateMsgFromPath(path *Path, msg *bgp.BGPMessage) *bgp.BGPMessage {
}
}
} else {
+ attrs := make([]bgp.PathAttributeInterface, 0, 8)
+
+ for _, p := range path.GetPathAttrs() {
+ if p.GetType() == bgp.BGP_ATTR_TYPE_MP_REACH_NLRI {
+ attrs = append(attrs, bgp.NewPathAttributeMpReachNLRI(path.GetNexthop().String(), []bgp.AddrPrefixInterface{path.GetNlri()}))
+ } else {
+ attrs = append(attrs, p)
+ }
+ }
+
// we don't need to clone here but we
// might merge path to this message in
// the future so let's clone anyway.
- return bgp.NewBGPUpdateMessage(nil, path.GetPathAttrs(), nil)
+ return bgp.NewBGPUpdateMessage(nil, attrs, nil)
}
}
}