Merge pull request #4179 from donaldsharp/mroute_show

Mroute show
This commit is contained in:
Jafar Al-Gharaibeh 2019-04-23 11:18:22 -05:00 committed by GitHub
commit e400cd8aac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 16 deletions

View File

@ -293,10 +293,14 @@ cause great confusion.
Display various information about the interfaces used in this pim instance.
.. index:: show ip mroute
.. clicmd:: show ip mroute
.. index:: show ip mroute [vrf NAME] [A.B.C.D [A.B.C.D]] [fill] [json]
.. clicmd:: show ip mroute [vrf NAME] [A.B.C.D [A.B.C.D]] [fill] [json]
Display information about installed into the kernel S,G mroutes.
Display information about installed into the kernel S,G mroutes. If
one address is specified we assume it is the Group we are interested
in displaying data on. If the second address is specified then it is
Source Group. The keyword `fill` says to fill in all assumed data
for test/data gathering purposes.
.. index:: show ip mroute count
.. clicmd:: show ip mroute count

View File

@ -4557,8 +4557,8 @@ DEFUN (show_ip_multicast_vrf_all,
return CMD_SUCCESS;
}
static void show_mroute(struct pim_instance *pim, struct vty *vty, bool fill,
bool uj)
static void show_mroute(struct pim_instance *pim, struct vty *vty,
struct prefix_sg *sg, bool fill, bool uj)
{
struct listnode *node;
struct channel_oil *c_oil;
@ -4595,6 +4595,13 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, bool fill,
if (!c_oil->installed && !uj)
continue;
if (sg->grp.s_addr != 0 &&
sg->grp.s_addr != c_oil->oil.mfcc_mcastgrp.s_addr)
continue;
if (sg->src.s_addr != 0 &&
sg->src.s_addr != c_oil->oil.mfcc_origin.s_addr)
continue;
pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, grp_str,
sizeof(grp_str));
pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, src_str,
@ -4892,28 +4899,43 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, bool fill,
}
}
DEFUN (show_ip_mroute,
DEFPY (show_ip_mroute,
show_ip_mroute_cmd,
"show ip mroute [vrf NAME] [fill] [json]",
"show ip mroute [vrf NAME] [A.B.C.D$s_or_g [A.B.C.D$g]] [fill$fill] [json$json]",
SHOW_STR
IP_STR
MROUTE_STR
VRF_CMD_HELP_STR
"The Source or Group\n"
"The Group\n"
"Fill in Assumed data\n"
JSON_STR)
{
bool uj = use_json(argc, argv);
bool fill = false;
int idx = 2;
struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
struct prefix_sg sg = {0};
struct pim_instance *pim;
struct vrf *v;
if (!vrf)
v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
if (!v) {
vty_out(vty, "%% Vrf specified: %s does not exist\n", vrf);
return CMD_WARNING;
}
pim = pim_get_pim_instance(v->vrf_id);
if (argv_find(argv, argc, "fill", &idx))
fill = true;
if (!pim) {
vty_out(vty, "%% Unable to find pim instance\n");
return CMD_WARNING;
}
show_mroute(vrf->info, vty, fill, uj);
if (s_or_g.s_addr != 0) {
if (g.s_addr != 0) {
sg.src = s_or_g;
sg.grp = g;
} else
sg.grp = s_or_g;
}
show_mroute(pim, vty, &sg, !!fill, !!json);
return CMD_SUCCESS;
}
@ -4927,6 +4949,7 @@ DEFUN (show_ip_mroute_vrf_all,
"Fill in Assumed data\n"
JSON_STR)
{
struct prefix_sg sg = {0};
bool uj = use_json(argc, argv);
int idx = 4;
struct vrf *vrf;
@ -4946,7 +4969,7 @@ DEFUN (show_ip_mroute_vrf_all,
first = false;
} else
vty_out(vty, "VRF: %s\n", vrf->name);
show_mroute(vrf->info, vty, fill, uj);
show_mroute(vrf->info, vty, &sg, fill, uj);
}
if (uj)
vty_out(vty, "}\n");