mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 23:53:28 +00:00
ripd/ripngd: use the new API to send routes to zebra
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
52dd3aa483
commit
c9fb3e233e
@ -39,40 +39,32 @@ struct zclient *zclient = NULL;
|
|||||||
/* Send ECMP routes to zebra. */
|
/* Send ECMP routes to zebra. */
|
||||||
static void rip_zebra_ipv4_send(struct route_node *rp, u_char cmd)
|
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 list *list = (struct list *)rp->info;
|
||||||
struct zapi_ipv4 api;
|
struct zapi_route api;
|
||||||
|
struct zapi_nexthop *api_nh;
|
||||||
struct listnode *listnode = NULL;
|
struct listnode *listnode = NULL;
|
||||||
struct rip_info *rinfo = NULL;
|
struct rip_info *rinfo = NULL;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
memset(&api, 0, sizeof(api));
|
||||||
api.vrf_id = VRF_DEFAULT;
|
api.vrf_id = VRF_DEFAULT;
|
||||||
api.type = ZEBRA_ROUTE_RIP;
|
api.type = ZEBRA_ROUTE_RIP;
|
||||||
api.instance = 0;
|
|
||||||
api.flags = 0;
|
|
||||||
api.message = 0;
|
|
||||||
api.safi = SAFI_UNICAST;
|
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);
|
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
|
||||||
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
|
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
|
||||||
nexthops[count++] = &rinfo->nexthop;
|
api_nh = &api.nexthops[count];
|
||||||
if (cmd == ZEBRA_IPV4_ROUTE_ADD)
|
api_nh->gate.ipv4 = rinfo->nexthop;
|
||||||
|
api_nh->type = NEXTHOP_TYPE_IPV4;
|
||||||
|
if (cmd == ZEBRA_ROUTE_ADD)
|
||||||
SET_FLAG(rinfo->flags, RIP_RTF_FIB);
|
SET_FLAG(rinfo->flags, RIP_RTF_FIB);
|
||||||
else
|
else
|
||||||
UNSET_FLAG(rinfo->flags, RIP_RTF_FIB);
|
UNSET_FLAG(rinfo->flags, RIP_RTF_FIB);
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
api.nexthop = nexthops;
|
api.prefix = rp->p;
|
||||||
api.nexthop_num = count;
|
api.nexthop_num = count;
|
||||||
api.ifindex_num = 0;
|
|
||||||
|
|
||||||
rinfo = listgetdata(listhead(list));
|
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;
|
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 (IS_RIP_DEBUG_ZEBRA) {
|
||||||
if (rip->ecmp)
|
if (rip->ecmp)
|
||||||
zlog_debug("%s: %s/%d nexthops %d",
|
zlog_debug("%s: %s/%d nexthops %d",
|
||||||
(cmd == ZEBRA_IPV4_ROUTE_ADD)
|
(cmd == ZEBRA_ROUTE_ADD)
|
||||||
? "Install into zebra"
|
? "Install into zebra"
|
||||||
: "Delete from zebra",
|
: "Delete from zebra",
|
||||||
inet_ntoa(rp->p.u.prefix4), rp->p.prefixlen,
|
inet_ntoa(rp->p.u.prefix4), rp->p.prefixlen,
|
||||||
count);
|
count);
|
||||||
else
|
else
|
||||||
zlog_debug("%s: %s/%d",
|
zlog_debug("%s: %s/%d",
|
||||||
(cmd == ZEBRA_IPV4_ROUTE_ADD)
|
(cmd == ZEBRA_ROUTE_ADD)
|
||||||
? "Install into zebra"
|
? "Install into zebra"
|
||||||
: "Delete from zebra",
|
: "Delete from zebra",
|
||||||
inet_ntoa(rp->p.u.prefix4), rp->p.prefixlen);
|
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. */
|
/* Add/update ECMP routes to zebra. */
|
||||||
void rip_zebra_ipv4_add(struct route_node *rp)
|
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. */
|
/* Delete ECMP routes from zebra. */
|
||||||
void rip_zebra_ipv4_delete(struct route_node *rp)
|
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. */
|
/* Zebra route add and delete treatment. */
|
||||||
|
@ -39,47 +39,33 @@ struct zclient *zclient = NULL;
|
|||||||
/* Send ECMP routes to zebra. */
|
/* Send ECMP routes to zebra. */
|
||||||
static void ripng_zebra_ipv6_send(struct route_node *rp, u_char cmd)
|
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 list *list = (struct list *)rp->info;
|
||||||
struct zapi_ipv6 api;
|
struct zapi_route api;
|
||||||
|
struct zapi_nexthop *api_nh;
|
||||||
struct listnode *listnode = NULL;
|
struct listnode *listnode = NULL;
|
||||||
struct ripng_info *rinfo = NULL;
|
struct ripng_info *rinfo = NULL;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
memset(&api, 0, sizeof(api));
|
||||||
api.vrf_id = VRF_DEFAULT;
|
api.vrf_id = VRF_DEFAULT;
|
||||||
api.type = ZEBRA_ROUTE_RIPNG;
|
api.type = ZEBRA_ROUTE_RIPNG;
|
||||||
api.instance = 0;
|
|
||||||
api.flags = 0;
|
|
||||||
api.message = 0;
|
|
||||||
api.safi = SAFI_UNICAST;
|
api.safi = SAFI_UNICAST;
|
||||||
|
api.prefix = rp->p;
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
|
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
|
||||||
SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX);
|
|
||||||
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
|
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
|
||||||
nexthops[count] = &rinfo->nexthop;
|
api_nh = &api.nexthops[count];
|
||||||
ifindexes[count] = rinfo->ifindex;
|
api_nh->gate.ipv6 = rinfo->nexthop;
|
||||||
|
api_nh->ifindex = rinfo->ifindex;
|
||||||
|
api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX;
|
||||||
count++;
|
count++;
|
||||||
if (cmd == ZEBRA_IPV6_ROUTE_ADD)
|
if (cmd == ZEBRA_ROUTE_ADD)
|
||||||
SET_FLAG(rinfo->flags, RIPNG_RTF_FIB);
|
SET_FLAG(rinfo->flags, RIPNG_RTF_FIB);
|
||||||
else
|
else
|
||||||
UNSET_FLAG(rinfo->flags, RIPNG_RTF_FIB);
|
UNSET_FLAG(rinfo->flags, RIPNG_RTF_FIB);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.nexthop = nexthops;
|
|
||||||
api.nexthop_num = count;
|
api.nexthop_num = count;
|
||||||
api.ifindex = ifindexes;
|
|
||||||
api.ifindex_num = count;
|
|
||||||
|
|
||||||
rinfo = listgetdata(listhead(list));
|
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;
|
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 (IS_RIPNG_DEBUG_ZEBRA) {
|
||||||
if (ripng->ecmp)
|
if (ripng->ecmp)
|
||||||
zlog_debug("%s: %s/%d nexthops %d",
|
zlog_debug("%s: %s/%d nexthops %d",
|
||||||
(cmd == ZEBRA_IPV6_ROUTE_ADD)
|
(cmd == ZEBRA_ROUTE_ADD)
|
||||||
? "Install into zebra"
|
? "Install into zebra"
|
||||||
: "Delete from zebra",
|
: "Delete from zebra",
|
||||||
inet6_ntoa(rp->p.u.prefix6), rp->p.prefixlen,
|
inet6_ntoa(rp->p.u.prefix6), rp->p.prefixlen,
|
||||||
count);
|
count);
|
||||||
else
|
else
|
||||||
zlog_debug("%s: %s/%d",
|
zlog_debug(
|
||||||
(cmd == ZEBRA_IPV6_ROUTE_ADD)
|
"%s: %s/%d",
|
||||||
? "Install into zebra"
|
(cmd == ZEBRA_ROUTE_ADD) ? "Install into zebra"
|
||||||
: "Delete from zebra",
|
: "Delete from zebra",
|
||||||
inet6_ntoa(rp->p.u.prefix6),
|
inet6_ntoa(rp->p.u.prefix6), rp->p.prefixlen);
|
||||||
rp->p.prefixlen);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add/update ECMP routes to zebra. */
|
/* Add/update ECMP routes to zebra. */
|
||||||
void ripng_zebra_ipv6_add(struct route_node *rp)
|
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. */
|
/* Delete ECMP routes from zebra. */
|
||||||
void ripng_zebra_ipv6_delete(struct route_node *rp)
|
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. */
|
/* Zebra route add and delete treatment. */
|
||||||
|
Loading…
Reference in New Issue
Block a user