diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2017-08-21 02:19:25 +0200 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2017-08-24 01:25:40 +0200 |
commit | 9913029c5c2a4e2d3d78d470aa9b91fdeb0fb007 (patch) | |
tree | 2f3f6291316a4a16a7e7c9bd9209886e9b936183 /bgpd/rfapi/vnc_zebra.c | |
parent | ospf6d: use the new API to send routes to zebra (diff) | |
download | frr-9913029c5c2a4e2d3d78d470aa9b91fdeb0fb007.tar.xz frr-9913029c5c2a4e2d3d78d470aa9b91fdeb0fb007.zip |
bgpd: use the new API to send routes to zebra
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to '')
-rw-r--r-- | bgpd/rfapi/vnc_zebra.c | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c index 29652e59d..1b1a89b35 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -501,21 +501,27 @@ static void vnc_zebra_route_msg(struct prefix *p, int nhp_count, void *nhp_ary, } if (p->family == AF_INET) { + struct zapi_route api; + struct zapi_nexthop *api_nh; + struct in_addr *nhp_ary4 = nhp_ary; + int i; - struct zapi_ipv4 api; - - api.flags = 0; + memset(&api, 0, sizeof(api)); api.vrf_id = VRF_DEFAULT; api.type = ZEBRA_ROUTE_VNC; - api.message = 0; - SET_FLAG(api.message, - ZAPI_MESSAGE_NEXTHOP); /* TBD what's it mean? */ - api.nexthop_num = nhp_count; - api.nexthop = nhp_ary; - api.ifindex_num = 0; - api.instance = 0; + api.prefix = *p; api.safi = SAFI_UNICAST; + /* Nexthops */ + SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); + api.nexthop_num = nhp_count; + for (i = 0; i < nhp_count; i++) { + api_nh = &api.nexthops[i]; + memcpy(&api_nh->gate.ipv4, &nhp_ary4[i], + sizeof(api_nh->gate.ipv4)); + api_nh->type = NEXTHOP_TYPE_IPV4; + } + if (BGP_DEBUG(zebra, ZEBRA)) { char buf[INET_ADDRSTRLEN]; @@ -527,29 +533,31 @@ static void vnc_zebra_route_msg(struct prefix *p, int nhp_count, void *nhp_ary, p->prefixlen, nhp_count); } - zapi_ipv4_route((add ? ZEBRA_IPV4_ROUTE_ADD - : ZEBRA_IPV4_ROUTE_DELETE), - zclient_vnc, (struct prefix_ipv4 *)p, &api); + zclient_route_send((add ? ZEBRA_ROUTE_ADD : ZEBRA_ROUTE_DELETE), + zclient_vnc, &api); } else if (p->family == AF_INET6) { + struct zapi_route api; + struct zapi_nexthop *api_nh; + struct in6_addr *nhp_ary6 = nhp_ary; + int i; - struct zapi_ipv6 api; - ifindex_t ifindex = 0; - - /* Make Zebra API structure. */ - api.flags = 0; + memset(&api, 0, sizeof(api)); api.vrf_id = VRF_DEFAULT; api.type = ZEBRA_ROUTE_VNC; - api.message = 0; - SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); /* TBD means? */ - api.nexthop_num = nhp_count; - api.nexthop = nhp_ary; - SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX); - api.ifindex_num = 1; - api.ifindex = &ifindex; - api.instance = 0; + api.prefix = *p; api.safi = SAFI_UNICAST; + /* Nexthops */ + SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); + api.nexthop_num = nhp_count; + for (i = 0; i < nhp_count; i++) { + api_nh = &api.nexthops[i]; + memcpy(&api_nh->gate.ipv6, &nhp_ary6[i], + sizeof(api_nh->gate.ipv6)); + api_nh->type = NEXTHOP_TYPE_IPV6; + } + if (BGP_DEBUG(zebra, ZEBRA)) { char buf[INET6_ADDRSTRLEN]; @@ -561,10 +569,8 @@ static void vnc_zebra_route_msg(struct prefix *p, int nhp_count, void *nhp_ary, p->prefixlen, nhp_count); } - zapi_ipv6_route((add ? ZEBRA_IPV6_ROUTE_ADD - : ZEBRA_IPV6_ROUTE_DELETE), - zclient_vnc, (struct prefix_ipv6 *)p, NULL, - &api); + zclient_route_send((add ? ZEBRA_ROUTE_ADD : ZEBRA_ROUTE_DELETE), + zclient_vnc, &api); } else { vnc_zlog_debug_verbose( "%s: unknown prefix address family, skipping", |