diff options
Diffstat (limited to 'pimd/pim_cmd.c')
| -rw-r--r-- | pimd/pim_cmd.c | 807 |
1 files changed, 37 insertions, 770 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 2d6ce24381..b387783e85 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -867,8 +867,6 @@ static void pim_show_interface_traffic(struct pim_instance *pim, if (!pim_ifp) continue; - if (pim_ifp->pim_sock_fd < 0) - continue; if (uj) { json_row = json_object_new_object(); json_object_pim_ifp_add(json_row, ifp); @@ -958,9 +956,6 @@ static void pim_show_interface_traffic_single(struct pim_instance *pim, if (!pim_ifp) continue; - if (pim_ifp->pim_sock_fd < 0) - continue; - found_ifname = 1; if (uj) { json_row = json_object_new_object(); @@ -2427,29 +2422,8 @@ DEFPY (show_ip_pim_interface, "interface name\n" JSON_STR) { - struct vrf *v; - bool uj = !!json; - bool is_mlag = !!mlag; - json_object *json_parent = NULL; - - v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); - - if (!v) - return CMD_WARNING; - - if (uj) - json_parent = json_object_new_object(); - - if (interface) - pim_show_interfaces_single(v->info, vty, interface, is_mlag, - json_parent); - else - pim_show_interfaces(v->info, vty, is_mlag, json_parent); - - if (uj) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_interface_cmd_helper(vrf, vty, !!json, !!mlag, + interface); } DEFPY (show_ip_pim_interface_vrf_all, @@ -2465,34 +2439,8 @@ DEFPY (show_ip_pim_interface_vrf_all, "interface name\n" JSON_STR) { - bool uj = !!json; - bool is_mlag = !!mlag; - struct vrf *v; - json_object *json_parent = NULL; - json_object *json_vrf = NULL; - - if (uj) - json_parent = json_object_new_object(); - - RB_FOREACH (v, vrf_name_head, &vrfs_by_name) { - if (!uj) - vty_out(vty, "VRF: %s\n", v->name); - else - json_vrf = json_object_new_object(); - - if (interface) - pim_show_interfaces_single(v->info, vty, interface, - is_mlag, json_vrf); - else - pim_show_interfaces(v->info, vty, is_mlag, json_vrf); - - if (uj) - json_object_object_add(json_parent, v->name, json_vrf); - } - if (uj) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_interface_vrf_all_cmd_helper(vty, !!json, !!mlag, + interface); } DEFPY (show_ip_pim_join, @@ -2507,41 +2455,7 @@ DEFPY (show_ip_pim_join, "The Group\n" JSON_STR) { - pim_sgaddr sg = {0}; - struct vrf *v; - struct pim_instance *pim; - json_object *json_parent = NULL; - - 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 (!pim) { - vty_out(vty, "%% Unable to find pim instance\n"); - return CMD_WARNING; - } - - if (s_or_g.s_addr != INADDR_ANY) { - if (g.s_addr != INADDR_ANY) { - sg.src = s_or_g; - sg.grp = g; - } else - sg.grp = s_or_g; - } - - if (json) - json_parent = json_object_new_object(); - - pim_show_join(pim, vty, &sg, json_parent); - - if (json) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_join_cmd_helper(vrf, vty, s_or_g, g, json); } DEFPY (show_ip_pim_join_vrf_all, @@ -2554,28 +2468,7 @@ DEFPY (show_ip_pim_join_vrf_all, "PIM interface join information\n" JSON_STR) { - pim_sgaddr sg = {0}; - struct vrf *vrf_struct; - json_object *json_parent = NULL; - json_object *json_vrf = NULL; - - if (json) - json_parent = json_object_new_object(); - RB_FOREACH (vrf_struct, vrf_name_head, &vrfs_by_name) { - if (!json) - vty_out(vty, "VRF: %s\n", vrf_struct->name); - else - json_vrf = json_object_new_object(); - pim_show_join(vrf_struct->info, vty, &sg, json_vrf); - - if (json) - json_object_object_add(json_parent, vrf_struct->name, - json_vrf); - } - if (json) - vty_json(vty, json_parent); - - return CMD_WARNING; + return pim_show_join_vrf_all_cmd_helper(vty, json); } DEFPY (show_ip_pim_jp_agg, @@ -2587,25 +2480,7 @@ DEFPY (show_ip_pim_jp_agg, VRF_CMD_HELP_STR "join prune aggregation list\n") { - struct vrf *v; - struct pim_instance *pim; - - 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 (!pim) { - vty_out(vty, "%% Unable to find pim instance\n"); - return CMD_WARNING; - } - - pim_show_jp_agg_list(pim, vty); - - return CMD_SUCCESS; + return pim_show_jp_agg_list_cmd_helper(vrf, vty); } DEFPY (show_ip_pim_local_membership, @@ -2618,17 +2493,7 @@ DEFPY (show_ip_pim_local_membership, "PIM interface local-membership\n" JSON_STR) { - struct vrf *v; - bool uj = !!json; - - v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); - - if (!v) - return CMD_WARNING; - - pim_show_membership(v->info, vty, uj); - - return CMD_SUCCESS; + return pim_show_membership_cmd_helper(vrf, vty, !!json); } static void pim_show_mlag_up_entry_detail(struct vrf *vrf, @@ -2910,26 +2775,7 @@ DEFPY (show_ip_pim_neighbor, "Name of interface or neighbor\n" JSON_STR) { - struct vrf *v; - json_object *json_parent = NULL; - - v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); - - if (!v) - return CMD_WARNING; - - if (json) - json_parent = json_object_new_object(); - - if (interface) - pim_show_neighbors_single(v->info, vty, interface, json_parent); - else - pim_show_neighbors(v->info, vty, json_parent); - - if (json) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_neighbors_cmd_helper(vrf, vty, json, interface); } DEFPY (show_ip_pim_neighbor_vrf_all, @@ -2944,31 +2790,7 @@ DEFPY (show_ip_pim_neighbor_vrf_all, "Name of interface or neighbor\n" JSON_STR) { - struct vrf *v; - json_object *json_parent = NULL; - json_object *json_vrf = NULL; - - if (json) - json_parent = json_object_new_object(); - RB_FOREACH (v, vrf_name_head, &vrfs_by_name) { - if (!json) - vty_out(vty, "VRF: %s\n", v->name); - else - json_vrf = json_object_new_object(); - - if (interface) - pim_show_neighbors_single(v->info, vty, interface, - json_vrf); - else - pim_show_neighbors(v->info, vty, json_vrf); - - if (json) - json_object_object_add(json_parent, v->name, json_vrf); - } - if (json) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_neighbors_vrf_all_cmd_helper(vty, json, interface); } DEFPY (show_ip_pim_secondary, @@ -2980,24 +2802,7 @@ DEFPY (show_ip_pim_secondary, VRF_CMD_HELP_STR "PIM neighbor addresses\n") { - struct pim_instance *pim; - struct vrf *v; - - 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; - } - - pim_show_neighbors_secondary(pim, vty); - - return CMD_SUCCESS; + return pim_show_secondary_helper(vrf, vty); } DEFPY (show_ip_pim_state, @@ -3012,31 +2817,7 @@ DEFPY (show_ip_pim_state, "Multicast address\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(); - - pim_show_state(pim, vty, s_or_g_str, g_str, json_parent); - - if (json) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_state_helper(vrf, vty, s_or_g_str, g_str, !!json); } DEFPY (show_ip_pim_state_vrf_all, @@ -3051,27 +2832,7 @@ DEFPY (show_ip_pim_state_vrf_all, "Multicast address\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(); - pim_show_state(vrf->info, vty, s_or_g_str, g_str, json_vrf); - if (json) - json_object_object_add(json_parent, vrf->name, - json_vrf); - } - if (json) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_state_vrf_all_helper(vty, s_or_g_str, g_str, !!json); } DEFPY (show_ip_pim_upstream, @@ -3086,41 +2847,7 @@ DEFPY (show_ip_pim_upstream, "The Group\n" JSON_STR) { - pim_sgaddr sg = {0}; - struct vrf *v; - bool uj = !!json; - struct pim_instance *pim; - json_object *json_parent = NULL; - - 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 (!pim) { - vty_out(vty, "%% Unable to find pim instance\n"); - return CMD_WARNING; - } - - if (uj) - json_parent = json_object_new_object(); - - if (s_or_g.s_addr != INADDR_ANY) { - if (g.s_addr != INADDR_ANY) { - sg.src = s_or_g; - sg.grp = g; - } else - sg.grp = s_or_g; - } - pim_show_upstream(pim, vty, &sg, json_parent); - - if (uj) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_upstream_helper(vrf, vty, s_or_g, g, !!json); } DEFPY (show_ip_pim_upstream_vrf_all, @@ -3133,29 +2860,7 @@ DEFPY (show_ip_pim_upstream_vrf_all, "PIM upstream information\n" JSON_STR) { - pim_sgaddr sg = {0}; - 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(); - pim_show_upstream(vrf->info, vty, &sg, json_vrf); - if (json) - json_object_object_add(json_parent, vrf->name, - json_vrf); - } - - if (json) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_upstream_vrf_all_helper(vty, !!json); } DEFPY (show_ip_pim_channel, @@ -3168,17 +2873,7 @@ DEFPY (show_ip_pim_channel, "PIM downstream channel info\n" JSON_STR) { - struct vrf *v; - bool uj = !!json; - - v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); - - if (!v) - return CMD_WARNING; - - pim_show_channel(v->info, vty, uj); - - return CMD_SUCCESS; + return pim_show_channel_cmd_helper(vrf, vty, !!json); } DEFPY (show_ip_pim_upstream_join_desired, @@ -3191,25 +2886,7 @@ DEFPY (show_ip_pim_upstream_join_desired, "PIM upstream join-desired\n" JSON_STR) { - struct pim_instance *pim; - struct vrf *v; - bool uj = !!json; - - 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; - } - - pim_show_join_desired(pim, vty, uj); - - return CMD_SUCCESS; + return pim_show_upstream_join_desired_helper(vrf, vty, !!json); } DEFPY (show_ip_pim_upstream_rpf, @@ -3222,25 +2899,7 @@ DEFPY (show_ip_pim_upstream_rpf, "PIM upstream source rpf\n" JSON_STR) { - struct pim_instance *pim; - struct vrf *v; - bool uj = !!json; - - 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; - } - - pim_show_upstream_rpf(pim, vty, uj); - - return CMD_SUCCESS; + return pim_show_upstream_rpf_helper(vrf, vty, !!json); } DEFPY (show_ip_pim_rp, @@ -3254,40 +2913,8 @@ DEFPY (show_ip_pim_rp, "Multicast Group range\n" JSON_STR) { - struct pim_instance *pim; - struct vrf *v; - json_object *json_parent = NULL; - struct prefix *range = 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 (group_str) { - range = prefix_new(); - prefix_copy(range, group); - apply_mask(range); - } - - if (json) - json_parent = json_object_new_object(); - - pim_rp_show_information(pim, range, vty, json_parent); - - if (json) - vty_json(vty, json_parent); - - prefix_free(&range); - - return CMD_SUCCESS; + return pim_show_rp_helper(vrf, vty, group_str, (struct prefix *)group, + !!json); } DEFPY (show_ip_pim_rp_vrf_all, @@ -3301,36 +2928,8 @@ DEFPY (show_ip_pim_rp_vrf_all, "Multicast Group range\n" JSON_STR) { - struct vrf *vrf; - json_object *json_parent = NULL; - json_object *json_vrf = NULL; - struct prefix *range = NULL; - - if (group_str) { - range = prefix_new(); - prefix_copy(range, group); - apply_mask(range); - } - - 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(); - pim_rp_show_information(vrf->info, range, vty, json_vrf); - if (json) - json_object_object_add(json_parent, vrf->name, - json_vrf); - } - if (json) - vty_json(vty, json_parent); - - prefix_free(&range); - - return CMD_SUCCESS; + return pim_show_rp_vrf_all_helper(vty, group_str, + (struct prefix *)group, !!json); } DEFPY (show_ip_pim_rpf, @@ -3343,31 +2942,7 @@ DEFPY (show_ip_pim_rpf, "PIM cached source rpf information\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(); - - pim_show_rpf(pim, vty, json_parent); - - if (json) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_rpf_helper(vrf, vty, !!json); } DEFPY (show_ip_pim_rpf_vrf_all, @@ -3380,27 +2955,7 @@ DEFPY (show_ip_pim_rpf_vrf_all, "PIM cached source rpf information\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(); - pim_show_rpf(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; + return pim_show_rpf_vrf_all_helper(vty, !!json); } DEFPY (show_ip_pim_nexthop, @@ -3412,16 +2967,7 @@ DEFPY (show_ip_pim_nexthop, VRF_CMD_HELP_STR "PIM cached nexthop rpf information\n") { - struct vrf *v; - - v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); - - if (!v) - return CMD_WARNING; - - pim_show_nexthop(v->info, vty); - - return CMD_SUCCESS; + return pim_show_nexthop_cmd_helper(vrf, vty); } DEFPY (show_ip_pim_nexthop_lookup, @@ -3435,49 +2981,7 @@ DEFPY (show_ip_pim_nexthop_lookup, "Source/RP address\n" "Multicast Group address\n") { - struct prefix nht_p; - int result = 0; - pim_addr vif_source; - struct prefix grp; - struct pim_nexthop nexthop; - struct vrf *v; - - v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); - - if (!v) - return CMD_WARNING; - - if (pim_is_group_224_4(source)) { - vty_out(vty, - "Invalid argument. Expected Valid Source Address.\n"); - return CMD_WARNING; - } - - if (!pim_is_group_224_4(group)) { - vty_out(vty, - "Invalid argument. Expected Valid Multicast Group Address.\n"); - return CMD_WARNING; - } - - if (!pim_rp_set_upstream_addr(v->info, &vif_source, source, group)) - return CMD_SUCCESS; - - pim_addr_to_prefix(&nht_p, vif_source); - pim_addr_to_prefix(&grp, group); - memset(&nexthop, 0, sizeof(nexthop)); - - result = pim_ecmp_nexthop_lookup(v->info, &nexthop, &nht_p, &grp, 0); - - if (!result) { - vty_out(vty, - "Nexthop Lookup failed, no usable routes returned.\n"); - return CMD_SUCCESS; - } - - vty_out(vty, "Group %s --- Nexthop %pPAs Interface %s \n", group_str, - &nexthop.mrib_nexthop_addr, nexthop.interface->name); - - return CMD_SUCCESS; + return pim_show_nexthop_lookup_cmd_helper(vrf, vty, source, group); } DEFUN (show_ip_pim_interface_traffic, @@ -3563,28 +3067,7 @@ DEFPY (show_ip_pim_statistics, "PIM interface\n" JSON_STR) { - struct pim_instance *pim; - struct vrf *v; - bool uj = !!json; - - 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 (word) - pim_show_statistics(pim, vty, word, uj); - else - pim_show_statistics(pim, vty, NULL, uj); - - return CMD_SUCCESS; + return pim_show_statistics_helper(vrf, vty, word, !!json); } DEFPY (show_ip_multicast, @@ -3595,24 +3078,7 @@ DEFPY (show_ip_multicast, "Multicast global information\n" VRF_CMD_HELP_STR) { - struct vrf *v; - struct pim_instance *pim; - - 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; - } - - pim_cmd_show_ip_multicast_helper(pim, vty); - - return CMD_SUCCESS; + return pim_show_multicast_helper(vrf, vty); } DEFPY (show_ip_multicast_vrf_all, @@ -3623,14 +3089,7 @@ DEFPY (show_ip_multicast_vrf_all, "Multicast global information\n" VRF_CMD_HELP_STR) { - struct vrf *vrf; - - RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { - vty_out(vty, "VRF: %s\n", vrf->name); - pim_cmd_show_ip_multicast_helper(vrf->info, vty); - } - - return CMD_SUCCESS; + return pim_show_multicast_vrf_all_helper(vty); } DEFPY (show_ip_multicast_count, @@ -3643,31 +3102,7 @@ DEFPY (show_ip_multicast_count, VRF_CMD_HELP_STR 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_multicast_interfaces(pim, vty, json_parent); - - if (json) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_multicast_count_helper(vrf, vty, !!json); } DEFPY (show_ip_multicast_count_vrf_all, @@ -3680,28 +3115,7 @@ DEFPY (show_ip_multicast_count_vrf_all, VRF_CMD_HELP_STR 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_multicast_interfaces(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; + return pim_show_multicast_count_vrf_all_helper(vty, !!json); } DEFPY (show_ip_mroute, @@ -3716,40 +3130,7 @@ DEFPY (show_ip_mroute, "Fill in Assumed data\n" JSON_STR) { - pim_sgaddr sg = {0}; - 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(); - - if (s_or_g.s_addr != INADDR_ANY) { - if (g.s_addr != INADDR_ANY) { - sg.src = s_or_g; - sg.grp = g; - } else - sg.grp = s_or_g; - } - - show_mroute(pim, vty, &sg, !!fill, json_parent); - - if (json) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_mroute_helper(vrf, vty, s_or_g, g, !!fill, !!json); } DEFPY (show_ip_mroute_vrf_all, @@ -3762,28 +3143,7 @@ DEFPY (show_ip_mroute_vrf_all, "Fill in Assumed data\n" JSON_STR) { - pim_sgaddr sg = {0}; - 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(vrf->info, vty, &sg, !!fill, json_vrf); - if (json) - json_object_object_add(json_parent, vrf->name, - json_vrf); - } - if (json) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_mroute_vrf_all_helper(vty, !!fill, !!json); } DEFPY (clear_ip_mroute_count, @@ -3808,31 +3168,7 @@ DEFPY (show_ip_mroute_count, "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; + return pim_show_mroute_count_helper(vrf, vty, !!json); } DEFPY (show_ip_mroute_count_vrf_all, @@ -3845,29 +3181,7 @@ DEFPY (show_ip_mroute_count_vrf_all, "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; + return pim_show_mroute_count_vrf_all_helper(vty, !!json); } DEFPY (show_ip_mroute_summary, @@ -3880,31 +3194,7 @@ DEFPY (show_ip_mroute_summary, "Summary of all mroutes\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_summary(pim, vty, json_parent); - - if (json) - vty_json(vty, json_parent); - - return CMD_SUCCESS; + return pim_show_mroute_summary_helper(vrf, vty, !!json); } DEFPY (show_ip_mroute_summary_vrf_all, @@ -3917,30 +3207,7 @@ DEFPY (show_ip_mroute_summary_vrf_all, "Summary of all mroutes\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_summary(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; + return pim_show_mroute_summary_vrf_all_helper(vty, !!json); } DEFUN (show_ip_rib, |
