summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorWataru Ishida <ishida.wataru@lab.ntt.co.jp>2016-12-09 20:57:19 -0500
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-12-10 06:55:36 -0800
commitcbf72956de08a8dd2bedac077a2f2d78837f44e3 (patch)
tree642a74c1b01d08aca09b5fe2984d322800a16713
parentfff2c32fb4ba2fb324953cb4cc96e515282524d9 (diff)
server: don't assume (*api.Path).Nlri is ipv4 NLRI
use (*api.Path).Family to decide how to decode (*api.Path).Nlri closes #1185 Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
-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}))