mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 22:29:23 +00:00
pim6d: Implementing "show ipv6 mroute count" CLI
Adding new show CLI to display ipv6 mroute count information. Signed-off-by: Abhishek N R <abnr@vmware.com>
This commit is contained in:
parent
50ba39bf4c
commit
c41a9dcfa2
@ -1768,6 +1768,78 @@ DEFPY (show_ipv6_mroute_vrf_all,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFPY (show_ipv6_mroute_count,
|
||||||
|
show_ipv6_mroute_count_cmd,
|
||||||
|
"show ipv6 mroute [vrf NAME] count [json$json]",
|
||||||
|
SHOW_STR
|
||||||
|
IPV6_STR
|
||||||
|
MROUTE_STR
|
||||||
|
VRF_CMD_HELP_STR
|
||||||
|
"Route and packet count data\n"
|
||||||
|
JSON_STR)
|
||||||
|
{
|
||||||
|
struct pim_instance *pim;
|
||||||
|
struct vrf *v;
|
||||||
|
json_object *json_parent = NULL;
|
||||||
|
|
||||||
|
v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
|
||||||
|
|
||||||
|
if (!v)
|
||||||
|
return CMD_WARNING;
|
||||||
|
|
||||||
|
pim = pim_get_pim_instance(v->vrf_id);
|
||||||
|
|
||||||
|
if (!pim) {
|
||||||
|
vty_out(vty, "%% Unable to find pim instance\n");
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
json_parent = json_object_new_object();
|
||||||
|
|
||||||
|
show_mroute_count(pim, vty, json_parent);
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
vty_json(vty, json_parent);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFPY (show_ipv6_mroute_count_vrf_all,
|
||||||
|
show_ipv6_mroute_count_vrf_all_cmd,
|
||||||
|
"show ipv6 mroute vrf all count [json$json]",
|
||||||
|
SHOW_STR
|
||||||
|
IPV6_STR
|
||||||
|
MROUTE_STR
|
||||||
|
VRF_CMD_HELP_STR
|
||||||
|
"Route and packet count data\n"
|
||||||
|
JSON_STR)
|
||||||
|
{
|
||||||
|
struct vrf *vrf;
|
||||||
|
json_object *json_parent = NULL;
|
||||||
|
json_object *json_vrf = NULL;
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
json_parent = json_object_new_object();
|
||||||
|
|
||||||
|
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
||||||
|
if (!json)
|
||||||
|
vty_out(vty, "VRF: %s\n", vrf->name);
|
||||||
|
else
|
||||||
|
json_vrf = json_object_new_object();
|
||||||
|
show_mroute_count(vrf->info, vty, json_vrf);
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
json_object_object_add(json_parent, vrf->name,
|
||||||
|
json_vrf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
vty_json(vty, json_parent);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
void pim_cmd_init(void)
|
void pim_cmd_init(void)
|
||||||
{
|
{
|
||||||
if_cmd_init(pim_interface_config_write);
|
if_cmd_init(pim_interface_config_write);
|
||||||
@ -1870,4 +1942,6 @@ void pim_cmd_init(void)
|
|||||||
install_element(VIEW_NODE, &show_ipv6_multicast_count_vrf_all_cmd);
|
install_element(VIEW_NODE, &show_ipv6_multicast_count_vrf_all_cmd);
|
||||||
install_element(VIEW_NODE, &show_ipv6_mroute_cmd);
|
install_element(VIEW_NODE, &show_ipv6_mroute_cmd);
|
||||||
install_element(VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
|
install_element(VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
|
||||||
|
install_element(VIEW_NODE, &show_ipv6_mroute_count_cmd);
|
||||||
|
install_element(VIEW_NODE, &show_ipv6_mroute_count_vrf_all_cmd);
|
||||||
}
|
}
|
||||||
|
@ -3891,9 +3891,9 @@ DEFUN (clear_ip_mroute_count,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN (show_ip_mroute_count,
|
DEFPY (show_ip_mroute_count,
|
||||||
show_ip_mroute_count_cmd,
|
show_ip_mroute_count_cmd,
|
||||||
"show ip mroute [vrf NAME] count [json]",
|
"show ip mroute [vrf NAME] count [json$json]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
MROUTE_STR
|
MROUTE_STR
|
||||||
@ -3901,20 +3901,36 @@ DEFUN (show_ip_mroute_count,
|
|||||||
"Route and packet count data\n"
|
"Route and packet count data\n"
|
||||||
JSON_STR)
|
JSON_STR)
|
||||||
{
|
{
|
||||||
int idx = 2;
|
struct pim_instance *pim;
|
||||||
bool uj = use_json(argc, argv);
|
struct vrf *v;
|
||||||
struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
|
json_object *json_parent = NULL;
|
||||||
|
|
||||||
if (!vrf)
|
v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
|
||||||
|
|
||||||
|
if (!v)
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
|
|
||||||
show_mroute_count(vrf->info, vty, uj);
|
pim = pim_get_pim_instance(v->vrf_id);
|
||||||
|
|
||||||
|
if (!pim) {
|
||||||
|
vty_out(vty, "%% Unable to find pim instance\n");
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
json_parent = json_object_new_object();
|
||||||
|
|
||||||
|
show_mroute_count(pim, vty, json_parent);
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
vty_json(vty, json_parent);
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN (show_ip_mroute_count_vrf_all,
|
DEFPY (show_ip_mroute_count_vrf_all,
|
||||||
show_ip_mroute_count_vrf_all_cmd,
|
show_ip_mroute_count_vrf_all_cmd,
|
||||||
"show ip mroute vrf all count [json]",
|
"show ip mroute vrf all count [json$json]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
MROUTE_STR
|
MROUTE_STR
|
||||||
@ -3922,24 +3938,27 @@ DEFUN (show_ip_mroute_count_vrf_all,
|
|||||||
"Route and packet count data\n"
|
"Route and packet count data\n"
|
||||||
JSON_STR)
|
JSON_STR)
|
||||||
{
|
{
|
||||||
bool uj = use_json(argc, argv);
|
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
bool first = true;
|
json_object *json_parent = NULL;
|
||||||
|
json_object *json_vrf = NULL;
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
json_parent = json_object_new_object();
|
||||||
|
|
||||||
if (uj)
|
|
||||||
vty_out(vty, "{ ");
|
|
||||||
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
||||||
if (uj) {
|
if (!json)
|
||||||
if (!first)
|
|
||||||
vty_out(vty, ", ");
|
|
||||||
vty_out(vty, " \"%s\": ", vrf->name);
|
|
||||||
first = false;
|
|
||||||
} else
|
|
||||||
vty_out(vty, "VRF: %s\n", vrf->name);
|
vty_out(vty, "VRF: %s\n", vrf->name);
|
||||||
show_mroute_count(vrf->info, vty, uj);
|
else
|
||||||
|
json_vrf = json_object_new_object();
|
||||||
|
|
||||||
|
show_mroute_count(vrf->info, vty, json_vrf);
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
json_object_object_add(json_parent, vrf->name,
|
||||||
|
json_vrf);
|
||||||
}
|
}
|
||||||
if (uj)
|
if (json)
|
||||||
vty_out(vty, "}\n");
|
vty_json(vty, json_parent);
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -3391,13 +3391,10 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PIM_IPV == 4
|
|
||||||
static void show_mroute_count_per_channel_oil(struct channel_oil *c_oil,
|
static void show_mroute_count_per_channel_oil(struct channel_oil *c_oil,
|
||||||
json_object *json,
|
json_object *json,
|
||||||
struct vty *vty)
|
struct vty *vty)
|
||||||
{
|
{
|
||||||
char group_str[INET_ADDRSTRLEN];
|
|
||||||
char source_str[INET_ADDRSTRLEN];
|
|
||||||
json_object *json_group = NULL;
|
json_object *json_group = NULL;
|
||||||
json_object *json_source = NULL;
|
json_object *json_source = NULL;
|
||||||
|
|
||||||
@ -3406,12 +3403,15 @@ static void show_mroute_count_per_channel_oil(struct channel_oil *c_oil,
|
|||||||
|
|
||||||
pim_mroute_update_counters(c_oil);
|
pim_mroute_update_counters(c_oil);
|
||||||
|
|
||||||
pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str,
|
|
||||||
sizeof(group_str));
|
|
||||||
pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str,
|
|
||||||
sizeof(source_str));
|
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
|
char group_str[PIM_ADDRSTRLEN];
|
||||||
|
char source_str[PIM_ADDRSTRLEN];
|
||||||
|
|
||||||
|
snprintfrr(group_str, sizeof(group_str), "%pPAs",
|
||||||
|
oil_mcastgrp(c_oil));
|
||||||
|
snprintfrr(source_str, sizeof(source_str), "%pPAs",
|
||||||
|
oil_origin(c_oil));
|
||||||
|
|
||||||
json_object_object_get_ex(json, group_str, &json_group);
|
json_object_object_get_ex(json, group_str, &json_group);
|
||||||
|
|
||||||
if (!json_group) {
|
if (!json_group) {
|
||||||
@ -3428,8 +3428,9 @@ static void show_mroute_count_per_channel_oil(struct channel_oil *c_oil,
|
|||||||
json_object_int_add(json_source, "wrongIf", c_oil->cc.wrong_if);
|
json_object_int_add(json_source, "wrongIf", c_oil->cc.wrong_if);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
vty_out(vty, "%-15s %-15s %-8llu %-7ld %-10ld %-7ld\n",
|
vty_out(vty, "%-15pPAs %-15pPAs %-8llu %-7ld %-10ld %-7ld\n",
|
||||||
source_str, group_str, c_oil->cc.lastused / 100,
|
oil_origin(c_oil), oil_mcastgrp(c_oil),
|
||||||
|
c_oil->cc.lastused / 100,
|
||||||
c_oil->cc.pktcnt - c_oil->cc.origpktcnt,
|
c_oil->cc.pktcnt - c_oil->cc.origpktcnt,
|
||||||
c_oil->cc.bytecnt - c_oil->cc.origbytecnt,
|
c_oil->cc.bytecnt - c_oil->cc.origbytecnt,
|
||||||
c_oil->cc.wrong_if - c_oil->cc.origwrong_if);
|
c_oil->cc.wrong_if - c_oil->cc.origwrong_if);
|
||||||
@ -3437,16 +3438,13 @@ static void show_mroute_count_per_channel_oil(struct channel_oil *c_oil,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void show_mroute_count(struct pim_instance *pim, struct vty *vty,
|
void show_mroute_count(struct pim_instance *pim, struct vty *vty,
|
||||||
bool uj)
|
json_object *json)
|
||||||
{
|
{
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
struct channel_oil *c_oil;
|
struct channel_oil *c_oil;
|
||||||
struct static_route *sr;
|
struct static_route *sr;
|
||||||
json_object *json = NULL;
|
|
||||||
|
|
||||||
if (uj)
|
if (!json) {
|
||||||
json = json_object_new_object();
|
|
||||||
else {
|
|
||||||
vty_out(vty, "\n");
|
vty_out(vty, "\n");
|
||||||
|
|
||||||
vty_out(vty,
|
vty_out(vty,
|
||||||
@ -3459,11 +3457,9 @@ void show_mroute_count(struct pim_instance *pim, struct vty *vty,
|
|||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO(pim->static_routes, node, sr))
|
for (ALL_LIST_ELEMENTS_RO(pim->static_routes, node, sr))
|
||||||
show_mroute_count_per_channel_oil(&sr->c_oil, json, vty);
|
show_mroute_count_per_channel_oil(&sr->c_oil, json, vty);
|
||||||
|
|
||||||
if (uj)
|
|
||||||
vty_json(vty, json);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if PIM_IPV == 4
|
||||||
void show_mroute_summary(struct pim_instance *pim, struct vty *vty,
|
void show_mroute_summary(struct pim_instance *pim, struct vty *vty,
|
||||||
json_object *json)
|
json_object *json)
|
||||||
{
|
{
|
||||||
|
@ -111,7 +111,7 @@ void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
|
|||||||
void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
|
void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
|
||||||
bool fill, json_object *json);
|
bool fill, json_object *json);
|
||||||
void show_mroute_count(struct pim_instance *pim, struct vty *vty,
|
void show_mroute_count(struct pim_instance *pim, struct vty *vty,
|
||||||
bool uj);
|
json_object *json);
|
||||||
void show_mroute_summary(struct pim_instance *pim, struct vty *vty,
|
void show_mroute_summary(struct pim_instance *pim, struct vty *vty,
|
||||||
json_object *json);
|
json_object *json);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user