mirror of
https://github.com/osrg/gobgp.git
synced 2024-05-11 05:55:10 +00:00
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 <[email protected]>
This commit is contained in:
+16
-1
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user