Skip to content

Commit

Permalink
pimd: Modifying members of igmp_sock and igmp_group to accommodate IP…
Browse files Browse the repository at this point in the history
…v6 changes

Modifying the members of igmp_sock and igmp_group  which are to be used
for both IPv4 and IPv6 to common names(for both MLD and IGMP).

Issue: FRRouting#10023

Co-authored-by: Mobashshera Rasool <[email protected]>
Signed-off-by: Abhishek N R <[email protected]>
  • Loading branch information
AbhishekNR and mobash-rasool committed Dec 3, 2021
1 parent 6afe9d4 commit 85733b8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 42 deletions.
35 changes: 18 additions & 17 deletions pimd/pim_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ static void igmp_show_interfaces(struct pim_instance *pim, struct vty *vty,
now - igmp->sock_creation);
pim_time_timer_to_hhmmss(query_hhmmss,
sizeof(query_hhmmss),
igmp->t_igmp_query_timer);
igmp->t_query_timer);

if (uj) {
json_row = json_object_new_object();
Expand All @@ -527,7 +527,7 @@ static void igmp_show_interfaces(struct pim_instance *pim, struct vty *vty,
json_object_int_add(json_row, "version",
pim_ifp->igmp_version);

if (igmp->t_igmp_query_timer) {
if (igmp->t_query_timer) {
json_object_boolean_true_add(json_row,
"querier");
json_object_string_add(json_row,
Expand Down Expand Up @@ -555,8 +555,8 @@ static void igmp_show_interfaces(struct pim_instance *pim, struct vty *vty,
: "down",
inet_ntop(AF_INET, &igmp->ifaddr, buf,
sizeof(buf)),
pim_ifp->igmp_version,
igmp->t_igmp_query_timer ? "local"
pim_ifp->version,
igmp->t_query_timer ? "local"
: "other",
&igmp->querier_addr, query_hhmmss,
uptime);
Expand Down Expand Up @@ -617,7 +617,7 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
now - igmp->sock_creation);
pim_time_timer_to_hhmmss(query_hhmmss,
sizeof(query_hhmmss),
igmp->t_igmp_query_timer);
igmp->t_query_timer);
pim_time_timer_to_hhmmss(other_hhmmss,
sizeof(other_hhmmss),
igmp->t_other_querier_timer);
Expand Down Expand Up @@ -661,9 +661,9 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
json_object_string_add(json_row, "upTime",
uptime);
json_object_string_add(json_row, "querier",
igmp->t_igmp_query_timer
? "local"
: "other");
igmp->t_query_timer
? "local"
: "other");
json_object_string_addf(json_row, "querierIp",
"%pI4",
&igmp->querier_addr);
Expand Down Expand Up @@ -734,8 +734,8 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
vty_out(vty, "Querier\n");
vty_out(vty, "-------\n");
vty_out(vty, "Querier : %s\n",
igmp->t_igmp_query_timer ? "local"
: "other");
igmp->t_query_timer ? "local"
: "other");
vty_out(vty, "QuerierIp : %pI4",
&igmp->querier_addr);
if (pim_ifp->primary_address.s_addr
Expand Down Expand Up @@ -3462,7 +3462,7 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj)
json_object_string_add(json_group, "group",
group_str);

if (grp->igmp_version == 3)
if (grp->version == 3)
json_object_string_add(
json_group, "mode",
grp->group_filtermode_isexcl
Expand All @@ -3477,23 +3477,24 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj)
grp->group_source_list)
: 0);
json_object_int_add(json_group, "version",
grp->igmp_version);
grp->version);
json_object_string_add(json_group, "uptime",
uptime);
json_object_array_add(json_groups, json_group);
} else {
vty_out(vty, "%-16s %-15s %4s %8s %4d %d %8s\n",
ifp->name, group_str,
grp->igmp_version == 3
grp->version == 3
? (grp->group_filtermode_isexcl
? "EXCL"
: "INCL")
: "----",
hhmmss,
grp->group_source_list ? listcount(
grp->group_source_list)
: 0,
grp->igmp_version, uptime);
grp->group_source_list
? listcount(
grp->group_source_list)
: 0,
grp->version, uptime);
}
} /* scan igmp groups */
} /* scan interfaces */
Expand Down
28 changes: 14 additions & 14 deletions pimd/pim_igmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static int pim_igmp_other_querier_expire(struct thread *t)

igmp = THREAD_ARG(t);

assert(!igmp->t_igmp_query_timer);
assert(!igmp->t_query_timer);

if (PIM_DEBUG_IGMP_TRACE) {
char ifaddr_str[INET_ADDRSTRLEN];
Expand Down Expand Up @@ -199,7 +199,7 @@ void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp)
} else {
/*
We are the current querier, then stop sending general queries:
igmp->t_igmp_query_timer = NULL;
igmp->t_query_timer = NULL;
*/
pim_igmp_general_query_off(igmp);
}
Expand All @@ -208,7 +208,7 @@ void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp)
Since this socket is starting the other-querier-present timer,
there should not be periodic query timer for this socket.
*/
assert(!igmp->t_igmp_query_timer);
assert(!igmp->t_query_timer);

/*
RFC 3376: 8.5. Other Querier Present Interval
Expand Down Expand Up @@ -660,15 +660,15 @@ void pim_igmp_general_query_on(struct igmp_sock *igmp)
startup_mode ? "startup" : "non-startup", igmp->fd);
}
thread_add_timer(router->master, pim_igmp_general_query, igmp,
query_interval, &igmp->t_igmp_query_timer);
query_interval, &igmp->t_query_timer);
}

void pim_igmp_general_query_off(struct igmp_sock *igmp)
{
assert(igmp);

if (PIM_DEBUG_IGMP_TRACE) {
if (igmp->t_igmp_query_timer) {
if (igmp->t_query_timer) {
char ifaddr_str[INET_ADDRSTRLEN];
pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str,
sizeof(ifaddr_str));
Expand All @@ -677,7 +677,7 @@ void pim_igmp_general_query_off(struct igmp_sock *igmp)
ifaddr_str, igmp->fd, igmp->interface->name);
}
}
THREAD_OFF(igmp->t_igmp_query_timer);
THREAD_OFF(igmp->t_query_timer);
}

/* Issue IGMP general query */
Expand Down Expand Up @@ -745,14 +745,14 @@ static void sock_close(struct igmp_sock *igmp)
pim_igmp_general_query_off(igmp);

if (PIM_DEBUG_IGMP_TRACE_DETAIL) {
if (igmp->t_igmp_read) {
if (igmp->t_gm_read) {
zlog_debug(
"Cancelling READ event on IGMP socket %pI4 fd=%d on interface %s",
&igmp->ifaddr, igmp->fd,
igmp->interface->name);
}
}
THREAD_OFF(igmp->t_igmp_read);
THREAD_OFF(igmp->t_gm_read);

if (close(igmp->fd)) {
flog_err(
Expand Down Expand Up @@ -859,8 +859,8 @@ void igmp_group_delete_empty_include(struct igmp_group *group)

void igmp_sock_free(struct igmp_sock *igmp)
{
assert(!igmp->t_igmp_read);
assert(!igmp->t_igmp_query_timer);
assert(!igmp->t_gm_read);
assert(!igmp->t_query_timer);
assert(!igmp->t_other_querier_timer);

XFREE(MTYPE_PIM_IGMP_SOCKET, igmp);
Expand Down Expand Up @@ -973,8 +973,8 @@ static struct igmp_sock *igmp_sock_new(int fd, struct in_addr ifaddr,
igmp->interface = ifp;
igmp->ifaddr = ifaddr;
igmp->querier_addr = ifaddr;
igmp->t_igmp_read = NULL;
igmp->t_igmp_query_timer = NULL;
igmp->t_gm_read = NULL;
igmp->t_query_timer = NULL;
igmp->t_other_querier_timer = NULL; /* no other querier present */
igmp->querier_robustness_variable =
pim_ifp->igmp_default_robustness_variable;
Expand Down Expand Up @@ -1039,7 +1039,7 @@ static void igmp_read_on(struct igmp_sock *igmp)
igmp->fd);
}
thread_add_read(router->master, pim_igmp_read, igmp, igmp->fd,
&igmp->t_igmp_read);
&igmp->t_gm_read);
}

struct igmp_sock *pim_igmp_sock_add(struct list *igmp_sock_list,
Expand Down Expand Up @@ -1241,7 +1241,7 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp,
group->last_igmp_v1_report_dsec = -1;
group->last_igmp_v2_report_dsec = -1;
group->group_creation = pim_time_monotonic_sec();
group->igmp_version = IGMP_DEFAULT_VERSION;
group->version = IGMP_DEFAULT_VERSION;

/* initialize new group as INCLUDE {empty} */
group->group_filtermode_isexcl = 0; /* 0=INCLUDE, 1=EXCLUDE */
Expand Down
9 changes: 4 additions & 5 deletions pimd/pim_igmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ struct igmp_sock {
struct in_addr ifaddr;
time_t sock_creation;

struct thread *t_igmp_read; /* read: IGMP sockets */
struct thread *t_gm_read; /* read: IGMP or MLD sockets */
struct thread
*t_igmp_query_timer; /* timer: issue IGMP general queries */
*t_query_timer; /* timer: issue IGMP or MLD general queries */
struct thread *t_other_querier_timer; /* timer: other querier present */
struct in_addr querier_addr; /* IP address of the querier */
int querier_query_interval; /* QQI */
Expand Down Expand Up @@ -173,12 +173,11 @@ struct igmp_group {
since sources have their counters) */
int group_specific_query_retransmit_count;

/* compatibility mode - igmp v1, v2 or v3 */
int igmp_version;
int version;

struct in_addr group_addr;
int group_filtermode_isexcl; /* 0=INCLUDE, 1=EXCLUDE */
struct list *group_source_list; /* list of struct igmp_source */
struct list *group_source_list; /* list of struct gm_source */
time_t group_creation;
struct interface *interface;
int64_t last_igmp_v1_report_dsec;
Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_igmpv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ void igmpv3_report_isex(struct igmp_sock *igmp, struct in_addr from,
/* So we can display how we learned the group in our show command output
*/
if (from_igmp_v2_report)
group->igmp_version = 2;
group->version = 2;

if (group->group_filtermode_isexcl) {
/* EXCLUDE mode */
Expand Down
10 changes: 5 additions & 5 deletions pimd/pim_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,26 +400,26 @@ static void igmp_sock_query_reschedule(struct igmp_sock *igmp)
if (igmp->mtrace_only)
return;

if (igmp->t_igmp_query_timer) {
if (igmp->t_query_timer) {
/* other querier present */
assert(igmp->t_igmp_query_timer);
assert(igmp->t_query_timer);
assert(!igmp->t_other_querier_timer);

pim_igmp_general_query_off(igmp);
pim_igmp_general_query_on(igmp);

assert(igmp->t_igmp_query_timer);
assert(igmp->t_query_timer);
assert(!igmp->t_other_querier_timer);
} else {
/* this is the querier */

assert(!igmp->t_igmp_query_timer);
assert(!igmp->t_query_timer);
assert(igmp->t_other_querier_timer);

pim_igmp_other_querier_timer_off(igmp);
pim_igmp_other_querier_timer_on(igmp);

assert(!igmp->t_igmp_query_timer);
assert(!igmp->t_query_timer);
assert(igmp->t_other_querier_timer);
}
}
Expand Down

0 comments on commit 85733b8

Please sign in to comment.