summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-01-13 12:38:01 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-01-13 12:38:01 +0900
commitc6b44ccd8a73bd0caf715bbabe7e7a8fd0685f39 (patch)
tree44b9bb2aeb83f0506742580ae24b66acd932f232
parentc75aec72eca9f213e5d7d90386fedb16ae8f5718 (diff)
cli: fix mrt to drop MP_REACH attribute when injecting
The GoBGP API gives an error with a path having multiple nlris MP_REACH attribute. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--gobgp/cmd/mrt.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/gobgp/cmd/mrt.go b/gobgp/cmd/mrt.go
index b64adb6b..a1723841 100644
--- a/gobgp/cmd/mrt.go
+++ b/gobgp/cmd/mrt.go
@@ -22,6 +22,7 @@ import (
"strconv"
"time"
+ "github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/packet/mrt"
"github.com/osrg/gobgp/table"
"github.com/spf13/cobra"
@@ -116,7 +117,21 @@ func injectMrt() error {
ID: peers[e.PeerIndex].BgpId,
}
t := time.Unix(int64(e.OriginatedTime), 0)
- paths = append(paths, table.NewPath(source, nlri, false, e.PathAttributes, t, false))
+
+ if subType != mrt.RIB_IPV4_UNICAST || subType != mrt.RIB_IPV4_UNICAST_ADDPATH {
+ attrs := make([]bgp.PathAttributeInterface, 0, len(e.PathAttributes))
+ for _, attr := range e.PathAttributes {
+ if attr.GetType() != bgp.BGP_ATTR_TYPE_MP_REACH_NLRI {
+ attrs = append(attrs, attr)
+ } else {
+ a := attr.(*bgp.PathAttributeMpReachNLRI)
+ attrs = append(attrs, bgp.NewPathAttributeMpReachNLRI(a.Nexthop.String(), []bgp.AddrPrefixInterface{nlri}))
+ }
+ }
+ paths = append(paths, table.NewPath(source, nlri, false, attrs, t, false))
+ } else {
+ paths = append(paths, table.NewPath(source, nlri, false, e.PathAttributes, t, false))
+ }
}
if mrtOpts.NextHop != nil {
for _, p := range paths {