diff options
Diffstat (limited to '')
-rw-r--r-- | ripd/rip_zebra.c | 36 | ||||
-rw-r--r-- | ripngd/ripng_zebra.c | 51 |
2 files changed, 32 insertions, 55 deletions
diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index f9d2d33f1..9a9bac51e 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -39,40 +39,32 @@ struct zclient *zclient = NULL; /* Send ECMP routes to zebra. */ static void rip_zebra_ipv4_send(struct route_node *rp, u_char cmd) { - static struct in_addr **nexthops = NULL; - static unsigned int nexthops_len = 0; - struct list *list = (struct list *)rp->info; - struct zapi_ipv4 api; + struct zapi_route api; + struct zapi_nexthop *api_nh; struct listnode *listnode = NULL; struct rip_info *rinfo = NULL; int count = 0; + memset(&api, 0, sizeof(api)); api.vrf_id = VRF_DEFAULT; api.type = ZEBRA_ROUTE_RIP; - api.instance = 0; - api.flags = 0; - api.message = 0; api.safi = SAFI_UNICAST; - if (nexthops_len < listcount(list)) { - nexthops_len = listcount(list); - nexthops = XREALLOC(MTYPE_TMP, nexthops, - nexthops_len * sizeof(struct in_addr *)); - } - SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) { - nexthops[count++] = &rinfo->nexthop; - if (cmd == ZEBRA_IPV4_ROUTE_ADD) + api_nh = &api.nexthops[count]; + api_nh->gate.ipv4 = rinfo->nexthop; + api_nh->type = NEXTHOP_TYPE_IPV4; + if (cmd == ZEBRA_ROUTE_ADD) SET_FLAG(rinfo->flags, RIP_RTF_FIB); else UNSET_FLAG(rinfo->flags, RIP_RTF_FIB); + count++; } - api.nexthop = nexthops; + api.prefix = rp->p; api.nexthop_num = count; - api.ifindex_num = 0; rinfo = listgetdata(listhead(list)); @@ -89,19 +81,19 @@ static void rip_zebra_ipv4_send(struct route_node *rp, u_char cmd) api.tag = rinfo->tag; } - zapi_ipv4_route(cmd, zclient, (struct prefix_ipv4 *)&rp->p, &api); + zclient_route_send(cmd, zclient, &api); if (IS_RIP_DEBUG_ZEBRA) { if (rip->ecmp) zlog_debug("%s: %s/%d nexthops %d", - (cmd == ZEBRA_IPV4_ROUTE_ADD) + (cmd == ZEBRA_ROUTE_ADD) ? "Install into zebra" : "Delete from zebra", inet_ntoa(rp->p.u.prefix4), rp->p.prefixlen, count); else zlog_debug("%s: %s/%d", - (cmd == ZEBRA_IPV4_ROUTE_ADD) + (cmd == ZEBRA_ROUTE_ADD) ? "Install into zebra" : "Delete from zebra", inet_ntoa(rp->p.u.prefix4), rp->p.prefixlen); @@ -113,13 +105,13 @@ static void rip_zebra_ipv4_send(struct route_node *rp, u_char cmd) /* Add/update ECMP routes to zebra. */ void rip_zebra_ipv4_add(struct route_node *rp) { - rip_zebra_ipv4_send(rp, ZEBRA_IPV4_ROUTE_ADD); + rip_zebra_ipv4_send(rp, ZEBRA_ROUTE_ADD); } /* Delete ECMP routes from zebra. */ void rip_zebra_ipv4_delete(struct route_node *rp) { - rip_zebra_ipv4_send(rp, ZEBRA_IPV4_ROUTE_DELETE); + rip_zebra_ipv4_send(rp, ZEBRA_ROUTE_DELETE); } /* Zebra route add and delete treatment. */ diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index 384502826..a5ed5c7b2 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -39,47 +39,33 @@ struct zclient *zclient = NULL; /* Send ECMP routes to zebra. */ static void ripng_zebra_ipv6_send(struct route_node *rp, u_char cmd) { - static struct in6_addr **nexthops = NULL; - static ifindex_t *ifindexes = NULL; - static unsigned int nexthops_len = 0; - struct list *list = (struct list *)rp->info; - struct zapi_ipv6 api; + struct zapi_route api; + struct zapi_nexthop *api_nh; struct listnode *listnode = NULL; struct ripng_info *rinfo = NULL; int count = 0; + memset(&api, 0, sizeof(api)); api.vrf_id = VRF_DEFAULT; api.type = ZEBRA_ROUTE_RIPNG; - api.instance = 0; - api.flags = 0; - api.message = 0; api.safi = SAFI_UNICAST; - - if (nexthops_len < listcount(list)) { - nexthops_len = listcount(list); - nexthops = XREALLOC(MTYPE_TMP, nexthops, - nexthops_len * sizeof(struct in6_addr *)); - ifindexes = XREALLOC(MTYPE_TMP, ifindexes, - nexthops_len * sizeof(unsigned int)); - } + api.prefix = rp->p; SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); - SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX); for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) { - nexthops[count] = &rinfo->nexthop; - ifindexes[count] = rinfo->ifindex; + api_nh = &api.nexthops[count]; + api_nh->gate.ipv6 = rinfo->nexthop; + api_nh->ifindex = rinfo->ifindex; + api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX; count++; - if (cmd == ZEBRA_IPV6_ROUTE_ADD) + if (cmd == ZEBRA_ROUTE_ADD) SET_FLAG(rinfo->flags, RIPNG_RTF_FIB); else UNSET_FLAG(rinfo->flags, RIPNG_RTF_FIB); } - api.nexthop = nexthops; api.nexthop_num = count; - api.ifindex = ifindexes; - api.ifindex_num = count; rinfo = listgetdata(listhead(list)); @@ -91,36 +77,35 @@ static void ripng_zebra_ipv6_send(struct route_node *rp, u_char cmd) api.tag = rinfo->tag; } - zapi_ipv6_route(cmd, zclient, (struct prefix_ipv6 *)&rp->p, NULL, &api); + zclient_route_send(cmd, zclient, &api); if (IS_RIPNG_DEBUG_ZEBRA) { if (ripng->ecmp) zlog_debug("%s: %s/%d nexthops %d", - (cmd == ZEBRA_IPV6_ROUTE_ADD) + (cmd == ZEBRA_ROUTE_ADD) ? "Install into zebra" : "Delete from zebra", inet6_ntoa(rp->p.u.prefix6), rp->p.prefixlen, count); else - zlog_debug("%s: %s/%d", - (cmd == ZEBRA_IPV6_ROUTE_ADD) - ? "Install into zebra" - : "Delete from zebra", - inet6_ntoa(rp->p.u.prefix6), - rp->p.prefixlen); + zlog_debug( + "%s: %s/%d", + (cmd == ZEBRA_ROUTE_ADD) ? "Install into zebra" + : "Delete from zebra", + inet6_ntoa(rp->p.u.prefix6), rp->p.prefixlen); } } /* Add/update ECMP routes to zebra. */ void ripng_zebra_ipv6_add(struct route_node *rp) { - ripng_zebra_ipv6_send(rp, ZEBRA_IPV6_ROUTE_ADD); + ripng_zebra_ipv6_send(rp, ZEBRA_ROUTE_ADD); } /* Delete ECMP routes from zebra. */ void ripng_zebra_ipv6_delete(struct route_node *rp) { - ripng_zebra_ipv6_send(rp, ZEBRA_IPV6_ROUTE_DELETE); + ripng_zebra_ipv6_send(rp, ZEBRA_ROUTE_DELETE); } /* Zebra route add and delete treatment. */ |