zebra, pimd: Add a field family in the message ZEBRA_IPMR_ROUTE_STATS

1. Adding a field family in the existing ZEBRA_IPMR_ROUTE_STATS
to get the ipv4 as well as ipv6 trafic stats between pim and zebra.
2. Modify the debug to print both v4/v6 prefixes

pimd: pim6d: Modify pim_zlookup_sg_statistics to get ipv6 stats

Modify the pim_zlookup_sg_statistics api to
get ipv4/ipv6 stats from zebra. Making the api
common.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
This commit is contained in:
Mobashshera Rasool 2022-04-04 03:17:32 -07:00
parent 4d3b4b1851
commit 51f4fd9810
2 changed files with 57 additions and 26 deletions

View File

@ -506,17 +506,16 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)
pim_sgaddr sg;
int count = 0;
int ret;
pim_sgaddr more = {};
struct interface *ifp =
pim_if_find_by_vif_index(c_oil->pim, c_oil->oil.mfcc_parent);
pim_if_find_by_vif_index(c_oil->pim, *oil_parent(c_oil));
if (PIM_DEBUG_ZEBRA) {
pim_sgaddr more;
more.src = c_oil->oil.mfcc_origin;
more.grp = c_oil->oil.mfcc_mcastgrp;
zlog_debug("Sending Request for New Channel Oil Information%pSG VIIF %d(%s)",
&more, c_oil->oil.mfcc_parent,
c_oil->pim->vrf->name);
more.src = *oil_origin(c_oil);
more.grp = *oil_mcastgrp(c_oil);
zlog_debug(
"Sending Request for New Channel Oil Information%pSG VIIF %d(%s)",
&more, *oil_parent(c_oil), c_oil->pim->vrf->name);
}
if (!ifp)
@ -525,8 +524,9 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)
stream_reset(s);
zclient_create_header(s, ZEBRA_IPMR_ROUTE_STATS,
c_oil->pim->vrf->vrf_id);
stream_put_in_addr(s, &c_oil->oil.mfcc_origin);
stream_put_in_addr(s, &c_oil->oil.mfcc_mcastgrp);
stream_putl(s, PIM_AF);
stream_write(s, oil_origin(c_oil), sizeof(pim_addr));
stream_write(s, oil_mcastgrp(c_oil), sizeof(pim_addr));
stream_putl(s, ifp->ifindex);
stream_putw_at(s, 0, stream_get_endp(s));
@ -560,20 +560,17 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)
}
}
sg.src.s_addr = stream_get_ipv4(s);
sg.grp.s_addr = stream_get_ipv4(s);
if (sg.src.s_addr != c_oil->oil.mfcc_origin.s_addr
|| sg.grp.s_addr != c_oil->oil.mfcc_mcastgrp.s_addr) {
if (PIM_DEBUG_ZEBRA) {
pim_sgaddr more;
stream_get(&sg.src, s, sizeof(pim_addr));
stream_get(&sg.grp, s, sizeof(pim_addr));
more.src = c_oil->oil.mfcc_origin;
more.grp = c_oil->oil.mfcc_mcastgrp;
more.src = *oil_origin(c_oil);
more.grp = *oil_mcastgrp(c_oil);
if (pim_sgaddr_cmp(sg, more)) {
if (PIM_DEBUG_ZEBRA)
flog_err(
EC_LIB_ZAPI_MISSMATCH,
"%s: Received wrong %pSG(%s) information requested",
__func__, &more, c_oil->pim->vrf->name);
}
zclient_lookup_failed(zlookup);
return -3;
}

View File

@ -39,14 +39,37 @@ void zebra_ipmr_route_stats(ZAPI_HANDLER_ARGS)
int suc = -1;
memset(&mroute, 0, sizeof(mroute));
STREAM_GET(&mroute.src.ipaddr_v4, msg, 4);
STREAM_GET(&mroute.grp.ipaddr_v4, msg, 4);
STREAM_GETL(msg, mroute.family);
switch (mroute.family) {
case AF_INET:
SET_IPADDR_V4(&mroute.src);
SET_IPADDR_V4(&mroute.grp);
STREAM_GET(&mroute.src.ipaddr_v4, msg,
sizeof(mroute.src.ipaddr_v4));
STREAM_GET(&mroute.grp.ipaddr_v4, msg,
sizeof(mroute.grp.ipaddr_v4));
break;
case AF_INET6:
SET_IPADDR_V6(&mroute.src);
SET_IPADDR_V6(&mroute.grp);
STREAM_GET(&mroute.src.ipaddr_v6, msg,
sizeof(mroute.src.ipaddr_v6));
STREAM_GET(&mroute.grp.ipaddr_v6, msg,
sizeof(mroute.grp.ipaddr_v6));
break;
default:
zlog_warn("%s: Invalid address family received while parsing",
__func__);
return;
}
STREAM_GETL(msg, mroute.ifindex);
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("Asking for (%pI4,%pI4)[%s(%u)] mroute information",
&mroute.src.ipaddr_v4, &mroute.grp.ipaddr_v4,
zvrf->vrf->name, zvrf->vrf->vrf_id);
zlog_debug("Asking for (%pIA,%pIA)[%s(%u)] mroute information",
&mroute.src, &mroute.grp, zvrf->vrf->name,
zvrf->vrf->vrf_id);
suc = kernel_get_ipmr_sg_stats(zvrf, &mroute);
@ -56,8 +79,19 @@ stream_failure:
stream_reset(s);
zclient_create_header(s, ZEBRA_IPMR_ROUTE_STATS, zvrf_id(zvrf));
stream_put_in_addr(s, &mroute.src.ipaddr_v4);
stream_put_in_addr(s, &mroute.grp.ipaddr_v4);
if (mroute.family == AF_INET) {
stream_write(s, &mroute.src.ipaddr_v4,
sizeof(mroute.src.ipaddr_v4));
stream_write(s, &mroute.grp.ipaddr_v4,
sizeof(mroute.grp.ipaddr_v4));
} else {
stream_write(s, &mroute.src.ipaddr_v6,
sizeof(mroute.src.ipaddr_v6));
stream_write(s, &mroute.grp.ipaddr_v6,
sizeof(mroute.grp.ipaddr_v6));
}
stream_put(s, &mroute.lastused, sizeof(mroute.lastused));
stream_putl(s, (uint32_t)suc);