diff options
Diffstat (limited to 'pimd/pim_cmd.c')
| -rw-r--r-- | pimd/pim_cmd.c | 218 |
1 files changed, 162 insertions, 56 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 3b3d06e791..2a6d03fb91 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -455,8 +455,7 @@ static void pim_show_membership(struct pim_instance *pim, struct vty *vty, json_object_free(json); } -static void pim_print_ifp_flags(struct vty *vty, struct interface *ifp, - int mloop) +static void pim_print_ifp_flags(struct vty *vty, struct interface *ifp) { vty_out(vty, "Flags\n"); vty_out(vty, "-----\n"); @@ -469,7 +468,6 @@ static void pim_print_ifp_flags(struct vty *vty, struct interface *ifp, vty_out(vty, "Interface Index : %d\n", ifp->ifindex); vty_out(vty, "Multicast : %s\n", if_is_multicast(ifp) ? "yes" : "no"); - vty_out(vty, "Multicast Loop : %d\n", mloop); vty_out(vty, "Promiscuous : %s\n", (ifp->flags & IFF_PROMISC) ? "yes" : "no"); vty_out(vty, "\n"); @@ -576,7 +574,6 @@ static void igmp_show_interfaces_single(struct pim_instance *pim, char other_hhmmss[10]; int found_ifname = 0; int sqi; - int mloop = 0; long gmi_msec; /* Group Membership Interval */ long lmqt_msec; long ohpi_msec; @@ -639,11 +636,6 @@ static void igmp_show_interfaces_single(struct pim_instance *pim, qri_msec = pim_ifp->gm_query_max_response_time_dsec * 100; - if (pim_ifp->pim_sock_fd >= 0) - mloop = pim_socket_mcastloop_get( - pim_ifp->pim_sock_fd); - else - mloop = 0; lmqc = pim_ifp->gm_last_member_query_count; if (uj) { @@ -776,7 +768,7 @@ static void igmp_show_interfaces_single(struct pim_instance *pim, vty_out(vty, "\n"); vty_out(vty, "\n"); - pim_print_ifp_flags(vty, ifp, mloop); + pim_print_ifp_flags(vty, ifp); } } } @@ -903,7 +895,6 @@ static void pim_show_interfaces_single(struct pim_instance *pim, char src_str[INET_ADDRSTRLEN]; char stat_uptime[10]; char uptime[10]; - int mloop = 0; int found_ifname = 0; int print_header; json_object *json = NULL; @@ -945,10 +936,6 @@ static void pim_show_interfaces_single(struct pim_instance *pim, pim_ifp->pim_hello_period); pim_time_uptime(stat_uptime, sizeof(stat_uptime), now - pim_ifp->pim_ifstat_start); - if (pim_ifp->pim_sock_fd >= 0) - mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd); - else - mloop = 0; if (uj) { char pbuf[PREFIX2STR_BUFFER]; @@ -1096,8 +1083,6 @@ static void pim_show_interfaces_single(struct pim_instance *pim, pim_ifp->pim_ifstat_hello_sendfail); json_object_int_add(json_row, "helloGenerationId", pim_ifp->pim_generation_id); - json_object_int_add(json_row, "flagMulticastLoop", - mloop); json_object_int_add( json_row, "effectivePropagationDelay", @@ -1250,7 +1235,7 @@ static void pim_show_interfaces_single(struct pim_instance *pim, vty_out(vty, "\n"); vty_out(vty, "\n"); - pim_print_ifp_flags(vty, ifp, mloop); + pim_print_ifp_flags(vty, ifp); vty_out(vty, "Join Prune Interval\n"); vty_out(vty, "-------------------\n"); @@ -1299,14 +1284,21 @@ static void igmp_show_statistics(struct pim_instance *pim, struct vty *vty, const char *ifname, bool uj) { struct interface *ifp; - struct igmp_stats rx_stats; + struct igmp_stats igmp_stats; + bool found_ifname = false; + json_object *json = NULL; - igmp_stats_init(&rx_stats); + igmp_stats_init(&igmp_stats); + + if (uj) + json = json_object_new_object(); FOR_ALL_INTERFACES (pim->vrf, ifp) { struct pim_interface *pim_ifp; - struct listnode *sock_node; + struct listnode *sock_node, *source_node, *group_node; struct gm_sock *igmp; + struct gm_group *group; + struct gm_source *src; pim_ifp = ifp->info; @@ -1316,50 +1308,119 @@ static void igmp_show_statistics(struct pim_instance *pim, struct vty *vty, if (ifname && strcmp(ifname, ifp->name)) continue; + found_ifname = true; + + igmp_stats.joins_failed += pim_ifp->igmp_ifstat_joins_failed; + igmp_stats.joins_sent += pim_ifp->igmp_ifstat_joins_sent; + igmp_stats.total_groups += + pim_ifp->gm_group_list + ? listcount(pim_ifp->gm_group_list) + : 0; + igmp_stats.peak_groups += pim_ifp->igmp_peak_group_count; + + + for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_group_list, group_node, + group)) { + for (ALL_LIST_ELEMENTS_RO(group->group_source_list, + source_node, src)) { + if (pim_addr_is_any(src->source_addr)) + continue; + + igmp_stats.total_source_groups++; + } + } + for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_socket_list, sock_node, igmp)) { - igmp_stats_add(&rx_stats, &igmp->rx_stats); + igmp_stats_add(&igmp_stats, &igmp->igmp_stats); } } - if (uj) { - json_object *json = NULL; - json_object *json_row = NULL; - json = json_object_new_object(); - json_row = json_object_new_object(); + if (!found_ifname) { + if (uj) + vty_json(vty, json); + else + vty_out(vty, "%% No such interface\n"); + return; + } - json_object_string_add(json_row, "name", ifname ? ifname : - "global"); - json_object_int_add(json_row, "queryV1", rx_stats.query_v1); - json_object_int_add(json_row, "queryV2", rx_stats.query_v2); - json_object_int_add(json_row, "queryV3", rx_stats.query_v3); - json_object_int_add(json_row, "leaveV3", rx_stats.leave_v2); - json_object_int_add(json_row, "reportV1", rx_stats.report_v1); - json_object_int_add(json_row, "reportV2", rx_stats.report_v2); - json_object_int_add(json_row, "reportV3", rx_stats.report_v3); + if (uj) { + json_object *json_row = json_object_new_object(); + + json_object_string_add(json_row, "name", + ifname ? ifname : "global"); + json_object_int_add(json_row, "queryV1", igmp_stats.query_v1); + json_object_int_add(json_row, "queryV2", igmp_stats.query_v2); + json_object_int_add(json_row, "queryV3", igmp_stats.query_v3); + json_object_int_add(json_row, "leaveV2", igmp_stats.leave_v2); + json_object_int_add(json_row, "reportV1", igmp_stats.report_v1); + json_object_int_add(json_row, "reportV2", igmp_stats.report_v2); + json_object_int_add(json_row, "reportV3", igmp_stats.report_v3); json_object_int_add(json_row, "mtraceResponse", - rx_stats.mtrace_rsp); + igmp_stats.mtrace_rsp); json_object_int_add(json_row, "mtraceRequest", - rx_stats.mtrace_req); + igmp_stats.mtrace_req); json_object_int_add(json_row, "unsupported", - rx_stats.unsupported); + igmp_stats.unsupported); + json_object_int_add(json_row, "totalReceivedMessages", + igmp_stats.total_recv_messages); + json_object_int_add(json_row, "peakGroups", + igmp_stats.peak_groups); + json_object_int_add(json_row, "totalGroups", + igmp_stats.total_groups); + json_object_int_add(json_row, "totalSourceGroups", + igmp_stats.total_source_groups); + json_object_int_add(json_row, "joinsFailed", + igmp_stats.joins_failed); + json_object_int_add(json_row, "joinsSent", + igmp_stats.joins_sent); + json_object_int_add(json_row, "generalQueriesSent", + igmp_stats.general_queries_sent); + json_object_int_add(json_row, "groupQueriesSent", + igmp_stats.group_queries_sent); json_object_object_add(json, ifname ? ifname : "global", json_row); vty_json(vty, json); } else { - vty_out(vty, "IGMP RX statistics\n"); - vty_out(vty, "Interface : %s\n", + vty_out(vty, "IGMP statistics\n"); + vty_out(vty, "Interface : %s\n", ifname ? ifname : "global"); - vty_out(vty, "V1 query : %u\n", rx_stats.query_v1); - vty_out(vty, "V2 query : %u\n", rx_stats.query_v2); - vty_out(vty, "V3 query : %u\n", rx_stats.query_v3); - vty_out(vty, "V2 leave : %u\n", rx_stats.leave_v2); - vty_out(vty, "V1 report : %u\n", rx_stats.report_v1); - vty_out(vty, "V2 report : %u\n", rx_stats.report_v2); - vty_out(vty, "V3 report : %u\n", rx_stats.report_v3); - vty_out(vty, "mtrace response : %u\n", rx_stats.mtrace_rsp); - vty_out(vty, "mtrace request : %u\n", rx_stats.mtrace_req); - vty_out(vty, "unsupported : %u\n", rx_stats.unsupported); + vty_out(vty, "V1 query : %u\n", + igmp_stats.query_v1); + vty_out(vty, "V2 query : %u\n", + igmp_stats.query_v2); + vty_out(vty, "V3 query : %u\n", + igmp_stats.query_v3); + vty_out(vty, "V2 leave : %u\n", + igmp_stats.leave_v2); + vty_out(vty, "V1 report : %u\n", + igmp_stats.report_v1); + vty_out(vty, "V2 report : %u\n", + igmp_stats.report_v2); + vty_out(vty, "V3 report : %u\n", + igmp_stats.report_v3); + vty_out(vty, "mtrace response : %u\n", + igmp_stats.mtrace_rsp); + vty_out(vty, "mtrace request : %u\n", + igmp_stats.mtrace_req); + vty_out(vty, "unsupported : %u\n", + igmp_stats.unsupported); + vty_out(vty, "total received messages : %u\n", + igmp_stats.total_recv_messages); + vty_out(vty, "joins failed : %u\n", + igmp_stats.joins_failed); + vty_out(vty, "joins sent : %u\n", + igmp_stats.joins_sent); + vty_out(vty, "general queries sent : %u\n", + igmp_stats.general_queries_sent); + vty_out(vty, "group queries sent : %u\n", + igmp_stats.group_queries_sent); + vty_out(vty, "peak groups : %u\n", + igmp_stats.peak_groups); + vty_out(vty, "total groups : %u\n", + igmp_stats.total_groups); + vty_out(vty, "total source groups : %u\n", + igmp_stats.total_source_groups); } } @@ -1686,8 +1747,13 @@ static void pim_show_join_helper(struct vty *vty, struct pim_interface *pim_ifp, json_object_string_add( json_row, "channelJoinName", pim_ifchannel_ifjoin_name(ch->ifjoin_state, ch->flags)); - if (PIM_IF_FLAG_TEST_S_G_RPT(ch->flags)) + if (PIM_IF_FLAG_TEST_S_G_RPT(ch->flags)) { +#if CONFDATE > 20230131 +CPP_NOTICE("Remove JSON object commands with keys starting with capital") +#endif json_object_int_add(json_row, "SGRpt", 1); + json_object_int_add(json_row, "sgRpt", 1); + } if (PIM_IF_FLAG_TEST_PROTO_PIM(ch->flags)) json_object_int_add(json_row, "protocolPim", 1); if (PIM_IF_FLAG_TEST_PROTO_IGMP(ch->flags)) @@ -2037,6 +2103,8 @@ static void pim_show_state(struct pim_instance *pim, struct vty *vty, json_ifp_in); json_object_int_add(json_source, "Installed", c_oil->installed); + json_object_int_add(json_source, "installed", + c_oil->installed); if (isRpt) json_object_boolean_true_add( json_source, "isRpt"); @@ -2045,20 +2113,36 @@ static void pim_show_state(struct pim_instance *pim, struct vty *vty, json_source, "isRpt"); json_object_int_add(json_source, "RefCount", c_oil->oil_ref_count); + json_object_int_add(json_source, "refCount", + c_oil->oil_ref_count); json_object_int_add(json_source, "OilListSize", c_oil->oil_size); + json_object_int_add(json_source, "oilListSize", + c_oil->oil_size); json_object_int_add( json_source, "OilRescan", c_oil->oil_inherited_rescan); + json_object_int_add( + json_source, "oilRescan", + c_oil->oil_inherited_rescan); json_object_int_add(json_source, "LastUsed", c_oil->cc.lastused); + json_object_int_add(json_source, "lastUsed", + c_oil->cc.lastused); json_object_int_add(json_source, "PacketCount", c_oil->cc.pktcnt); + json_object_int_add(json_source, "packetCount", + c_oil->cc.pktcnt); json_object_int_add(json_source, "ByteCount", c_oil->cc.bytecnt); + json_object_int_add(json_source, "byteCount", + c_oil->cc.bytecnt); json_object_int_add(json_source, "WrongInterface", c_oil->cc.wrong_if); + json_object_int_add(json_source, + "wrongInterface", + c_oil->cc.wrong_if); } } else { vty_out(vty, "%-6d %-15s %-15s %-3s %-16s ", @@ -3983,6 +4067,9 @@ DEFUN (clear_ip_pim_interface_traffic, pim_ifp->pim_ifstat_assert_send = 0; pim_ifp->pim_ifstat_bsm_rx = 0; pim_ifp->pim_ifstat_bsm_tx = 0; + pim_ifp->igmp_ifstat_joins_sent = 0; + pim_ifp->igmp_ifstat_joins_failed = 0; + pim_ifp->igmp_peak_group_count = 0; } return CMD_SUCCESS; @@ -5313,39 +5400,56 @@ DEFUN (show_ip_pim_upstream_rpf, DEFUN (show_ip_pim_rp, show_ip_pim_rp_cmd, - "show ip pim [vrf NAME] rp-info [json]", + "show ip pim [vrf NAME] rp-info [A.B.C.D/M] [json]", SHOW_STR IP_STR PIM_STR VRF_CMD_HELP_STR "PIM RP information\n" + "Multicast Group range\n" JSON_STR) { int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); bool uj = use_json(argc, argv); + struct prefix *range = NULL; if (!vrf) return CMD_WARNING; - pim_rp_show_information(vrf->info, vty, uj); + if (argv_find(argv, argc, "A.B.C.D/M", &idx)) { + range = prefix_new(); + (void)str2prefix(argv[idx]->arg, range); + apply_mask(range); + } + + pim_rp_show_information(vrf->info, range, vty, uj); return CMD_SUCCESS; } DEFUN (show_ip_pim_rp_vrf_all, show_ip_pim_rp_vrf_all_cmd, - "show ip pim vrf all rp-info [json]", + "show ip pim vrf all rp-info [A.B.C.D/M] [json]", SHOW_STR IP_STR PIM_STR VRF_CMD_HELP_STR "PIM RP information\n" + "Multicast Group range\n" JSON_STR) { + int idx = 0; bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; + struct prefix *range = NULL; + + if (argv_find(argv, argc, "A.B.C.D/M", &idx)) { + range = prefix_new(); + (void)str2prefix(argv[idx]->arg, range); + apply_mask(range); + } if (uj) vty_out(vty, "{ "); @@ -5357,7 +5461,7 @@ DEFUN (show_ip_pim_rp_vrf_all, first = false; } else vty_out(vty, "VRF: %s\n", vrf->name); - pim_rp_show_information(vrf->info, vty, uj); + pim_rp_show_information(vrf->info, range, vty, uj); } if (uj) vty_out(vty, "}\n"); @@ -5960,6 +6064,8 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, c_oil->oil_size); json_object_int_add(json_source, "OilInheritedRescan", c_oil->oil_inherited_rescan); + json_object_int_add(json_source, "oilInheritedRescan", + c_oil->oil_inherited_rescan); json_object_string_add(json_source, "iif", in_ifname); json_object_string_add(json_source, "upTime", mroute_uptime); |
