3 Copyright (C) 2008 Everton da Silva Marques
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING; if not, write to the
17 Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
20 $QuaggaId: $Format:%an, %ai, %h$ $
31 #include "pim_igmpv3.h"
32 #include "pim_iface.h"
34 #include "pim_mroute.h"
38 #include "pim_zebra.h"
40 #define IGMP_GRP_REC_TYPE_MODE_IS_INCLUDE (1)
41 #define IGMP_GRP_REC_TYPE_MODE_IS_EXCLUDE (2)
42 #define IGMP_GRP_REC_TYPE_CHANGE_TO_INCLUDE_MODE (3)
43 #define IGMP_GRP_REC_TYPE_CHANGE_TO_EXCLUDE_MODE (4)
44 #define IGMP_GRP_REC_TYPE_ALLOW_NEW_SOURCES (5)
45 #define IGMP_GRP_REC_TYPE_BLOCK_OLD_SOURCES (6)
47 static void group_timer_off(struct igmp_group
*group
);
49 static struct igmp_group
*find_group_by_addr(struct igmp_sock
*igmp
,
50 struct in_addr group_addr
);
52 static int igmp_sock_open(struct in_addr ifaddr
, int ifindex
, uint32_t pim_options
)
58 fd
= pim_socket_mcast(IPPROTO_IGMP
, ifaddr
, ifindex
, 1 /* loop=true */);
62 if (PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(pim_options
)) {
63 if (inet_aton(PIM_ALL_ROUTERS
, &group
)) {
64 if (!pim_socket_join(fd
, group
, ifaddr
, ifindex
))
68 zlog_warn("%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s",
69 __FILE__
, __PRETTY_FUNCTION__
, fd
, inet_ntoa(ifaddr
),
70 PIM_ALL_ROUTERS
, errno
, safe_strerror(errno
));
75 IGMP routers periodically send IGMP general queries to AllSystems=224.0.0.1
76 IGMP routers must receive general queries for querier election.
78 if (inet_aton(PIM_ALL_SYSTEMS
, &group
)) {
79 if (!pim_socket_join(fd
, group
, ifaddr
, ifindex
))
83 zlog_warn("%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s",
84 __FILE__
, __PRETTY_FUNCTION__
, fd
, inet_ntoa(ifaddr
),
85 PIM_ALL_SYSTEMS
, errno
, safe_strerror(errno
));
88 if (inet_aton(PIM_ALL_IGMP_ROUTERS
, &group
)) {
89 if (!pim_socket_join(fd
, group
, ifaddr
, ifindex
)) {
94 zlog_warn("%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s",
95 __FILE__
, __PRETTY_FUNCTION__
, fd
, inet_ntoa(ifaddr
),
96 PIM_ALL_IGMP_ROUTERS
, errno
, safe_strerror(errno
));
100 zlog_err("IGMP socket fd=%d could not join any group on interface address %s",
101 fd
, inet_ntoa(ifaddr
));
109 #undef IGMP_SOCK_DUMP
111 #ifdef IGMP_SOCK_DUMP
112 static void igmp_sock_dump(array_t
*igmp_sock_array
)
114 int size
= array_size(igmp_sock_array
);
115 for (int i
= 0; i
< size
; ++i
) {
117 struct igmp_sock
*igmp
= array_get(igmp_sock_array
, i
);
119 zlog_debug("%s %s: [%d/%d] igmp_addr=%s fd=%d",
120 __FILE__
, __PRETTY_FUNCTION__
,
122 inet_ntoa(igmp
->ifaddr
),
128 struct igmp_sock
*pim_igmp_sock_lookup_ifaddr(struct list
*igmp_sock_list
,
129 struct in_addr ifaddr
)
131 struct listnode
*sock_node
;
132 struct igmp_sock
*igmp
;
134 #ifdef IGMP_SOCK_DUMP
135 igmp_sock_dump(igmp_sock_list
);
138 for (ALL_LIST_ELEMENTS_RO(igmp_sock_list
, sock_node
, igmp
))
139 if (ifaddr
.s_addr
== igmp
->ifaddr
.s_addr
)
145 struct igmp_sock
*igmp_sock_lookup_by_fd(struct list
*igmp_sock_list
,
148 struct listnode
*sock_node
;
149 struct igmp_sock
*igmp
;
151 for (ALL_LIST_ELEMENTS_RO(igmp_sock_list
, sock_node
, igmp
))
158 static int pim_igmp_other_querier_expire(struct thread
*t
)
160 struct igmp_sock
*igmp
;
163 igmp
= THREAD_ARG(t
);
166 zassert(igmp
->t_other_querier_timer
);
167 zassert(!igmp
->t_igmp_query_timer
);
169 if (PIM_DEBUG_IGMP_TRACE
) {
170 char ifaddr_str
[100];
171 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
172 zlog_debug("%s: Querier %s resuming",
177 igmp
->t_other_querier_timer
= 0;
180 We are the current querier, then
181 re-start sending general queries.
183 pim_igmp_general_query_on(igmp
);
188 void pim_igmp_other_querier_timer_on(struct igmp_sock
*igmp
)
190 long other_querier_present_interval_msec
;
191 struct pim_interface
*pim_ifp
;
194 zassert(igmp
->interface
);
195 zassert(igmp
->interface
->info
);
197 pim_ifp
= igmp
->interface
->info
;
199 if (igmp
->t_other_querier_timer
) {
201 There is other querier present already,
202 then reset the other-querier-present timer.
205 if (PIM_DEBUG_IGMP_TRACE
) {
206 char ifaddr_str
[100];
207 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
208 zlog_debug("Querier %s resetting TIMER event for Other-Querier-Present",
212 THREAD_OFF(igmp
->t_other_querier_timer
);
213 zassert(!igmp
->t_other_querier_timer
);
217 We are the current querier, then stop sending general queries:
218 igmp->t_igmp_query_timer = 0;
220 pim_igmp_general_query_off(igmp
);
224 Since this socket is starting the other-querier-present timer,
225 there should not be periodic query timer for this socket.
227 zassert(!igmp
->t_igmp_query_timer
);
230 RFC 3376: 8.5. Other Querier Present Interval
232 The Other Querier Present Interval is the length of time that must
233 pass before a multicast router decides that there is no longer
234 another multicast router which should be the querier. This value
235 MUST be ((the Robustness Variable) times (the Query Interval)) plus
236 (one half of one Query Response Interval).
238 other_querier_present_interval_msec = \
239 igmp->querier_robustness_variable * \
240 1000 * igmp->querier_query_interval + \
241 100 * (pim_ifp->query_max_response_time_dsec >> 1);
243 other_querier_present_interval_msec
=
244 PIM_IGMP_OQPI_MSEC(igmp
->querier_robustness_variable
,
245 igmp
->querier_query_interval
,
246 pim_ifp
->igmp_query_max_response_time_dsec
);
248 if (PIM_DEBUG_IGMP_TRACE
) {
249 char ifaddr_str
[100];
250 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
251 zlog_debug("Querier %s scheduling %ld.%03ld sec TIMER event for Other-Querier-Present",
253 other_querier_present_interval_msec
/ 1000,
254 other_querier_present_interval_msec
% 1000);
257 THREAD_TIMER_MSEC_ON(master
, igmp
->t_other_querier_timer
,
258 pim_igmp_other_querier_expire
,
259 igmp
, other_querier_present_interval_msec
);
262 void pim_igmp_other_querier_timer_off(struct igmp_sock
*igmp
)
266 if (PIM_DEBUG_IGMP_TRACE
) {
267 if (igmp
->t_other_querier_timer
) {
268 char ifaddr_str
[100];
269 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
270 zlog_debug("IGMP querier %s fd=%d cancelling other-querier-present TIMER event on %s",
271 ifaddr_str
, igmp
->fd
, igmp
->interface
->name
);
274 THREAD_OFF(igmp
->t_other_querier_timer
);
275 zassert(!igmp
->t_other_querier_timer
);
278 static int recv_igmp_query(struct igmp_sock
*igmp
, int query_version
,
280 struct in_addr from
, const char *from_str
,
281 char *igmp_msg
, int igmp_msg_len
)
283 struct interface
*ifp
;
284 struct pim_interface
*pim_ifp
;
285 uint8_t resv_s_qrv
= 0;
288 struct in_addr group_addr
;
289 uint16_t recv_checksum
;
293 //group_addr = *(struct in_addr *)(igmp_msg + 4);
294 memcpy(&group_addr
, igmp_msg
+ 4, sizeof(struct in_addr
));
296 ifp
= igmp
->interface
;
299 recv_checksum
= *(uint16_t *) (igmp_msg
+ IGMP_V3_CHECKSUM_OFFSET
);
301 /* for computing checksum */
302 *(uint16_t *) (igmp_msg
+ IGMP_V3_CHECKSUM_OFFSET
) = 0;
304 checksum
= in_cksum(igmp_msg
, igmp_msg_len
);
305 if (checksum
!= recv_checksum
) {
306 zlog_warn("Recv IGMP query v%d from %s on %s: checksum mismatch: received=%x computed=%x",
307 query_version
, from_str
, ifp
->name
, recv_checksum
, checksum
);
311 if (PIM_DEBUG_IGMP_PACKETS
) {
313 pim_inet4_dump("<group?>", group_addr
, group_str
, sizeof(group_str
));
314 zlog_debug("Recv IGMP query v%d from %s on %s: size=%d checksum=%x group=%s",
315 query_version
, from_str
, ifp
->name
,
316 igmp_msg_len
, checksum
, group_str
);
320 RFC 3376: 6.6.2. Querier Election
322 When a router receives a query with a lower IP address, it sets
323 the Other-Querier-Present timer to Other Querier Present Interval
324 and ceases to send queries on the network if it was the previously
327 if (ntohl(from
.s_addr
) < ntohl(igmp
->ifaddr
.s_addr
)) {
329 if (PIM_DEBUG_IGMP_TRACE
) {
330 char ifaddr_str
[100];
331 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
332 zlog_debug("%s: local address %s (%u) lost querier election to %s (%u)",
334 ifaddr_str
, ntohl(igmp
->ifaddr
.s_addr
),
335 from_str
, ntohl(from
.s_addr
));
338 pim_igmp_other_querier_timer_on(igmp
);
341 if (query_version
== 3) {
343 RFC 3376: 4.1.6. QRV (Querier's Robustness Variable)
345 Routers adopt the QRV value from the most recently received Query
346 as their own [Robustness Variable] value, unless that most
347 recently received QRV was zero, in which case the receivers use
348 the default [Robustness Variable] value specified in section 8.1
349 or a statically configured value.
351 resv_s_qrv
= igmp_msg
[8];
352 qrv
= 7 & resv_s_qrv
;
353 igmp
->querier_robustness_variable
= qrv
? qrv
: pim_ifp
->igmp_default_robustness_variable
;
357 RFC 3376: 4.1.7. QQIC (Querier's Query Interval Code)
359 Multicast routers that are not the current querier adopt the QQI
360 value from the most recently received Query as their own [Query
361 Interval] value, unless that most recently received QQI was zero,
362 in which case the receiving routers use the default.
364 if (igmp
->t_other_querier_timer
&& query_version
== 3) {
365 /* other querier present */
369 qqi
= igmp_msg_decode8to16(qqic
);
370 igmp
->querier_query_interval
= qqi
? qqi
: pim_ifp
->igmp_default_query_interval
;
372 if (PIM_DEBUG_IGMP_TRACE
) {
373 char ifaddr_str
[100];
374 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
375 zlog_debug("Querier %s new query interval is %s QQI=%u sec (recv QQIC=%02x from %s)",
377 qqi
? "recv-non-default" : "default",
378 igmp
->querier_query_interval
,
385 RFC 3376: 6.6.1. Timer Updates
387 When a router sends or receives a query with a clear Suppress
388 Router-Side Processing flag, it must update its timers to reflect
389 the correct timeout values for the group or sources being queried.
391 General queries don't trigger timer update.
393 if (query_version
== 3) {
394 s_flag
= (1 << 3) & resv_s_qrv
;
397 /* Neither V1 nor V2 have this field. Pimd should really go into
398 * a compatibility mode here and run as V2 (or V1) but it doesn't
399 * so for now, lets just set the flag to suppress these timer updates.
405 /* s_flag is clear */
407 if (PIM_INADDR_IS_ANY(group_addr
)) {
408 /* this is a general query */
410 /* log that general query should have the s_flag set */
411 zlog_warn("General IGMP query v%d from %s on %s: Suppress Router-Side Processing flag is clear",
412 query_version
, from_str
, ifp
->name
);
415 struct igmp_group
*group
;
417 /* this is a non-general query: perform timer updates */
419 group
= find_group_by_addr(igmp
, group_addr
);
421 int recv_num_sources
= ntohs(*(uint16_t *)(igmp_msg
+ IGMP_V3_NUMSOURCES_OFFSET
));
424 RFC 3376: 6.6.1. Timer Updates
425 Query Q(G,A): Source Timer for sources in A are lowered to LMQT
426 Query Q(G): Group Timer is lowered to LMQT
428 if (recv_num_sources
< 1) {
429 /* Query Q(G): Group Timer is lowered to LMQT */
431 igmp_group_timer_lower_to_lmqt(group
);
434 /* Query Q(G,A): Source Timer for sources in A are lowered to LMQT */
436 /* Scan sources in query and lower their timers to LMQT */
437 struct in_addr
*sources
= (struct in_addr
*)(igmp_msg
+ IGMP_V3_SOURCES_OFFSET
);
438 for (i
= 0; i
< recv_num_sources
; ++i
) {
439 //struct in_addr src_addr = sources[i];
440 //struct igmp_source *src = igmp_find_source_by_addr(group, src_addr);
441 struct in_addr src_addr
;
442 struct igmp_source
*src
;
443 memcpy(&src_addr
, sources
+ i
, sizeof(struct in_addr
));
444 src
= igmp_find_source_by_addr(group
, src_addr
);
446 igmp_source_timer_lower_to_lmqt(src
);
454 pim_inet4_dump("<group?>", group_addr
, group_str
, sizeof(group_str
));
455 zlog_warn("IGMP query v%d from %s on %s: could not find group %s for timer update",
456 query_version
, from_str
, ifp
->name
, group_str
);
459 } /* s_flag is clear: timer updates */
464 static int igmp_v3_report(struct igmp_sock
*igmp
,
465 struct in_addr from
, const char *from_str
,
466 char *igmp_msg
, int igmp_msg_len
)
468 uint16_t recv_checksum
;
471 uint8_t *group_record
;
472 uint8_t *report_pastend
= (uint8_t *) igmp_msg
+ igmp_msg_len
;
473 struct interface
*ifp
= igmp
->interface
;
477 if (igmp_msg_len
< IGMP_V3_MSG_MIN_SIZE
) {
478 zlog_warn("Recv IGMP report v3 from %s on %s: size=%d shorter than minimum=%d",
479 from_str
, ifp
->name
, igmp_msg_len
, IGMP_V3_MSG_MIN_SIZE
);
483 recv_checksum
= *(uint16_t *) (igmp_msg
+ IGMP_V3_CHECKSUM_OFFSET
);
485 /* for computing checksum */
486 *(uint16_t *) (igmp_msg
+ IGMP_V3_CHECKSUM_OFFSET
) = 0;
488 checksum
= in_cksum(igmp_msg
, igmp_msg_len
);
489 if (checksum
!= recv_checksum
) {
490 zlog_warn("Recv IGMP report v3 from %s on %s: checksum mismatch: received=%x computed=%x",
491 from_str
, ifp
->name
, recv_checksum
, checksum
);
495 num_groups
= ntohs(*(uint16_t *) (igmp_msg
+ IGMP_V3_REPORT_NUMGROUPS_OFFSET
));
496 if (num_groups
< 1) {
497 zlog_warn("Recv IGMP report v3 from %s on %s: missing group records",
498 from_str
, ifp
->name
);
502 if (PIM_DEBUG_IGMP_PACKETS
) {
503 zlog_debug("Recv IGMP report v3 from %s on %s: size=%d checksum=%x groups=%d",
504 from_str
, ifp
->name
, igmp_msg_len
, checksum
, num_groups
);
507 group_record
= (uint8_t *) igmp_msg
+ IGMP_V3_REPORT_GROUPPRECORD_OFFSET
;
510 for (i
= 0; i
< num_groups
; ++i
) {
511 struct in_addr rec_group
;
521 if ((group_record
+ IGMP_V3_GROUP_RECORD_MIN_SIZE
) > report_pastend
) {
522 zlog_warn("Recv IGMP report v3 from %s on %s: group record beyond report end",
523 from_str
, ifp
->name
);
527 rec_type
= group_record
[IGMP_V3_GROUP_RECORD_TYPE_OFFSET
];
528 rec_auxdatalen
= group_record
[IGMP_V3_GROUP_RECORD_AUXDATALEN_OFFSET
];
529 rec_num_sources
= ntohs(* (uint16_t *) (group_record
+ IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET
));
531 //rec_group = *(struct in_addr *)(group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET);
532 memcpy(&rec_group
, group_record
+ IGMP_V3_GROUP_RECORD_GROUP_OFFSET
, sizeof(struct in_addr
));
534 if (PIM_DEBUG_IGMP_PACKETS
) {
535 zlog_debug("Recv IGMP report v3 from %s on %s: record=%d type=%d auxdatalen=%d sources=%d group=%s",
536 from_str
, ifp
->name
, i
, rec_type
, rec_auxdatalen
, rec_num_sources
, inet_ntoa(rec_group
));
541 sources
= group_record
+ IGMP_V3_GROUP_RECORD_SOURCE_OFFSET
;
543 for (j
= 0, src
= sources
; j
< rec_num_sources
; ++j
, src
+= 4) {
545 if ((src
+ 4) > report_pastend
) {
546 zlog_warn("Recv IGMP report v3 from %s on %s: group source beyond report end",
547 from_str
, ifp
->name
);
551 if (PIM_DEBUG_IGMP_PACKETS
) {
554 if (!inet_ntop(AF_INET
, src
, src_str
, sizeof(src_str
)))
555 sprintf(src_str
, "<source?>");
557 zlog_debug("Recv IGMP report v3 from %s on %s: record=%d group=%s source=%s",
558 from_str
, ifp
->name
, i
, inet_ntoa(rec_group
), src_str
);
560 } /* for (sources) */
563 lncb
.family
= AF_INET
;
564 lncb
.u
.prefix4
.s_addr
= 0x000000E0;
568 g
.u
.prefix4
= rec_group
;
571 * If we receive a igmp report with the group in 224.0.0.0/24
572 * then we should ignore it
574 if (prefix_match(&lncb
, &g
))
579 case IGMP_GRP_REC_TYPE_MODE_IS_INCLUDE
:
580 igmpv3_report_isin(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
582 case IGMP_GRP_REC_TYPE_MODE_IS_EXCLUDE
:
583 igmpv3_report_isex(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
585 case IGMP_GRP_REC_TYPE_CHANGE_TO_INCLUDE_MODE
:
586 igmpv3_report_toin(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
588 case IGMP_GRP_REC_TYPE_CHANGE_TO_EXCLUDE_MODE
:
589 igmpv3_report_toex(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
591 case IGMP_GRP_REC_TYPE_ALLOW_NEW_SOURCES
:
592 igmpv3_report_allow(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
594 case IGMP_GRP_REC_TYPE_BLOCK_OLD_SOURCES
:
595 igmpv3_report_block(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
598 zlog_warn("Recv IGMP report v3 from %s on %s: unknown record type: type=%d",
599 from_str
, ifp
->name
, rec_type
);
602 group_record
+= 8 + (rec_num_sources
<< 2) + (rec_auxdatalen
<< 2);
605 } /* for (group records) */
610 static void on_trace(const char *label
,
611 struct interface
*ifp
, struct in_addr from
)
613 if (PIM_DEBUG_IGMP_TRACE
) {
615 pim_inet4_dump("<from?>", from
, from_str
, sizeof(from_str
));
616 zlog_debug("%s: from %s on %s",
617 label
, from_str
, ifp
->name
);
621 static int igmp_v2_report(struct igmp_sock
*igmp
,
622 struct in_addr from
, const char *from_str
,
623 char *igmp_msg
, int igmp_msg_len
)
625 struct interface
*ifp
= igmp
->interface
;
626 struct igmp_group
*group
;
627 struct in_addr group_addr
;
629 on_trace(__PRETTY_FUNCTION__
, igmp
->interface
, from
);
631 if (igmp_msg_len
!= IGMP_V12_MSG_SIZE
) {
632 zlog_warn("Recv IGMP report v2 from %s on %s: size=%d other than correct=%d",
633 from_str
, ifp
->name
, igmp_msg_len
, IGMP_V12_MSG_SIZE
);
637 if (PIM_DEBUG_IGMP_TRACE
) {
638 zlog_warn("%s %s: FIXME WRITEME",
639 __FILE__
, __PRETTY_FUNCTION__
);
642 //group_addr = *(struct in_addr *)(igmp_msg + 4);
643 memcpy(&group_addr
, igmp_msg
+ 4, sizeof(struct in_addr
));
645 /* non-existant group is created as INCLUDE {empty} */
646 group
= igmp_add_group_by_addr(igmp
, group_addr
);
651 group
->last_igmp_v2_report_dsec
= pim_time_monotonic_dsec();
656 static int igmp_v2_leave(struct igmp_sock
*igmp
,
657 struct in_addr from
, const char *from_str
,
658 char *igmp_msg
, int igmp_msg_len
)
660 struct interface
*ifp
= igmp
->interface
;
662 on_trace(__PRETTY_FUNCTION__
, igmp
->interface
, from
);
664 if (igmp_msg_len
!= IGMP_V12_MSG_SIZE
) {
665 zlog_warn("Recv IGMP leave v2 from %s on %s: size=%d other than correct=%d",
666 from_str
, ifp
->name
, igmp_msg_len
, IGMP_V12_MSG_SIZE
);
670 if (PIM_DEBUG_IGMP_TRACE
) {
671 zlog_warn("%s %s: FIXME WRITEME",
672 __FILE__
, __PRETTY_FUNCTION__
);
678 static int igmp_v1_report(struct igmp_sock
*igmp
,
679 struct in_addr from
, const char *from_str
,
680 char *igmp_msg
, int igmp_msg_len
)
682 struct interface
*ifp
= igmp
->interface
;
683 struct igmp_group
*group
;
684 struct in_addr group_addr
;
686 on_trace(__PRETTY_FUNCTION__
, igmp
->interface
, from
);
688 if (igmp_msg_len
!= IGMP_V12_MSG_SIZE
) {
689 zlog_warn("Recv IGMP report v1 from %s on %s: size=%d other than correct=%d",
690 from_str
, ifp
->name
, igmp_msg_len
, IGMP_V12_MSG_SIZE
);
694 if (PIM_DEBUG_IGMP_TRACE
) {
695 zlog_warn("%s %s: FIXME WRITEME",
696 __FILE__
, __PRETTY_FUNCTION__
);
699 //group_addr = *(struct in_addr *)(igmp_msg + 4);
700 memcpy(&group_addr
, igmp_msg
+ 4, sizeof(struct in_addr
));
702 /* non-existant group is created as INCLUDE {empty} */
703 group
= igmp_add_group_by_addr(igmp
, group_addr
);
708 group
->last_igmp_v1_report_dsec
= pim_time_monotonic_dsec();
713 int pim_igmp_packet(struct igmp_sock
*igmp
, char *buf
, size_t len
)
716 size_t ip_hlen
; /* ip header length in bytes */
723 if (len
< sizeof(*ip_hdr
)) {
724 zlog_warn("IGMP packet size=%zu shorter than minimum=%zu",
725 len
, sizeof(*ip_hdr
));
729 ip_hdr
= (struct ip
*) buf
;
731 pim_inet4_dump("<src?>", ip_hdr
->ip_src
, from_str
, sizeof(from_str
));
732 pim_inet4_dump("<dst?>", ip_hdr
->ip_dst
, to_str
, sizeof(to_str
));
734 ip_hlen
= ip_hdr
->ip_hl
<< 2; /* ip_hl gives length in 4-byte words */
736 if (PIM_DEBUG_IGMP_PACKETS
) {
737 zlog_debug("Recv IP packet from %s to %s on %s: size=%zu ip_header_size=%zu ip_proto=%d",
738 from_str
, to_str
, igmp
->interface
->name
, len
, ip_hlen
, ip_hdr
->ip_p
);
741 if (ip_hdr
->ip_p
!= PIM_IP_PROTO_IGMP
) {
742 zlog_warn("IP packet protocol=%d is not IGMP=%d",
743 ip_hdr
->ip_p
, PIM_IP_PROTO_IGMP
);
747 if (ip_hlen
< PIM_IP_HEADER_MIN_LEN
) {
748 zlog_warn("IP packet header size=%zu shorter than minimum=%d",
749 ip_hlen
, PIM_IP_HEADER_MIN_LEN
);
752 if (ip_hlen
> PIM_IP_HEADER_MAX_LEN
) {
753 zlog_warn("IP packet header size=%zu greater than maximum=%d",
754 ip_hlen
, PIM_IP_HEADER_MAX_LEN
);
758 igmp_msg
= buf
+ ip_hlen
;
759 msg_type
= *igmp_msg
;
760 igmp_msg_len
= len
- ip_hlen
;
762 if (PIM_DEBUG_IGMP_PACKETS
) {
763 zlog_debug("Recv IGMP packet from %s to %s on %s: ttl=%d msg_type=%d msg_size=%d",
764 from_str
, to_str
, igmp
->interface
->name
, ip_hdr
->ip_ttl
, msg_type
,
768 if (igmp_msg_len
< PIM_IGMP_MIN_LEN
) {
769 zlog_warn("IGMP message size=%d shorter than minimum=%d",
770 igmp_msg_len
, PIM_IGMP_MIN_LEN
);
775 case PIM_IGMP_MEMBERSHIP_QUERY
:
777 int max_resp_code
= igmp_msg
[1];
781 RFC 3376: 7.1. Query Version Distinctions
782 IGMPv1 Query: length = 8 octets AND Max Resp Code field is zero
783 IGMPv2 Query: length = 8 octets AND Max Resp Code field is non-zero
784 IGMPv3 Query: length >= 12 octets
787 if (igmp_msg_len
== 8) {
788 query_version
= max_resp_code
? 2 : 1;
790 else if (igmp_msg_len
>= 12) {
794 zlog_warn("Unknown IGMP query version");
798 return recv_igmp_query(igmp
, query_version
, max_resp_code
,
799 ip_hdr
->ip_src
, from_str
,
800 igmp_msg
, igmp_msg_len
);
803 case PIM_IGMP_V3_MEMBERSHIP_REPORT
:
804 return igmp_v3_report(igmp
, ip_hdr
->ip_src
, from_str
,
805 igmp_msg
, igmp_msg_len
);
807 case PIM_IGMP_V2_MEMBERSHIP_REPORT
:
808 return igmp_v2_report(igmp
, ip_hdr
->ip_src
, from_str
,
809 igmp_msg
, igmp_msg_len
);
811 case PIM_IGMP_V1_MEMBERSHIP_REPORT
:
812 return igmp_v1_report(igmp
, ip_hdr
->ip_src
, from_str
,
813 igmp_msg
, igmp_msg_len
);
815 case PIM_IGMP_V2_LEAVE_GROUP
:
816 return igmp_v2_leave(igmp
, ip_hdr
->ip_src
, from_str
,
817 igmp_msg
, igmp_msg_len
);
820 zlog_warn("Ignoring unsupported IGMP message type: %d", msg_type
);
825 static int pim_igmp_general_query(struct thread
*t
);
827 void pim_igmp_general_query_on(struct igmp_sock
*igmp
)
829 struct pim_interface
*pim_ifp
;
834 zassert(igmp
->interface
);
837 Since this socket is starting as querier,
838 there should not exist a timer for other-querier-present.
840 zassert(!igmp
->t_other_querier_timer
);
841 pim_ifp
= igmp
->interface
->info
;
845 RFC 3376: 8.6. Startup Query Interval
847 The Startup Query Interval is the interval between General Queries
848 sent by a Querier on startup. Default: 1/4 the Query Interval.
850 startup_mode
= igmp
->startup_query_count
> 0;
852 --igmp
->startup_query_count
;
854 /* query_interval = pim_ifp->igmp_default_query_interval >> 2; */
855 query_interval
= PIM_IGMP_SQI(pim_ifp
->igmp_default_query_interval
);
858 query_interval
= igmp
->querier_query_interval
;
861 if (PIM_DEBUG_IGMP_TRACE
) {
862 char ifaddr_str
[100];
863 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
864 zlog_debug("Querier %s scheduling %d-second (%s) TIMER event for IGMP query on fd=%d",
867 startup_mode
? "startup" : "non-startup",
870 igmp
->t_igmp_query_timer
= 0;
871 zassert(!igmp
->t_igmp_query_timer
);
872 THREAD_TIMER_ON(master
, igmp
->t_igmp_query_timer
,
873 pim_igmp_general_query
,
874 igmp
, query_interval
);
877 void pim_igmp_general_query_off(struct igmp_sock
*igmp
)
881 if (PIM_DEBUG_IGMP_TRACE
) {
882 if (igmp
->t_igmp_query_timer
) {
883 char ifaddr_str
[100];
884 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
885 zlog_debug("IGMP querier %s fd=%d cancelling query TIMER event on %s",
886 ifaddr_str
, igmp
->fd
, igmp
->interface
->name
);
889 THREAD_OFF(igmp
->t_igmp_query_timer
);
890 zassert(!igmp
->t_igmp_query_timer
);
893 /* Issue IGMP general query */
894 static int pim_igmp_general_query(struct thread
*t
)
896 char query_buf
[PIM_IGMP_BUFSIZE_WRITE
];
897 struct igmp_sock
*igmp
;
898 struct in_addr dst_addr
;
899 struct in_addr group_addr
;
900 struct pim_interface
*pim_ifp
;
904 igmp
= THREAD_ARG(t
);
907 zassert(igmp
->interface
);
908 zassert(igmp
->interface
->info
);
910 pim_ifp
= igmp
->interface
->info
;
913 RFC3376: 4.1.12. IP Destination Addresses for Queries
915 In IGMPv3, General Queries are sent with an IP destination address
916 of 224.0.0.1, the all-systems multicast address. Group-Specific
917 and Group-and-Source-Specific Queries are sent with an IP
918 destination address equal to the multicast address of interest.
921 dst_addr
.s_addr
= htonl(INADDR_ALLHOSTS_GROUP
);
922 group_addr
.s_addr
= PIM_NET_INADDR_ANY
;
924 if (PIM_DEBUG_IGMP_TRACE
) {
925 char querier_str
[100];
927 pim_inet4_dump("<querier?>", igmp
->ifaddr
, querier_str
,
928 sizeof(querier_str
));
929 pim_inet4_dump("<dst?>", dst_addr
, dst_str
, sizeof(dst_str
));
930 zlog_debug("Querier %s issuing IGMP general query to %s on %s",
931 querier_str
, dst_str
, igmp
->interface
->name
);
934 pim_igmp_send_membership_query(0 /* igmp_group */,
936 igmp
->interface
->name
,
942 pim_ifp
->igmp_query_max_response_time_dsec
,
943 1 /* s_flag: always set for general queries */,
944 igmp
->querier_robustness_variable
,
945 igmp
->querier_query_interval
);
947 pim_igmp_general_query_on(igmp
);
952 static int pim_igmp_read(struct thread
*t
);
954 static void igmp_read_on(struct igmp_sock
*igmp
)
958 if (PIM_DEBUG_IGMP_TRACE_DETAIL
) {
959 zlog_debug("Scheduling READ event on IGMP socket fd=%d",
962 igmp
->t_igmp_read
= 0;
963 zassert(!igmp
->t_igmp_read
);
964 THREAD_READ_ON(master
, igmp
->t_igmp_read
, pim_igmp_read
, igmp
, igmp
->fd
);
967 static int pim_igmp_read(struct thread
*t
)
969 struct igmp_sock
*igmp
;
971 struct sockaddr_in from
;
972 struct sockaddr_in to
;
973 socklen_t fromlen
= sizeof(from
);
974 socklen_t tolen
= sizeof(to
);
975 uint8_t buf
[PIM_IGMP_BUFSIZE_READ
];
978 int result
= -1; /* defaults to bad */
982 igmp
= THREAD_ARG(t
);
988 zassert(fd
== igmp
->fd
);
990 len
= pim_socket_recvfromto(fd
, buf
, sizeof(buf
),
995 zlog_warn("Failure receiving IP IGMP packet on fd=%d: errno=%d: %s",
996 fd
, errno
, safe_strerror(errno
));
1000 if (PIM_DEBUG_IGMP_PACKETS
) {
1004 if (!inet_ntop(AF_INET
, &from
.sin_addr
, from_str
, sizeof(from_str
)))
1005 sprintf(from_str
, "<from?>");
1006 if (!inet_ntop(AF_INET
, &to
.sin_addr
, to_str
, sizeof(to_str
)))
1007 sprintf(to_str
, "<to?>");
1009 zlog_debug("Recv IP IGMP pkt size=%d from %s to %s on fd=%d on ifindex=%d (sock_ifindex=%d)",
1010 len
, from_str
, to_str
, fd
, ifindex
, igmp
->interface
->ifindex
);
1013 #ifdef PIM_CHECK_RECV_IFINDEX_SANITY
1014 /* ifindex sanity check */
1015 if (ifindex
!= (int) igmp
->interface
->ifindex
) {
1018 struct interface
*ifp
;
1020 if (!inet_ntop(AF_INET
, &from
.sin_addr
, from_str
, sizeof(from_str
)))
1021 sprintf(from_str
, "<from?>");
1022 if (!inet_ntop(AF_INET
, &to
.sin_addr
, to_str
, sizeof(to_str
)))
1023 sprintf(to_str
, "<to?>");
1025 ifp
= if_lookup_by_index(ifindex
);
1027 zassert(ifindex
== (int) ifp
->ifindex
);
1030 #ifdef PIM_REPORT_RECV_IFINDEX_MISMATCH
1031 zlog_warn("Interface mismatch: recv IGMP pkt from %s to %s on fd=%d: recv_ifindex=%d (%s) sock_ifindex=%d (%s)",
1032 from_str
, to_str
, fd
,
1033 ifindex
, ifp
? ifp
->name
: "<if-notfound>",
1034 igmp
->interface
->ifindex
, igmp
->interface
->name
);
1040 if (pim_igmp_packet(igmp
, (char *)buf
, len
)) {
1044 result
= 0; /* good */
1052 static void sock_close(struct igmp_sock
*igmp
)
1054 pim_igmp_other_querier_timer_off(igmp
);
1055 pim_igmp_general_query_off(igmp
);
1057 if (PIM_DEBUG_IGMP_TRACE_DETAIL
) {
1058 if (igmp
->t_igmp_read
) {
1059 zlog_debug("Cancelling READ event on IGMP socket %s fd=%d on interface %s",
1060 inet_ntoa(igmp
->ifaddr
), igmp
->fd
,
1061 igmp
->interface
->name
);
1064 THREAD_OFF(igmp
->t_igmp_read
);
1065 zassert(!igmp
->t_igmp_read
);
1067 if (close(igmp
->fd
)) {
1068 zlog_err("Failure closing IGMP socket %s fd=%d on interface %s: errno=%d: %s",
1069 inet_ntoa(igmp
->ifaddr
), igmp
->fd
, igmp
->interface
->name
,
1070 errno
, safe_strerror(errno
));
1073 if (PIM_DEBUG_IGMP_TRACE_DETAIL
) {
1074 zlog_debug("Deleted IGMP socket %s fd=%d on interface %s",
1075 inet_ntoa(igmp
->ifaddr
), igmp
->fd
, igmp
->interface
->name
);
1079 void igmp_startup_mode_on(struct igmp_sock
*igmp
)
1081 struct pim_interface
*pim_ifp
;
1083 pim_ifp
= igmp
->interface
->info
;
1086 RFC 3376: 8.7. Startup Query Count
1088 The Startup Query Count is the number of Queries sent out on
1089 startup, separated by the Startup Query Interval. Default: the
1090 Robustness Variable.
1092 igmp
->startup_query_count
= igmp
->querier_robustness_variable
;
1095 Since we're (re)starting, reset QQI to default Query Interval
1097 igmp
->querier_query_interval
= pim_ifp
->igmp_default_query_interval
;
1100 static void igmp_group_free(struct igmp_group
*group
)
1102 list_free(group
->group_source_list
);
1104 XFREE(MTYPE_PIM_IGMP_GROUP
, group
);
1107 static void igmp_group_delete(struct igmp_group
*group
)
1109 struct listnode
*src_node
;
1110 struct listnode
*src_nextnode
;
1111 struct igmp_source
*src
;
1113 if (PIM_DEBUG_IGMP_TRACE
) {
1114 char group_str
[100];
1115 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1116 zlog_debug("Deleting IGMP group %s from socket %d interface %s",
1118 group
->group_igmp_sock
->fd
,
1119 group
->group_igmp_sock
->interface
->name
);
1122 for (ALL_LIST_ELEMENTS(group
->group_source_list
, src_node
, src_nextnode
, src
)) {
1123 igmp_source_delete(src
);
1126 if (group
->t_group_query_retransmit_timer
) {
1127 THREAD_OFF(group
->t_group_query_retransmit_timer
);
1130 group_timer_off(group
);
1131 listnode_delete(group
->group_igmp_sock
->igmp_group_list
, group
);
1132 igmp_group_free(group
);
1135 void igmp_group_delete_empty_include(struct igmp_group
*group
)
1137 zassert(!group
->group_filtermode_isexcl
);
1138 zassert(!listcount(group
->group_source_list
));
1140 igmp_group_delete(group
);
1143 void igmp_sock_free(struct igmp_sock
*igmp
)
1145 zassert(!igmp
->t_igmp_read
);
1146 zassert(!igmp
->t_igmp_query_timer
);
1147 zassert(!igmp
->t_other_querier_timer
);
1148 zassert(igmp
->igmp_group_list
);
1149 zassert(!listcount(igmp
->igmp_group_list
));
1151 list_free(igmp
->igmp_group_list
);
1153 XFREE(MTYPE_PIM_IGMP_SOCKET
, igmp
);
1156 void igmp_sock_delete(struct igmp_sock
*igmp
)
1158 struct pim_interface
*pim_ifp
;
1159 struct listnode
*grp_node
;
1160 struct listnode
*grp_nextnode
;
1161 struct igmp_group
*grp
;
1163 for (ALL_LIST_ELEMENTS(igmp
->igmp_group_list
, grp_node
, grp_nextnode
, grp
)) {
1164 igmp_group_delete(grp
);
1169 pim_ifp
= igmp
->interface
->info
;
1171 listnode_delete(pim_ifp
->igmp_socket_list
, igmp
);
1173 igmp_sock_free(igmp
);
1176 static struct igmp_sock
*igmp_sock_new(int fd
,
1177 struct in_addr ifaddr
,
1178 struct interface
*ifp
)
1180 struct pim_interface
*pim_ifp
;
1181 struct igmp_sock
*igmp
;
1183 pim_ifp
= ifp
->info
;
1185 if (PIM_DEBUG_IGMP_TRACE
) {
1186 zlog_debug("Creating IGMP socket fd=%d for address %s on interface %s",
1187 fd
, inet_ntoa(ifaddr
), ifp
->name
);
1190 igmp
= XMALLOC(MTYPE_PIM_IGMP_SOCKET
, sizeof(*igmp
));
1192 zlog_warn("%s %s: XMALLOC() failure",
1193 __FILE__
, __PRETTY_FUNCTION__
);
1197 igmp
->igmp_group_list
= list_new();
1198 if (!igmp
->igmp_group_list
) {
1199 zlog_err("%s %s: failure: igmp_group_list = list_new()",
1200 __FILE__
, __PRETTY_FUNCTION__
);
1203 igmp
->igmp_group_list
->del
= (void (*)(void *)) igmp_group_free
;
1206 igmp
->interface
= ifp
;
1207 igmp
->ifaddr
= ifaddr
;
1208 igmp
->t_igmp_read
= 0;
1209 igmp
->t_igmp_query_timer
= 0;
1210 igmp
->t_other_querier_timer
= 0; /* no other querier present */
1211 igmp
->querier_robustness_variable
= pim_ifp
->igmp_default_robustness_variable
;
1212 igmp
->sock_creation
= pim_time_monotonic_sec();
1215 igmp_startup_mode_on() will reset QQI:
1217 igmp->querier_query_interval = pim_ifp->igmp_default_query_interval;
1219 igmp_startup_mode_on(igmp
);
1222 pim_igmp_general_query_on(igmp
);
1227 struct igmp_sock
*pim_igmp_sock_add(struct list
*igmp_sock_list
,
1228 struct in_addr ifaddr
,
1229 struct interface
*ifp
)
1231 struct pim_interface
*pim_ifp
;
1232 struct igmp_sock
*igmp
;
1235 pim_ifp
= ifp
->info
;
1237 fd
= igmp_sock_open(ifaddr
, ifp
->ifindex
, pim_ifp
->options
);
1239 zlog_warn("Could not open IGMP socket for %s on %s",
1240 inet_ntoa(ifaddr
), ifp
->name
);
1244 igmp
= igmp_sock_new(fd
, ifaddr
, ifp
);
1246 zlog_err("%s %s: igmp_sock_new() failure",
1247 __FILE__
, __PRETTY_FUNCTION__
);
1252 listnode_add(igmp_sock_list
, igmp
);
1254 #ifdef IGMP_SOCK_DUMP
1255 igmp_sock_dump(igmp_sock_array
);
1262 RFC 3376: 6.5. Switching Router Filter-Modes
1264 When a router's filter-mode for a group is EXCLUDE and the group
1265 timer expires, the router filter-mode for the group transitions to
1268 A router uses source records with running source timers as its state
1269 for the switch to a filter-mode of INCLUDE. If there are any source
1270 records with source timers greater than zero (i.e., requested to be
1271 forwarded), a router switches to filter-mode of INCLUDE using those
1272 source records. Source records whose timers are zero (from the
1273 previous EXCLUDE mode) are deleted.
1275 static int igmp_group_timer(struct thread
*t
)
1277 struct igmp_group
*group
;
1280 group
= THREAD_ARG(t
);
1283 if (PIM_DEBUG_IGMP_TRACE
) {
1284 char group_str
[100];
1285 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1286 zlog_debug("%s: Timer for group %s on interface %s",
1287 __PRETTY_FUNCTION__
,
1288 group_str
, group
->group_igmp_sock
->interface
->name
);
1291 zassert(group
->group_filtermode_isexcl
);
1293 group
->t_group_timer
= NULL
;
1294 group
->group_filtermode_isexcl
= 0;
1296 /* Any source (*,G) is forwarded only if mode is EXCLUDE {empty} */
1297 igmp_anysource_forward_stop(group
);
1299 igmp_source_delete_expired(group
->group_source_list
);
1301 zassert(!group
->t_group_timer
);
1302 zassert(!group
->group_filtermode_isexcl
);
1305 RFC 3376: 6.2.2. Definition of Group Timers
1307 If there are no more source records for the group, delete group
1310 if (listcount(group
->group_source_list
) < 1) {
1311 igmp_group_delete_empty_include(group
);
1317 static void group_timer_off(struct igmp_group
*group
)
1319 if (!group
->t_group_timer
)
1322 if (PIM_DEBUG_IGMP_TRACE
) {
1323 char group_str
[100];
1324 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1325 zlog_debug("Cancelling TIMER event for group %s on %s",
1326 group_str
, group
->group_igmp_sock
->interface
->name
);
1329 THREAD_OFF(group
->t_group_timer
);
1330 zassert(!group
->t_group_timer
);
1333 void igmp_group_timer_on(struct igmp_group
*group
,
1334 long interval_msec
, const char *ifname
)
1336 group_timer_off(group
);
1338 if (PIM_DEBUG_IGMP_EVENTS
) {
1339 char group_str
[100];
1340 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1341 zlog_debug("Scheduling %ld.%03ld sec TIMER event for group %s on %s",
1342 interval_msec
/ 1000,
1343 interval_msec
% 1000,
1348 RFC 3376: 6.2.2. Definition of Group Timers
1350 The group timer is only used when a group is in EXCLUDE mode and
1351 it represents the time for the *filter-mode* of the group to
1352 expire and switch to INCLUDE mode.
1354 zassert(group
->group_filtermode_isexcl
);
1356 THREAD_TIMER_MSEC_ON(master
, group
->t_group_timer
,
1358 group
, interval_msec
);
1361 static struct igmp_group
*find_group_by_addr(struct igmp_sock
*igmp
,
1362 struct in_addr group_addr
)
1364 struct igmp_group
*group
;
1365 struct listnode
*node
;
1367 for (ALL_LIST_ELEMENTS_RO(igmp
->igmp_group_list
, node
, group
))
1368 if (group_addr
.s_addr
== group
->group_addr
.s_addr
)
1374 struct igmp_group
*igmp_add_group_by_addr(struct igmp_sock
*igmp
,
1375 struct in_addr group_addr
)
1377 struct igmp_group
*group
;
1379 group
= find_group_by_addr(igmp
, group_addr
);
1385 Non-existant group is created as INCLUDE {empty}:
1387 RFC 3376 - 5.1. Action on Change of Interface State
1389 If no interface state existed for that multicast address before
1390 the change (i.e., the change consisted of creating a new
1391 per-interface record), or if no state exists after the change
1392 (i.e., the change consisted of deleting a per-interface record),
1393 then the "non-existent" state is considered to have a filter mode
1394 of INCLUDE and an empty source list.
1397 group
= XMALLOC(MTYPE_PIM_IGMP_GROUP
, sizeof(*group
));
1399 zlog_warn("%s %s: XMALLOC() failure",
1400 __FILE__
, __PRETTY_FUNCTION__
);
1401 return 0; /* error, not found, could not create */
1404 group
->group_source_list
= list_new();
1405 if (!group
->group_source_list
) {
1406 zlog_warn("%s %s: list_new() failure",
1407 __FILE__
, __PRETTY_FUNCTION__
);
1408 XFREE(MTYPE_PIM_IGMP_GROUP
, group
); /* discard group */
1409 return 0; /* error, not found, could not initialize */
1411 group
->group_source_list
->del
= (void (*)(void *)) igmp_source_free
;
1413 group
->t_group_timer
= NULL
;
1414 group
->t_group_query_retransmit_timer
= NULL
;
1415 group
->group_specific_query_retransmit_count
= 0;
1416 group
->group_addr
= group_addr
;
1417 group
->group_igmp_sock
= igmp
;
1418 group
->last_igmp_v1_report_dsec
= -1;
1419 group
->last_igmp_v2_report_dsec
= -1;
1420 group
->group_creation
= pim_time_monotonic_sec();
1422 /* initialize new group as INCLUDE {empty} */
1423 group
->group_filtermode_isexcl
= 0; /* 0=INCLUDE, 1=EXCLUDE */
1425 listnode_add(igmp
->igmp_group_list
, group
);
1427 if (PIM_DEBUG_IGMP_TRACE
) {
1428 char group_str
[100];
1429 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1430 zlog_debug("Creating new IGMP group %s on socket %d interface %s",
1431 group_str
, igmp
->fd
, igmp
->interface
->name
);
1435 RFC 3376: 6.2.2. Definition of Group Timers
1437 The group timer is only used when a group is in EXCLUDE mode and
1438 it represents the time for the *filter-mode* of the group to
1439 expire and switch to INCLUDE mode.
1441 zassert(!group
->group_filtermode_isexcl
); /* INCLUDE mode */
1442 zassert(!group
->t_group_timer
); /* group timer == 0 */
1444 /* Any source (*,G) is forwarded only if mode is EXCLUDE {empty} */
1445 igmp_anysource_forward_stop(group
);