summaryrefslogtreecommitdiff
path: root/pimd/pim_cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'pimd/pim_cmd.c')
-rw-r--r--pimd/pim_cmd.c220
1 files changed, 120 insertions, 100 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 1ebe9c9aba..ed1d6a8195 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -1063,58 +1063,48 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
// FHR
for (ALL_LIST_ELEMENTS_RO(pim->upstream_list, upnode,
up)) {
- if (ifp == up->rpf.source_nexthop.interface) {
- if (up->flags
- & PIM_UPSTREAM_FLAG_MASK_FHR) {
- if (!json_fhr_sources) {
- json_fhr_sources =
- json_object_new_object();
- }
-
- pim_inet4_dump("<src?>",
- up->sg.src,
- src_str,
- sizeof(src_str));
- pim_inet4_dump("<grp?>",
- up->sg.grp,
- grp_str,
- sizeof(grp_str));
- pim_time_uptime(
- uptime, sizeof(uptime),
- now - up->state_transition);
-
- /* Does this group live in
- * json_fhr_sources? If not
- * create it. */
- json_object_object_get_ex(
- json_fhr_sources,
- grp_str, &json_group);
-
- if (!json_group) {
- json_group =
- json_object_new_object();
- json_object_object_add(
- json_fhr_sources,
- grp_str,
- json_group);
- }
-
- json_group_source =
- json_object_new_object();
- json_object_string_add(
- json_group_source,
- "source", src_str);
- json_object_string_add(
- json_group_source,
- "group", grp_str);
- json_object_string_add(
- json_group_source,
- "upTime", uptime);
- json_object_object_add(
- json_group, src_str,
- json_group_source);
- }
+ if (ifp != up->rpf.source_nexthop.interface)
+ continue;
+
+ if (!(up->flags & PIM_UPSTREAM_FLAG_MASK_FHR))
+ continue;
+
+ if (!json_fhr_sources)
+ json_fhr_sources =
+ json_object_new_object();
+
+ pim_inet4_dump("<src?>", up->sg.src,
+ src_str, sizeof(src_str));
+ pim_inet4_dump("<grp?>", up->sg.grp,
+ grp_str, sizeof(grp_str));
+ pim_time_uptime(uptime, sizeof(uptime),
+ now - up->state_transition);
+
+ /*
+ * Does this group live in json_fhr_sources?
+ * If not create it.
+ */
+ json_object_object_get_ex(json_fhr_sources,
+ grp_str,
+ &json_group);
+
+ if (!json_group) {
+ json_group = json_object_new_object();
+ json_object_object_add(
+ json_fhr_sources,
+ grp_str,
+ json_group);
}
+
+ json_group_source = json_object_new_object();
+ json_object_string_add(json_group_source,
+ "source", src_str);
+ json_object_string_add(json_group_source,
+ "group", grp_str);
+ json_object_string_add(json_group_source,
+ "upTime", uptime);
+ json_object_object_add(json_group, src_str,
+ json_group_source);
}
if (json_fhr_sources) {
@@ -1237,37 +1227,33 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
print_header = 1;
for (ALL_LIST_ELEMENTS_RO(pim->upstream_list, upnode,
up)) {
- if (strcmp(ifp->name, up->rpf.source_nexthop
- .interface->name)
- == 0) {
- if (up->flags
- & PIM_UPSTREAM_FLAG_MASK_FHR) {
-
- if (print_header) {
- vty_out(vty,
- "FHR - First Hop Router\n");
- vty_out(vty,
- "----------------------\n");
- print_header = 0;
- }
-
- pim_inet4_dump("<src?>",
- up->sg.src,
- src_str,
- sizeof(src_str));
- pim_inet4_dump("<grp?>",
- up->sg.grp,
- grp_str,
- sizeof(grp_str));
- pim_time_uptime(
- uptime, sizeof(uptime),
- now - up->state_transition);
- vty_out(vty,
- "%s : %s is a source, uptime is %s\n",
- grp_str, src_str,
- uptime);
- }
+
+ if (strcmp(ifp->name,
+ up->rpf.source_nexthop.
+ interface->name) != 0)
+ continue;
+
+ if (!(up->flags & PIM_UPSTREAM_FLAG_MASK_FHR))
+ continue;
+
+ if (print_header) {
+ vty_out(vty,
+ "FHR - First Hop Router\n");
+ vty_out(vty,
+ "----------------------\n");
+ print_header = 0;
}
+
+ pim_inet4_dump("<src?>", up->sg.src,
+ src_str, sizeof(src_str));
+ pim_inet4_dump("<grp?>", up->sg.grp,
+ grp_str, sizeof(grp_str));
+ pim_time_uptime(uptime, sizeof(uptime),
+ now - up->state_transition);
+ vty_out(vty,
+ "%s : %s is a source, uptime is %s\n",
+ grp_str, src_str,
+ uptime);
}
if (!print_header) {
@@ -2400,6 +2386,30 @@ static void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
json_object_string_add(
json_row, "inboundInterface",
up->rpf.source_nexthop.interface->name);
+
+ /*
+ * The RPF address we use is slightly different
+ * based upon what we are looking up.
+ * If we have a S, list that unless
+ * we are the FHR, else we just put
+ * the RP as the rpfAddress
+ */
+ if (up->flags & PIM_UPSTREAM_FLAG_MASK_FHR ||
+ up->sg.src.s_addr == INADDR_ANY) {
+ char rpf[PREFIX_STRLEN];
+ struct pim_rpf *rpg;
+
+ rpg = RP(pim, up->sg.grp);
+ pim_inet4_dump("<rpf?>",
+ rpg->rpf_addr.u.prefix4,
+ rpf, sizeof(rpf));
+ json_object_string_add(json_row,
+ "rpfAddress", rpf);
+ } else {
+ json_object_string_add(json_row,
+ "rpfAddress", src_str);
+ }
+
json_object_string_add(json_row, "source", src_str);
json_object_string_add(json_row, "group", grp_str);
json_object_string_add(json_row, "state", state_str);
@@ -3160,12 +3170,12 @@ static void clear_interfaces(struct pim_instance *pim)
clear_pim_interfaces(pim);
}
-#define PIM_GET_PIM_INTERFACE(pim_ifp, ifp) \
- pim_ifp = ifp->info; \
- if (!pim_ifp) { \
- vty_out(vty, \
+#define PIM_GET_PIM_INTERFACE(pim_ifp, ifp) \
+ pim_ifp = ifp->info; \
+ if (!pim_ifp) { \
+ vty_out(vty, \
"%% Enable PIM and/or IGMP on this interface first\n"); \
- return CMD_WARNING_CONFIG_FAILED; \
+ return CMD_WARNING_CONFIG_FAILED; \
}
DEFUN (clear_ip_interfaces,
@@ -4451,7 +4461,8 @@ DEFUN (show_ip_multicast_vrf_all,
return CMD_SUCCESS;
}
-static void show_mroute(struct pim_instance *pim, struct vty *vty, u_char uj)
+static void show_mroute(struct pim_instance *pim, struct vty *vty,
+ bool fill, u_char uj)
{
struct listnode *node;
struct channel_oil *c_oil;
@@ -4704,11 +4715,9 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, u_char uj)
continue;
ifp_out = pim_if_find_by_vif_index(pim, oif_vif_index);
- pim_time_uptime(
- oif_uptime, sizeof(oif_uptime),
- now
- - s_route->c_oil
- .oif_creation[oif_vif_index]);
+ pim_time_uptime(oif_uptime, sizeof(oif_uptime),
+ now -
+ s_route->c_oil.oif_creation[oif_vif_index]);
found_oif = 1;
if (ifp_out)
@@ -4751,7 +4760,7 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, u_char uj)
src_str, grp_str, proto, in_ifname,
out_ifname, ttl, oif_uptime,
pim->vrf->name);
- if (first) {
+ if (first && !fill) {
src_str[0] = '\0';
grp_str[0] = '\0';
in_ifname[0] = '\0';
@@ -4777,36 +4786,47 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, u_char uj)
DEFUN (show_ip_mroute,
show_ip_mroute_cmd,
- "show ip mroute [vrf NAME] [json]",
+ "show ip mroute [vrf NAME] [fill] [json]",
SHOW_STR
IP_STR
MROUTE_STR
VRF_CMD_HELP_STR
+ "Fill in Assumed data\n"
JSON_STR)
{
u_char uj = use_json(argc, argv);
+ bool fill = false;
int idx = 2;
struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
if (!vrf)
return CMD_WARNING;
- show_mroute(vrf->info, vty, uj);
+ if (argv_find(argv, argc, "fill", &idx))
+ fill = true;
+
+ show_mroute(vrf->info, vty, fill, uj);
return CMD_SUCCESS;
}
DEFUN (show_ip_mroute_vrf_all,
show_ip_mroute_vrf_all_cmd,
- "show ip mroute vrf all [json]",
+ "show ip mroute vrf all [fill] [json]",
SHOW_STR
IP_STR
MROUTE_STR
VRF_CMD_HELP_STR
+ "Fill in Assumed data\n"
JSON_STR)
{
u_char uj = use_json(argc, argv);
+ int idx = 4;
struct vrf *vrf;
bool first = true;
+ bool fill = false;
+
+ if (argv_find(argv, argc, "fill", &idx))
+ fill = true;
if (uj)
vty_out(vty, "{ ");
@@ -4818,7 +4838,7 @@ DEFUN (show_ip_mroute_vrf_all,
first = false;
} else
vty_out(vty, "VRF: %s\n", vrf->name);
- show_mroute(vrf->info, vty, uj);
+ show_mroute(vrf->info, vty, fill, uj);
}
if (uj)
vty_out(vty, "}\n");
@@ -6470,7 +6490,7 @@ DEFUN(interface_ip_pim_boundary_oil,
"Generic multicast configuration options\n"
"Define multicast boundary\n"
"Filter OIL by group using prefix list\n"
- "Prefix list to filter OIL with")
+ "Prefix list to filter OIL with\n")
{
VTY_DECLVAR_CONTEXT(interface, iif);
struct pim_interface *pim_ifp;
@@ -6498,11 +6518,11 @@ DEFUN(interface_no_ip_pim_boundary_oil,
"Generic multicast configuration options\n"
"Define multicast boundary\n"
"Filter OIL by group using prefix list\n"
- "Prefix list to filter OIL with")
+ "Prefix list to filter OIL with\n")
{
VTY_DECLVAR_CONTEXT(interface, iif);
struct pim_interface *pim_ifp;
- int idx;
+ int idx = 0;
argv_find(argv, argc, "WORD", &idx);