Skip to content

Commit

Permalink
Merge pull request FRRouting#10788 from opensourcerouting/feature/igm…
Browse files Browse the repository at this point in the history
…p_stats_queries_sent

pimd: Add additional IGMP stats (generic/group specific queries sent)
  • Loading branch information
donaldsharp authored Mar 14, 2022
2 parents 6c72dd8 + 278912e commit 2283482
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 67 deletions.
42 changes: 27 additions & 15 deletions pimd/pim_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1356,36 +1356,48 @@ static void igmp_show_statistics(struct pim_instance *pim, struct vty *vty,
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 statistics\n");
vty_out(vty, "Interface : %s\n",
vty_out(vty, "Interface : %s\n",
ifname ? ifname : "global");
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",
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",
vty_out(vty, "V2 report : %u\n",
igmp_stats.report_v2);
vty_out(vty, "V3 report : %u\n",
vty_out(vty, "V3 report : %u\n",
igmp_stats.report_v3);
vty_out(vty, "mtrace response : %u\n",
vty_out(vty, "mtrace response : %u\n",
igmp_stats.mtrace_rsp);
vty_out(vty, "mtrace request : %u\n",
vty_out(vty, "mtrace request : %u\n",
igmp_stats.mtrace_req);
vty_out(vty, "unsupported : %u\n",
vty_out(vty, "unsupported : %u\n",
igmp_stats.unsupported);
vty_out(vty, "joins failed : %u\n",
vty_out(vty, "joins failed : %u\n",
igmp_stats.joins_failed);
vty_out(vty, "joins sent : %u\n",
vty_out(vty, "joins sent : %u\n",
igmp_stats.joins_sent);
vty_out(vty, "total groups : %u\n",
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, "total groups : %u\n",
igmp_stats.total_groups);
vty_out(vty, "total source groups : %u\n",
vty_out(vty, "total source groups : %u\n",
igmp_stats.total_source_groups);
}
}
Expand Down
54 changes: 27 additions & 27 deletions pimd/pim_igmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,13 +909,10 @@ static void pim_igmp_general_query(struct thread *t)
querier_str, dst_str, igmp->interface->name);
}

igmp_send_query(pim_ifp->igmp_version, 0 /* igmp_group */, igmp->fd,
igmp->interface->name, query_buf, sizeof(query_buf),
0 /* num_sources */, dst_addr, group_addr,
pim_ifp->gm_query_max_response_time_dsec,
1 /* s_flag: always set for general queries */,
igmp->querier_robustness_variable,
igmp->querier_query_interval);
igmp_send_query(pim_ifp->igmp_version, 0 /* igmp_group */, query_buf,
sizeof(query_buf), 0 /* num_sources */, dst_addr,
group_addr, pim_ifp->gm_query_max_response_time_dsec,
1 /* s_flag: always set for general queries */, igmp);

pim_igmp_general_query_on(igmp);
}
Expand Down Expand Up @@ -1454,23 +1451,29 @@ struct gm_group *igmp_add_group_by_addr(struct gm_sock *igmp,
return group;
}

void igmp_send_query(int igmp_version, struct gm_group *group, int fd,
const char *ifname, char *query_buf, int query_buf_size,
int num_sources, struct in_addr dst_addr,
struct in_addr group_addr,
void igmp_send_query(int igmp_version, struct gm_group *group, char *query_buf,
int query_buf_size, int num_sources,
struct in_addr dst_addr, struct in_addr group_addr,
int query_max_response_time_dsec, uint8_t s_flag,
uint8_t querier_robustness_variable,
uint16_t querier_query_interval)
struct gm_sock *igmp)
{
if (pim_addr_is_any(group_addr) &&
ntohl(dst_addr.s_addr) == INADDR_ALLHOSTS_GROUP)
igmp->igmp_stats.general_queries_sent++;
else if (group)
igmp->igmp_stats.group_queries_sent++;

if (igmp_version == 3) {
igmp_v3_send_query(group, fd, ifname, query_buf, query_buf_size,
num_sources, dst_addr, group_addr,
igmp_v3_send_query(group, igmp->fd, igmp->interface->name,
query_buf, query_buf_size, num_sources,
dst_addr, group_addr,
query_max_response_time_dsec, s_flag,
querier_robustness_variable,
querier_query_interval);
igmp->querier_robustness_variable,
igmp->querier_query_interval);
} else if (igmp_version == 2) {
igmp_v2_send_query(group, fd, ifname, query_buf, dst_addr,
group_addr, query_max_response_time_dsec);
igmp_v2_send_query(group, igmp->fd, igmp->interface->name,
query_buf, dst_addr, group_addr,
query_max_response_time_dsec);
}
}

Expand Down Expand Up @@ -1501,13 +1504,10 @@ void igmp_send_query_on_intf(struct interface *ifp, int igmp_ver)

char query_buf[query_buf_size];

igmp_send_query(igmp_ver, 0 /* igmp_group */, igmp->fd,
igmp->interface->name, query_buf,
sizeof(query_buf), 0 /* num_sources */,
dst_addr, group_addr,
pim_ifp->gm_query_max_response_time_dsec,
1 /* s_flag: always set for general queries */,
igmp->querier_robustness_variable,
igmp->querier_query_interval);
igmp_send_query(
igmp_ver, 0 /* igmp_group */, query_buf,
sizeof(query_buf), 0 /* num_sources */, dst_addr,
group_addr, pim_ifp->gm_query_max_response_time_dsec,
1 /* s_flag: always set for general queries */, igmp);
}
}
10 changes: 4 additions & 6 deletions pimd/pim_igmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,11 @@ void igmp_startup_mode_on(struct gm_sock *igmp);
void igmp_group_timer_on(struct gm_group *group, long interval_msec,
const char *ifname);

void igmp_send_query(int igmp_version, struct gm_group *group, int fd,
const char *ifname, char *query_buf, int query_buf_size,
int num_sources, struct in_addr dst_addr,
struct in_addr group_addr,
void igmp_send_query(int igmp_version, struct gm_group *group, char *query_buf,
int query_buf_size, int num_sources,
struct in_addr dst_addr, struct in_addr group_addr,
int query_max_response_time_dsec, uint8_t s_flag,
uint8_t querier_robustness_variable,
uint16_t querier_query_interval);
struct gm_sock *igmp);
void igmp_group_delete(struct gm_group *group);

void igmp_send_query_on_intf(struct interface *ifp, int igmp_ver);
Expand Down
2 changes: 2 additions & 0 deletions pimd/pim_igmp_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ void igmp_stats_add(struct igmp_stats *a, struct igmp_stats *b)
a->total_source_groups += b->total_source_groups;
a->joins_sent += b->joins_sent;
a->joins_failed += b->joins_failed;
a->general_queries_sent += b->general_queries_sent;
a->group_queries_sent += b->group_queries_sent;
}
30 changes: 16 additions & 14 deletions pimd/pim_igmp_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,22 @@
#include <zebra.h>

struct igmp_stats {
uint32_t query_v1;
uint32_t query_v2;
uint32_t query_v3;
uint32_t report_v1;
uint32_t report_v2;
uint32_t report_v3;
uint32_t leave_v2;
uint32_t mtrace_rsp;
uint32_t mtrace_req;
uint32_t unsupported;
uint32_t total_groups;
uint32_t total_source_groups;
uint32_t joins_sent;
uint32_t joins_failed;
uint32_t query_v1;
uint32_t query_v2;
uint32_t query_v3;
uint32_t report_v1;
uint32_t report_v2;
uint32_t report_v3;
uint32_t leave_v2;
uint32_t mtrace_rsp;
uint32_t mtrace_req;
uint32_t unsupported;
uint32_t total_groups;
uint32_t total_source_groups;
uint32_t joins_sent;
uint32_t joins_failed;
uint32_t general_queries_sent;
uint32_t group_queries_sent;
};

#if PIM_IPV == 4
Expand Down
8 changes: 3 additions & 5 deletions pimd/pim_igmpv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,12 +984,10 @@ static void igmp_send_query_group(struct gm_group *group, char *query_buf,

for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_socket_list, sock_node, igmp)) {
igmp_send_query(
pim_ifp->igmp_version, group, igmp->fd, ifp->name,
query_buf, query_buf_size, num_sources,
group->group_addr, group->group_addr,
pim_ifp->igmp_version, group, query_buf, query_buf_size,
num_sources, group->group_addr, group->group_addr,
pim_ifp->gm_specific_query_max_response_time_dsec,
s_flag, igmp->querier_robustness_variable,
igmp->querier_query_interval);
s_flag, igmp);
}
}

Expand Down

0 comments on commit 2283482

Please sign in to comment.