Merge pull request #1314 from donaldsharp/pim_rpf_address

Pim rpf address
This commit is contained in:
Jafar Al-Gharaibeh 2017-10-10 11:42:26 -05:00 committed by GitHub
commit 39271f2192

View File

@ -1063,59 +1063,49 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
// FHR // FHR
for (ALL_LIST_ELEMENTS_RO(pim->upstream_list, upnode, for (ALL_LIST_ELEMENTS_RO(pim->upstream_list, upnode,
up)) { up)) {
if (ifp == up->rpf.source_nexthop.interface) { if (ifp != up->rpf.source_nexthop.interface)
if (up->flags continue;
& PIM_UPSTREAM_FLAG_MASK_FHR) {
if (!json_fhr_sources) { if (!(up->flags & PIM_UPSTREAM_FLAG_MASK_FHR))
continue;
if (!json_fhr_sources)
json_fhr_sources = json_fhr_sources =
json_object_new_object(); json_object_new_object();
}
pim_inet4_dump("<src?>", pim_inet4_dump("<src?>", up->sg.src,
up->sg.src, src_str, sizeof(src_str));
src_str, pim_inet4_dump("<grp?>", up->sg.grp,
sizeof(src_str)); grp_str, sizeof(grp_str));
pim_inet4_dump("<grp?>", pim_time_uptime(uptime, sizeof(uptime),
up->sg.grp,
grp_str,
sizeof(grp_str));
pim_time_uptime(
uptime, sizeof(uptime),
now - up->state_transition); now - up->state_transition);
/* Does this group live in /*
* json_fhr_sources? If not * Does this group live in json_fhr_sources?
* create it. */ * If not create it.
json_object_object_get_ex( */
json_fhr_sources, json_object_object_get_ex(json_fhr_sources,
grp_str, &json_group); grp_str,
&json_group);
if (!json_group) { if (!json_group) {
json_group = json_group = json_object_new_object();
json_object_new_object();
json_object_object_add( json_object_object_add(
json_fhr_sources, json_fhr_sources,
grp_str, grp_str,
json_group); json_group);
} }
json_group_source = json_group_source = json_object_new_object();
json_object_new_object(); json_object_string_add(json_group_source,
json_object_string_add(
json_group_source,
"source", src_str); "source", src_str);
json_object_string_add( json_object_string_add(json_group_source,
json_group_source,
"group", grp_str); "group", grp_str);
json_object_string_add( json_object_string_add(json_group_source,
json_group_source,
"upTime", uptime); "upTime", uptime);
json_object_object_add( json_object_object_add(json_group, src_str,
json_group, src_str,
json_group_source); json_group_source);
} }
}
}
if (json_fhr_sources) { if (json_fhr_sources) {
json_object_object_add(json_row, json_object_object_add(json_row,
@ -1237,11 +1227,14 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
print_header = 1; print_header = 1;
for (ALL_LIST_ELEMENTS_RO(pim->upstream_list, upnode, for (ALL_LIST_ELEMENTS_RO(pim->upstream_list, upnode,
up)) { up)) {
if (strcmp(ifp->name, up->rpf.source_nexthop
.interface->name) if (strcmp(ifp->name,
== 0) { up->rpf.source_nexthop.
if (up->flags interface->name) != 0)
& PIM_UPSTREAM_FLAG_MASK_FHR) { continue;
if (!(up->flags & PIM_UPSTREAM_FLAG_MASK_FHR))
continue;
if (print_header) { if (print_header) {
vty_out(vty, vty_out(vty,
@ -1251,24 +1244,17 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
print_header = 0; print_header = 0;
} }
pim_inet4_dump("<src?>", pim_inet4_dump("<src?>", up->sg.src,
up->sg.src, src_str, sizeof(src_str));
src_str, pim_inet4_dump("<grp?>", up->sg.grp,
sizeof(src_str)); grp_str, sizeof(grp_str));
pim_inet4_dump("<grp?>", pim_time_uptime(uptime, sizeof(uptime),
up->sg.grp,
grp_str,
sizeof(grp_str));
pim_time_uptime(
uptime, sizeof(uptime),
now - up->state_transition); now - up->state_transition);
vty_out(vty, vty_out(vty,
"%s : %s is a source, uptime is %s\n", "%s : %s is a source, uptime is %s\n",
grp_str, src_str, grp_str, src_str,
uptime); uptime);
} }
}
}
if (!print_header) { if (!print_header) {
vty_out(vty, "\n"); vty_out(vty, "\n");
@ -2400,6 +2386,30 @@ static void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
json_object_string_add( json_object_string_add(
json_row, "inboundInterface", json_row, "inboundInterface",
up->rpf.source_nexthop.interface->name); 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, "source", src_str);
json_object_string_add(json_row, "group", grp_str); json_object_string_add(json_row, "group", grp_str);
json_object_string_add(json_row, "state", state_str); json_object_string_add(json_row, "state", state_str);