mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 07:27:50 +00:00
pimd: Cleanup deep nesting in pim_cmd.c
Cleanup some deep nesting in pim_cmd.c so that functions look easier on the eyes. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
48f41fe829
commit
5fe58e3d62
146
pimd/pim_cmd.c
146
pimd/pim_cmd.c
@ -1063,58 +1063,48 @@ 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) {
|
|
||||||
json_fhr_sources =
|
|
||||||
json_object_new_object();
|
|
||||||
}
|
|
||||||
|
|
||||||
pim_inet4_dump("<src?>",
|
if (!(up->flags & PIM_UPSTREAM_FLAG_MASK_FHR))
|
||||||
up->sg.src,
|
continue;
|
||||||
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
|
if (!json_fhr_sources)
|
||||||
* json_fhr_sources? If not
|
json_fhr_sources =
|
||||||
* create it. */
|
json_object_new_object();
|
||||||
json_object_object_get_ex(
|
|
||||||
json_fhr_sources,
|
|
||||||
grp_str, &json_group);
|
|
||||||
|
|
||||||
if (!json_group) {
|
pim_inet4_dump("<src?>", up->sg.src,
|
||||||
json_group =
|
src_str, sizeof(src_str));
|
||||||
json_object_new_object();
|
pim_inet4_dump("<grp?>", up->sg.grp,
|
||||||
json_object_object_add(
|
grp_str, sizeof(grp_str));
|
||||||
json_fhr_sources,
|
pim_time_uptime(uptime, sizeof(uptime),
|
||||||
grp_str,
|
now - up->state_transition);
|
||||||
json_group);
|
|
||||||
}
|
|
||||||
|
|
||||||
json_group_source =
|
/*
|
||||||
json_object_new_object();
|
* Does this group live in json_fhr_sources?
|
||||||
json_object_string_add(
|
* If not create it.
|
||||||
json_group_source,
|
*/
|
||||||
"source", src_str);
|
json_object_object_get_ex(json_fhr_sources,
|
||||||
json_object_string_add(
|
grp_str,
|
||||||
json_group_source,
|
&json_group);
|
||||||
"group", grp_str);
|
|
||||||
json_object_string_add(
|
if (!json_group) {
|
||||||
json_group_source,
|
json_group = json_object_new_object();
|
||||||
"upTime", uptime);
|
json_object_object_add(
|
||||||
json_object_object_add(
|
json_fhr_sources,
|
||||||
json_group, src_str,
|
grp_str,
|
||||||
json_group_source);
|
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) {
|
if (json_fhr_sources) {
|
||||||
@ -1237,37 +1227,33 @@ 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)
|
|
||||||
== 0) {
|
|
||||||
if (up->flags
|
|
||||||
& PIM_UPSTREAM_FLAG_MASK_FHR) {
|
|
||||||
|
|
||||||
if (print_header) {
|
if (strcmp(ifp->name,
|
||||||
vty_out(vty,
|
up->rpf.source_nexthop.
|
||||||
"FHR - First Hop Router\n");
|
interface->name) != 0)
|
||||||
vty_out(vty,
|
continue;
|
||||||
"----------------------\n");
|
|
||||||
print_header = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pim_inet4_dump("<src?>",
|
if (!(up->flags & PIM_UPSTREAM_FLAG_MASK_FHR))
|
||||||
up->sg.src,
|
continue;
|
||||||
src_str,
|
|
||||||
sizeof(src_str));
|
if (print_header) {
|
||||||
pim_inet4_dump("<grp?>",
|
vty_out(vty,
|
||||||
up->sg.grp,
|
"FHR - First Hop Router\n");
|
||||||
grp_str,
|
vty_out(vty,
|
||||||
sizeof(grp_str));
|
"----------------------\n");
|
||||||
pim_time_uptime(
|
print_header = 0;
|
||||||
uptime, sizeof(uptime),
|
|
||||||
now - up->state_transition);
|
|
||||||
vty_out(vty,
|
|
||||||
"%s : %s is a source, uptime is %s\n",
|
|
||||||
grp_str, src_str,
|
|
||||||
uptime);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
if (!print_header) {
|
||||||
@ -3184,12 +3170,12 @@ static void clear_interfaces(struct pim_instance *pim)
|
|||||||
clear_pim_interfaces(pim);
|
clear_pim_interfaces(pim);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PIM_GET_PIM_INTERFACE(pim_ifp, ifp) \
|
#define PIM_GET_PIM_INTERFACE(pim_ifp, ifp) \
|
||||||
pim_ifp = ifp->info; \
|
pim_ifp = ifp->info; \
|
||||||
if (!pim_ifp) { \
|
if (!pim_ifp) { \
|
||||||
vty_out(vty, \
|
vty_out(vty, \
|
||||||
"%% Enable PIM and/or IGMP on this interface first\n"); \
|
"%% Enable PIM and/or IGMP on this interface first\n"); \
|
||||||
return CMD_WARNING_CONFIG_FAILED; \
|
return CMD_WARNING_CONFIG_FAILED; \
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN (clear_ip_interfaces,
|
DEFUN (clear_ip_interfaces,
|
||||||
|
Loading…
Reference in New Issue
Block a user