summaryrefslogtreecommitdiffhomepage
path: root/api/grpc_server.go
diff options
context:
space:
mode:
Diffstat (limited to 'api/grpc_server.go')
-rw-r--r--api/grpc_server.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/api/grpc_server.go b/api/grpc_server.go
index 264279be..5c83ca8c 100644
--- a/api/grpc_server.go
+++ b/api/grpc_server.go
@@ -483,6 +483,7 @@ func (s *Server) api2PathList(resource Resource, ApiPathList []*Path) ([]*table.
var nlri bgp.AddrPrefixInterface
var nexthop string
var pi *table.PeerInfo
+ var err error
pathList := make([]*table.Path, 0, len(ApiPathList))
for _, path := range ApiPathList {
@@ -499,7 +500,10 @@ func (s *Server) api2PathList(resource Resource, ApiPathList []*Path) ([]*table.
}
if len(path.Nlri) > 0 {
- nlri = &bgp.IPAddrPrefix{}
+ afi, safi := bgp.RouteFamilyToAfiSafi(bgp.RouteFamily(path.Family))
+ if nlri, err = bgp.NewPrefixFromRouteFamily(afi, safi); err != nil {
+ return nil, err
+ }
err := nlri.DecodeFromBytes(path.Nlri)
if err != nil {
return nil, err
@@ -546,9 +550,7 @@ func (s *Server) api2PathList(resource Resource, ApiPathList []*Path) ([]*table.
return nil, fmt.Errorf("not found nlri or nexthop")
}
- rf := bgp.AfiSafiToRouteFamily(nlri.AFI(), nlri.SAFI())
-
- if resource != Resource_VRF && rf == bgp.RF_IPv4_UC {
+ if resource != Resource_VRF && bgp.RouteFamily(path.Family) == bgp.RF_IPv4_UC {
pattr = append(pattr, bgp.NewPathAttributeNextHop(nexthop))
} else {
pattr = append(pattr, bgp.NewPathAttributeMpReachNLRI(nexthop, []bgp.AddrPrefixInterface{nlri}))