diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-05-09 16:22:40 +0900 |
---|---|---|
committer | fujita <fujita@fujita-no-MacBook.local> | 2017-05-15 15:14:24 +0900 |
commit | c28f127f5fad42d252e5775ef7d7968e7c2b75c7 (patch) | |
tree | b9b77219dffb910c3ba89d8a382d2586c60e6388 | |
parent | 4215941eec35635f59c068de968523913df2a087 (diff) |
bgp: Advertise IPv4 routes with IPv6 Next Hop
RFC5549 allows IPv6 Next Hop address for the advertisement of IPv4
related NLRIs for <AFI/SAFI> of <1/1>, <1/2>, <1/4> and <1/128>.
Currently, the advertisement using the MP_REACH_NLRI is supported,
but IPv4 routes with IPv6 Next Hop is not enough.
This patch enable to advertise IPv4 routes for <AFI/SAFI> of <1/1>
through GoBGP CLI command.
e.g.)
$ gobgp global rib add -a ipv4 10.2.1.0/24 nexthop 2001:2::1
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
-rw-r--r-- | api/grpc_server.go | 2 | ||||
-rw-r--r-- | gobgp/cmd/global.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/api/grpc_server.go b/api/grpc_server.go index f9bdaf6a..a6306580 100644 --- a/api/grpc_server.go +++ b/api/grpc_server.go @@ -573,7 +573,7 @@ func (s *Server) api2PathList(resource Resource, ApiPathList []*Path) ([]*table. return nil, fmt.Errorf("not found nlri or nexthop") } - if resource != Resource_VRF && bgp.RouteFamily(path.Family) == bgp.RF_IPv4_UC { + if resource != Resource_VRF && bgp.RouteFamily(path.Family) == bgp.RF_IPv4_UC && net.ParseIP(nexthop).To4() != nil { pattr = append(pattr, bgp.NewPathAttributeNextHop(nexthop)) } else { pattr = append(pattr, bgp.NewPathAttributeMpReachNLRI(nexthop, []bgp.AddrPrefixInterface{nlri})) diff --git a/gobgp/cmd/global.go b/gobgp/cmd/global.go index 0c771080..c7d07db1 100644 --- a/gobgp/cmd/global.go +++ b/gobgp/cmd/global.go @@ -797,7 +797,7 @@ func ParsePath(rf bgp.RouteFamily, args []string) (*table.Path, error) { return nil, err } - if rf == bgp.RF_IPv4_UC { + if rf == bgp.RF_IPv4_UC && net.ParseIP(nexthop).To4() != nil { attrs = append(attrs, bgp.NewPathAttributeNextHop(nexthop)) } else { mpreach := bgp.NewPathAttributeMpReachNLRI(nexthop, []bgp.AddrPrefixInterface{nlri}) |