]> git.proxmox.com Git - mirror_frr.git/commitdiff
pimd: Add IGMP total groups and total source groups to statistics
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 8 Mar 2022 16:34:34 +0000 (18:34 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 8 Mar 2022 17:07:57 +0000 (19:07 +0200)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
pimd/pim_cmd.c
pimd/pim_igmp_stats.c
pimd/pim_igmp_stats.h

index 3b3d06e791116e081bf1206be65deae2f39b1404..a9b57cabbe75e5e26f28ccb09c4c9341a193ac73 100644 (file)
@@ -1305,8 +1305,10 @@ static void igmp_show_statistics(struct pim_instance *pim, struct vty *vty,
 
        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,6 +1318,22 @@ static void igmp_show_statistics(struct pim_instance *pim, struct vty *vty,
                if (ifname && strcmp(ifname, ifp->name))
                        continue;
 
+               rx_stats.total_groups +=
+                       pim_ifp->gm_group_list
+                               ? listcount(pim_ifp->gm_group_list)
+                               : 0;
+
+               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;
+
+                               rx_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);
@@ -1343,6 +1361,10 @@ static void igmp_show_statistics(struct pim_instance *pim, struct vty *vty,
                                    rx_stats.mtrace_req);
                json_object_int_add(json_row, "unsupported",
                                    rx_stats.unsupported);
+               json_object_int_add(json_row, "totalGroups",
+                                   rx_stats.total_groups);
+               json_object_int_add(json_row, "totalSourceGroups",
+                                   rx_stats.total_source_groups);
                json_object_object_add(json, ifname ? ifname : "global",
                                       json_row);
                vty_json(vty, json);
@@ -1350,16 +1372,21 @@ static void igmp_show_statistics(struct pim_instance *pim, struct vty *vty,
                vty_out(vty, "IGMP RX 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", 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, "total groups        : %u\n",
+                       rx_stats.total_groups);
+               vty_out(vty, "total source groups : %u\n",
+                       rx_stats.total_source_groups);
        }
 }
 
index 40851a45299a356f05b7706b099c870c23158874..0cf1bb1ec130e79ad1a1315c36335fb03d5908f1 100644 (file)
@@ -43,4 +43,6 @@ void igmp_stats_add(struct igmp_stats *a, struct igmp_stats *b)
        a->mtrace_rsp += b->mtrace_rsp;
        a->mtrace_req += b->mtrace_req;
        a->unsupported += b->unsupported;
+       a->total_groups += b->total_groups;
+       a->total_source_groups += b->total_source_groups;
 }
index a70a4335579e5f2e8901aee5eca4408f8ab29ecf..47167efb3abca716d92fd912740338d2c4f499e5 100644 (file)
@@ -33,6 +33,8 @@ struct igmp_stats {
        uint32_t        mtrace_rsp;
        uint32_t        mtrace_req;
        uint32_t        unsupported;
+       uint32_t        total_groups;
+       uint32_t        total_source_groups;
 };
 
 #if PIM_IPV == 4