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 int igmp_sock_open(struct in_addr ifaddr
, int ifindex
, uint32_t pim_options
)
55 fd
= pim_socket_mcast(IPPROTO_IGMP
, ifaddr
, ifindex
, 1 /* loop=true */);
59 if (PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(pim_options
)) {
60 if (inet_aton(PIM_ALL_ROUTERS
, &group
)) {
61 if (!pim_socket_join(fd
, group
, ifaddr
, ifindex
))
65 zlog_warn("%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s",
66 __FILE__
, __PRETTY_FUNCTION__
, fd
, inet_ntoa(ifaddr
),
67 PIM_ALL_ROUTERS
, errno
, safe_strerror(errno
));
72 IGMP routers periodically send IGMP general queries to AllSystems=224.0.0.1
73 IGMP routers must receive general queries for querier election.
75 if (inet_aton(PIM_ALL_SYSTEMS
, &group
)) {
76 if (!pim_socket_join(fd
, group
, ifaddr
, ifindex
))
80 zlog_warn("%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s",
81 __FILE__
, __PRETTY_FUNCTION__
, fd
, inet_ntoa(ifaddr
),
82 PIM_ALL_SYSTEMS
, errno
, safe_strerror(errno
));
85 if (inet_aton(PIM_ALL_IGMP_ROUTERS
, &group
)) {
86 if (!pim_socket_join(fd
, group
, ifaddr
, ifindex
)) {
91 zlog_warn("%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s",
92 __FILE__
, __PRETTY_FUNCTION__
, fd
, inet_ntoa(ifaddr
),
93 PIM_ALL_IGMP_ROUTERS
, errno
, safe_strerror(errno
));
97 zlog_err("IGMP socket fd=%d could not join any group on interface address %s",
98 fd
, inet_ntoa(ifaddr
));
106 #undef IGMP_SOCK_DUMP
108 #ifdef IGMP_SOCK_DUMP
109 static void igmp_sock_dump(array_t
*igmp_sock_array
)
111 int size
= array_size(igmp_sock_array
);
112 for (int i
= 0; i
< size
; ++i
) {
114 struct igmp_sock
*igmp
= array_get(igmp_sock_array
, i
);
116 zlog_debug("%s %s: [%d/%d] igmp_addr=%s fd=%d",
117 __FILE__
, __PRETTY_FUNCTION__
,
119 inet_ntoa(igmp
->ifaddr
),
125 struct igmp_sock
*pim_igmp_sock_lookup_ifaddr(struct list
*igmp_sock_list
,
126 struct in_addr ifaddr
)
128 struct listnode
*sock_node
;
129 struct igmp_sock
*igmp
;
131 #ifdef IGMP_SOCK_DUMP
132 igmp_sock_dump(igmp_sock_list
);
135 for (ALL_LIST_ELEMENTS_RO(igmp_sock_list
, sock_node
, igmp
))
136 if (ifaddr
.s_addr
== igmp
->ifaddr
.s_addr
)
142 struct igmp_sock
*igmp_sock_lookup_by_fd(struct list
*igmp_sock_list
,
145 struct listnode
*sock_node
;
146 struct igmp_sock
*igmp
;
148 for (ALL_LIST_ELEMENTS_RO(igmp_sock_list
, sock_node
, igmp
))
155 static int pim_igmp_other_querier_expire(struct thread
*t
)
157 struct igmp_sock
*igmp
;
160 igmp
= THREAD_ARG(t
);
163 zassert(igmp
->t_other_querier_timer
);
164 zassert(!igmp
->t_igmp_query_timer
);
166 if (PIM_DEBUG_IGMP_TRACE
) {
167 char ifaddr_str
[100];
168 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
169 zlog_debug("%s: Querier %s resuming",
174 igmp
->t_other_querier_timer
= 0;
177 We are the current querier, then
178 re-start sending general queries.
180 pim_igmp_general_query_on(igmp
);
185 void pim_igmp_other_querier_timer_on(struct igmp_sock
*igmp
)
187 long other_querier_present_interval_msec
;
188 struct pim_interface
*pim_ifp
;
191 zassert(igmp
->interface
);
192 zassert(igmp
->interface
->info
);
194 pim_ifp
= igmp
->interface
->info
;
196 if (igmp
->t_other_querier_timer
) {
198 There is other querier present already,
199 then reset the other-querier-present timer.
202 if (PIM_DEBUG_IGMP_TRACE
) {
203 char ifaddr_str
[100];
204 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
205 zlog_debug("Querier %s resetting TIMER event for Other-Querier-Present",
209 THREAD_OFF(igmp
->t_other_querier_timer
);
210 zassert(!igmp
->t_other_querier_timer
);
214 We are the current querier, then stop sending general queries:
215 igmp->t_igmp_query_timer = 0;
217 pim_igmp_general_query_off(igmp
);
221 Since this socket is starting the other-querier-present timer,
222 there should not be periodic query timer for this socket.
224 zassert(!igmp
->t_igmp_query_timer
);
227 RFC 3376: 8.5. Other Querier Present Interval
229 The Other Querier Present Interval is the length of time that must
230 pass before a multicast router decides that there is no longer
231 another multicast router which should be the querier. This value
232 MUST be ((the Robustness Variable) times (the Query Interval)) plus
233 (one half of one Query Response Interval).
235 other_querier_present_interval_msec = \
236 igmp->querier_robustness_variable * \
237 1000 * igmp->querier_query_interval + \
238 100 * (pim_ifp->query_max_response_time_dsec >> 1);
240 other_querier_present_interval_msec
=
241 PIM_IGMP_OQPI_MSEC(igmp
->querier_robustness_variable
,
242 igmp
->querier_query_interval
,
243 pim_ifp
->igmp_query_max_response_time_dsec
);
245 if (PIM_DEBUG_IGMP_TRACE
) {
246 char ifaddr_str
[100];
247 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
248 zlog_debug("Querier %s scheduling %ld.%03ld sec TIMER event for Other-Querier-Present",
250 other_querier_present_interval_msec
/ 1000,
251 other_querier_present_interval_msec
% 1000);
254 THREAD_TIMER_MSEC_ON(master
, igmp
->t_other_querier_timer
,
255 pim_igmp_other_querier_expire
,
256 igmp
, other_querier_present_interval_msec
);
259 void pim_igmp_other_querier_timer_off(struct igmp_sock
*igmp
)
263 if (PIM_DEBUG_IGMP_TRACE
) {
264 if (igmp
->t_other_querier_timer
) {
265 char ifaddr_str
[100];
266 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
267 zlog_debug("IGMP querier %s fd=%d cancelling other-querier-present TIMER event on %s",
268 ifaddr_str
, igmp
->fd
, igmp
->interface
->name
);
271 THREAD_OFF(igmp
->t_other_querier_timer
);
272 zassert(!igmp
->t_other_querier_timer
);
275 static int recv_igmp_query(struct igmp_sock
*igmp
, int query_version
,
277 struct in_addr from
, const char *from_str
,
278 char *igmp_msg
, int igmp_msg_len
)
280 struct interface
*ifp
;
281 struct pim_interface
*pim_ifp
;
282 uint8_t resv_s_qrv
= 0;
285 struct in_addr group_addr
;
286 uint16_t recv_checksum
;
290 //group_addr = *(struct in_addr *)(igmp_msg + 4);
291 memcpy(&group_addr
, igmp_msg
+ 4, sizeof(struct in_addr
));
293 ifp
= igmp
->interface
;
296 recv_checksum
= *(uint16_t *) (igmp_msg
+ IGMP_V3_CHECKSUM_OFFSET
);
298 /* for computing checksum */
299 *(uint16_t *) (igmp_msg
+ IGMP_V3_CHECKSUM_OFFSET
) = 0;
301 checksum
= in_cksum(igmp_msg
, igmp_msg_len
);
302 if (checksum
!= recv_checksum
) {
303 zlog_warn("Recv IGMP query v%d from %s on %s: checksum mismatch: received=%x computed=%x",
304 query_version
, from_str
, ifp
->name
, recv_checksum
, checksum
);
308 if (PIM_DEBUG_IGMP_PACKETS
) {
310 pim_inet4_dump("<group?>", group_addr
, group_str
, sizeof(group_str
));
311 zlog_debug("Recv IGMP query v%d from %s on %s: size=%d checksum=%x group=%s",
312 query_version
, from_str
, ifp
->name
,
313 igmp_msg_len
, checksum
, group_str
);
317 RFC 3376: 6.6.2. Querier Election
319 When a router receives a query with a lower IP address, it sets
320 the Other-Querier-Present timer to Other Querier Present Interval
321 and ceases to send queries on the network if it was the previously
324 if (ntohl(from
.s_addr
) < ntohl(igmp
->ifaddr
.s_addr
)) {
326 if (PIM_DEBUG_IGMP_TRACE
) {
327 char ifaddr_str
[100];
328 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
329 zlog_debug("%s: local address %s (%u) lost querier election to %s (%u)",
331 ifaddr_str
, ntohl(igmp
->ifaddr
.s_addr
),
332 from_str
, ntohl(from
.s_addr
));
335 pim_igmp_other_querier_timer_on(igmp
);
338 if (query_version
== 3) {
340 RFC 3376: 4.1.6. QRV (Querier's Robustness Variable)
342 Routers adopt the QRV value from the most recently received Query
343 as their own [Robustness Variable] value, unless that most
344 recently received QRV was zero, in which case the receivers use
345 the default [Robustness Variable] value specified in section 8.1
346 or a statically configured value.
348 resv_s_qrv
= igmp_msg
[8];
349 qrv
= 7 & resv_s_qrv
;
350 igmp
->querier_robustness_variable
= qrv
? qrv
: pim_ifp
->igmp_default_robustness_variable
;
354 RFC 3376: 4.1.7. QQIC (Querier's Query Interval Code)
356 Multicast routers that are not the current querier adopt the QQI
357 value from the most recently received Query as their own [Query
358 Interval] value, unless that most recently received QQI was zero,
359 in which case the receiving routers use the default.
361 if (igmp
->t_other_querier_timer
&& query_version
== 3) {
362 /* other querier present */
366 qqi
= igmp_msg_decode8to16(qqic
);
367 igmp
->querier_query_interval
= qqi
? qqi
: pim_ifp
->igmp_default_query_interval
;
369 if (PIM_DEBUG_IGMP_TRACE
) {
370 char ifaddr_str
[100];
371 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
372 zlog_debug("Querier %s new query interval is %s QQI=%u sec (recv QQIC=%02x from %s)",
374 qqi
? "recv-non-default" : "default",
375 igmp
->querier_query_interval
,
382 RFC 3376: 6.6.1. Timer Updates
384 When a router sends or receives a query with a clear Suppress
385 Router-Side Processing flag, it must update its timers to reflect
386 the correct timeout values for the group or sources being queried.
388 General queries don't trigger timer update.
390 if (query_version
== 3) {
391 s_flag
= (1 << 3) & resv_s_qrv
;
394 /* Neither V1 nor V2 have this field. Pimd should really go into
395 * a compatibility mode here and run as V2 (or V1) but it doesn't
396 * so for now, lets just set the flag to suppress these timer updates.
402 /* s_flag is clear */
404 if (PIM_INADDR_IS_ANY(group_addr
)) {
405 /* this is a general query */
407 /* log that general query should have the s_flag set */
408 zlog_warn("General IGMP query v%d from %s on %s: Suppress Router-Side Processing flag is clear",
409 query_version
, from_str
, ifp
->name
);
412 struct igmp_group
*group
;
414 /* this is a non-general query: perform timer updates */
416 group
= find_group_by_addr(igmp
, group_addr
);
418 int recv_num_sources
= ntohs(*(uint16_t *)(igmp_msg
+ IGMP_V3_NUMSOURCES_OFFSET
));
421 RFC 3376: 6.6.1. Timer Updates
422 Query Q(G,A): Source Timer for sources in A are lowered to LMQT
423 Query Q(G): Group Timer is lowered to LMQT
425 if (recv_num_sources
< 1) {
426 /* Query Q(G): Group Timer is lowered to LMQT */
428 igmp_group_timer_lower_to_lmqt(group
);
431 /* Query Q(G,A): Source Timer for sources in A are lowered to LMQT */
433 /* Scan sources in query and lower their timers to LMQT */
434 struct in_addr
*sources
= (struct in_addr
*)(igmp_msg
+ IGMP_V3_SOURCES_OFFSET
);
435 for (i
= 0; i
< recv_num_sources
; ++i
) {
436 //struct in_addr src_addr = sources[i];
437 //struct igmp_source *src = igmp_find_source_by_addr(group, src_addr);
438 struct in_addr src_addr
;
439 struct igmp_source
*src
;
440 memcpy(&src_addr
, sources
+ i
, sizeof(struct in_addr
));
441 src
= igmp_find_source_by_addr(group
, src_addr
);
443 igmp_source_timer_lower_to_lmqt(src
);
451 pim_inet4_dump("<group?>", group_addr
, group_str
, sizeof(group_str
));
452 zlog_warn("IGMP query v%d from %s on %s: could not find group %s for timer update",
453 query_version
, from_str
, ifp
->name
, group_str
);
456 } /* s_flag is clear: timer updates */
461 static int igmp_v3_report(struct igmp_sock
*igmp
,
462 struct in_addr from
, const char *from_str
,
463 char *igmp_msg
, int igmp_msg_len
)
465 uint16_t recv_checksum
;
468 uint8_t *group_record
;
469 uint8_t *report_pastend
= (uint8_t *) igmp_msg
+ igmp_msg_len
;
470 struct interface
*ifp
= igmp
->interface
;
474 if (igmp_msg_len
< IGMP_V3_MSG_MIN_SIZE
) {
475 zlog_warn("Recv IGMP report v3 from %s on %s: size=%d shorter than minimum=%d",
476 from_str
, ifp
->name
, igmp_msg_len
, IGMP_V3_MSG_MIN_SIZE
);
480 recv_checksum
= *(uint16_t *) (igmp_msg
+ IGMP_V3_CHECKSUM_OFFSET
);
482 /* for computing checksum */
483 *(uint16_t *) (igmp_msg
+ IGMP_V3_CHECKSUM_OFFSET
) = 0;
485 checksum
= in_cksum(igmp_msg
, igmp_msg_len
);
486 if (checksum
!= recv_checksum
) {
487 zlog_warn("Recv IGMP report v3 from %s on %s: checksum mismatch: received=%x computed=%x",
488 from_str
, ifp
->name
, recv_checksum
, checksum
);
492 num_groups
= ntohs(*(uint16_t *) (igmp_msg
+ IGMP_V3_REPORT_NUMGROUPS_OFFSET
));
493 if (num_groups
< 1) {
494 zlog_warn("Recv IGMP report v3 from %s on %s: missing group records",
495 from_str
, ifp
->name
);
499 if (PIM_DEBUG_IGMP_PACKETS
) {
500 zlog_debug("Recv IGMP report v3 from %s on %s: size=%d checksum=%x groups=%d",
501 from_str
, ifp
->name
, igmp_msg_len
, checksum
, num_groups
);
504 group_record
= (uint8_t *) igmp_msg
+ IGMP_V3_REPORT_GROUPPRECORD_OFFSET
;
507 for (i
= 0; i
< num_groups
; ++i
) {
508 struct in_addr rec_group
;
518 if ((group_record
+ IGMP_V3_GROUP_RECORD_MIN_SIZE
) > report_pastend
) {
519 zlog_warn("Recv IGMP report v3 from %s on %s: group record beyond report end",
520 from_str
, ifp
->name
);
524 rec_type
= group_record
[IGMP_V3_GROUP_RECORD_TYPE_OFFSET
];
525 rec_auxdatalen
= group_record
[IGMP_V3_GROUP_RECORD_AUXDATALEN_OFFSET
];
526 rec_num_sources
= ntohs(* (uint16_t *) (group_record
+ IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET
));
528 //rec_group = *(struct in_addr *)(group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET);
529 memcpy(&rec_group
, group_record
+ IGMP_V3_GROUP_RECORD_GROUP_OFFSET
, sizeof(struct in_addr
));
531 if (PIM_DEBUG_IGMP_PACKETS
) {
532 zlog_debug("Recv IGMP report v3 from %s on %s: record=%d type=%d auxdatalen=%d sources=%d group=%s",
533 from_str
, ifp
->name
, i
, rec_type
, rec_auxdatalen
, rec_num_sources
, inet_ntoa(rec_group
));
538 sources
= group_record
+ IGMP_V3_GROUP_RECORD_SOURCE_OFFSET
;
540 for (j
= 0, src
= sources
; j
< rec_num_sources
; ++j
, src
+= 4) {
542 if ((src
+ 4) > report_pastend
) {
543 zlog_warn("Recv IGMP report v3 from %s on %s: group source beyond report end",
544 from_str
, ifp
->name
);
548 if (PIM_DEBUG_IGMP_PACKETS
) {
551 if (!inet_ntop(AF_INET
, src
, src_str
, sizeof(src_str
)))
552 sprintf(src_str
, "<source?>");
554 zlog_debug("Recv IGMP report v3 from %s on %s: record=%d group=%s source=%s",
555 from_str
, ifp
->name
, i
, inet_ntoa(rec_group
), src_str
);
557 } /* for (sources) */
560 lncb
.family
= AF_INET
;
561 lncb
.u
.prefix4
.s_addr
= 0x000000E0;
565 g
.u
.prefix4
= rec_group
;
568 * If we receive a igmp report with the group in 224.0.0.0/24
569 * then we should ignore it
571 if (prefix_match(&lncb
, &g
))
576 case IGMP_GRP_REC_TYPE_MODE_IS_INCLUDE
:
577 igmpv3_report_isin(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
579 case IGMP_GRP_REC_TYPE_MODE_IS_EXCLUDE
:
580 igmpv3_report_isex(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
582 case IGMP_GRP_REC_TYPE_CHANGE_TO_INCLUDE_MODE
:
583 igmpv3_report_toin(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
585 case IGMP_GRP_REC_TYPE_CHANGE_TO_EXCLUDE_MODE
:
586 igmpv3_report_toex(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
588 case IGMP_GRP_REC_TYPE_ALLOW_NEW_SOURCES
:
589 igmpv3_report_allow(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
591 case IGMP_GRP_REC_TYPE_BLOCK_OLD_SOURCES
:
592 igmpv3_report_block(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
595 zlog_warn("Recv IGMP report v3 from %s on %s: unknown record type: type=%d",
596 from_str
, ifp
->name
, rec_type
);
599 group_record
+= 8 + (rec_num_sources
<< 2) + (rec_auxdatalen
<< 2);
602 } /* for (group records) */
607 static void on_trace(const char *label
,
608 struct interface
*ifp
, struct in_addr from
)
610 if (PIM_DEBUG_IGMP_TRACE
) {
612 pim_inet4_dump("<from?>", from
, from_str
, sizeof(from_str
));
613 zlog_debug("%s: from %s on %s",
614 label
, from_str
, ifp
->name
);
618 static int igmp_v2_report(struct igmp_sock
*igmp
,
619 struct in_addr from
, const char *from_str
,
620 char *igmp_msg
, int igmp_msg_len
)
622 struct interface
*ifp
= igmp
->interface
;
623 struct igmp_group
*group
;
624 struct in_addr group_addr
;
626 on_trace(__PRETTY_FUNCTION__
, igmp
->interface
, from
);
628 if (igmp_msg_len
!= IGMP_V12_MSG_SIZE
) {
629 zlog_warn("Recv IGMP report v2 from %s on %s: size=%d other than correct=%d",
630 from_str
, ifp
->name
, igmp_msg_len
, IGMP_V12_MSG_SIZE
);
634 if (PIM_DEBUG_IGMP_TRACE
) {
635 zlog_warn("%s %s: FIXME WRITEME",
636 __FILE__
, __PRETTY_FUNCTION__
);
639 //group_addr = *(struct in_addr *)(igmp_msg + 4);
640 memcpy(&group_addr
, igmp_msg
+ 4, sizeof(struct in_addr
));
642 /* non-existant group is created as INCLUDE {empty} */
643 group
= igmp_add_group_by_addr(igmp
, group_addr
);
648 group
->last_igmp_v2_report_dsec
= pim_time_monotonic_dsec();
653 static int igmp_v2_leave(struct igmp_sock
*igmp
,
654 struct in_addr from
, const char *from_str
,
655 char *igmp_msg
, int igmp_msg_len
)
657 struct interface
*ifp
= igmp
->interface
;
659 on_trace(__PRETTY_FUNCTION__
, igmp
->interface
, from
);
661 if (igmp_msg_len
!= IGMP_V12_MSG_SIZE
) {
662 zlog_warn("Recv IGMP leave v2 from %s on %s: size=%d other than correct=%d",
663 from_str
, ifp
->name
, igmp_msg_len
, IGMP_V12_MSG_SIZE
);
667 if (PIM_DEBUG_IGMP_TRACE
) {
668 zlog_warn("%s %s: FIXME WRITEME",
669 __FILE__
, __PRETTY_FUNCTION__
);
675 static int igmp_v1_report(struct igmp_sock
*igmp
,
676 struct in_addr from
, const char *from_str
,
677 char *igmp_msg
, int igmp_msg_len
)
679 struct interface
*ifp
= igmp
->interface
;
680 struct igmp_group
*group
;
681 struct in_addr group_addr
;
683 on_trace(__PRETTY_FUNCTION__
, igmp
->interface
, from
);
685 if (igmp_msg_len
!= IGMP_V12_MSG_SIZE
) {
686 zlog_warn("Recv IGMP report v1 from %s on %s: size=%d other than correct=%d",
687 from_str
, ifp
->name
, igmp_msg_len
, IGMP_V12_MSG_SIZE
);
691 if (PIM_DEBUG_IGMP_TRACE
) {
692 zlog_warn("%s %s: FIXME WRITEME",
693 __FILE__
, __PRETTY_FUNCTION__
);
696 //group_addr = *(struct in_addr *)(igmp_msg + 4);
697 memcpy(&group_addr
, igmp_msg
+ 4, sizeof(struct in_addr
));
699 /* non-existant group is created as INCLUDE {empty} */
700 group
= igmp_add_group_by_addr(igmp
, group_addr
);
705 group
->last_igmp_v1_report_dsec
= pim_time_monotonic_dsec();
710 int pim_igmp_packet(struct igmp_sock
*igmp
, char *buf
, size_t len
)
713 size_t ip_hlen
; /* ip header length in bytes */
720 if (len
< sizeof(*ip_hdr
)) {
721 zlog_warn("IGMP packet size=%zu shorter than minimum=%zu",
722 len
, sizeof(*ip_hdr
));
726 ip_hdr
= (struct ip
*) buf
;
728 pim_inet4_dump("<src?>", ip_hdr
->ip_src
, from_str
, sizeof(from_str
));
729 pim_inet4_dump("<dst?>", ip_hdr
->ip_dst
, to_str
, sizeof(to_str
));
731 ip_hlen
= ip_hdr
->ip_hl
<< 2; /* ip_hl gives length in 4-byte words */
733 if (PIM_DEBUG_IGMP_PACKETS
) {
734 zlog_debug("Recv IP packet from %s to %s on %s: size=%zu ip_header_size=%zu ip_proto=%d",
735 from_str
, to_str
, igmp
->interface
->name
, len
, ip_hlen
, ip_hdr
->ip_p
);
738 if (ip_hdr
->ip_p
!= PIM_IP_PROTO_IGMP
) {
739 zlog_warn("IP packet protocol=%d is not IGMP=%d",
740 ip_hdr
->ip_p
, PIM_IP_PROTO_IGMP
);
744 if (ip_hlen
< PIM_IP_HEADER_MIN_LEN
) {
745 zlog_warn("IP packet header size=%zu shorter than minimum=%d",
746 ip_hlen
, PIM_IP_HEADER_MIN_LEN
);
749 if (ip_hlen
> PIM_IP_HEADER_MAX_LEN
) {
750 zlog_warn("IP packet header size=%zu greater than maximum=%d",
751 ip_hlen
, PIM_IP_HEADER_MAX_LEN
);
755 igmp_msg
= buf
+ ip_hlen
;
756 msg_type
= *igmp_msg
;
757 igmp_msg_len
= len
- ip_hlen
;
759 if (PIM_DEBUG_IGMP_PACKETS
) {
760 zlog_debug("Recv IGMP packet from %s to %s on %s: ttl=%d msg_type=%d msg_size=%d",
761 from_str
, to_str
, igmp
->interface
->name
, ip_hdr
->ip_ttl
, msg_type
,
765 if (igmp_msg_len
< PIM_IGMP_MIN_LEN
) {
766 zlog_warn("IGMP message size=%d shorter than minimum=%d",
767 igmp_msg_len
, PIM_IGMP_MIN_LEN
);
772 case PIM_IGMP_MEMBERSHIP_QUERY
:
774 int max_resp_code
= igmp_msg
[1];
778 RFC 3376: 7.1. Query Version Distinctions
779 IGMPv1 Query: length = 8 octets AND Max Resp Code field is zero
780 IGMPv2 Query: length = 8 octets AND Max Resp Code field is non-zero
781 IGMPv3 Query: length >= 12 octets
784 if (igmp_msg_len
== 8) {
785 query_version
= max_resp_code
? 2 : 1;
787 else if (igmp_msg_len
>= 12) {
791 zlog_warn("Unknown IGMP query version");
795 return recv_igmp_query(igmp
, query_version
, max_resp_code
,
796 ip_hdr
->ip_src
, from_str
,
797 igmp_msg
, igmp_msg_len
);
800 case PIM_IGMP_V3_MEMBERSHIP_REPORT
:
801 return igmp_v3_report(igmp
, ip_hdr
->ip_src
, from_str
,
802 igmp_msg
, igmp_msg_len
);
804 case PIM_IGMP_V2_MEMBERSHIP_REPORT
:
805 return igmp_v2_report(igmp
, ip_hdr
->ip_src
, from_str
,
806 igmp_msg
, igmp_msg_len
);
808 case PIM_IGMP_V1_MEMBERSHIP_REPORT
:
809 return igmp_v1_report(igmp
, ip_hdr
->ip_src
, from_str
,
810 igmp_msg
, igmp_msg_len
);
812 case PIM_IGMP_V2_LEAVE_GROUP
:
813 return igmp_v2_leave(igmp
, ip_hdr
->ip_src
, from_str
,
814 igmp_msg
, igmp_msg_len
);
817 zlog_warn("Ignoring unsupported IGMP message type: %d", msg_type
);
822 static int pim_igmp_general_query(struct thread
*t
);
824 void pim_igmp_general_query_on(struct igmp_sock
*igmp
)
826 struct pim_interface
*pim_ifp
;
831 zassert(igmp
->interface
);
834 Since this socket is starting as querier,
835 there should not exist a timer for other-querier-present.
837 zassert(!igmp
->t_other_querier_timer
);
838 pim_ifp
= igmp
->interface
->info
;
842 RFC 3376: 8.6. Startup Query Interval
844 The Startup Query Interval is the interval between General Queries
845 sent by a Querier on startup. Default: 1/4 the Query Interval.
847 startup_mode
= igmp
->startup_query_count
> 0;
849 --igmp
->startup_query_count
;
851 /* query_interval = pim_ifp->igmp_default_query_interval >> 2; */
852 query_interval
= PIM_IGMP_SQI(pim_ifp
->igmp_default_query_interval
);
855 query_interval
= igmp
->querier_query_interval
;
858 if (PIM_DEBUG_IGMP_TRACE
) {
859 char ifaddr_str
[100];
860 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
861 zlog_debug("Querier %s scheduling %d-second (%s) TIMER event for IGMP query on fd=%d",
864 startup_mode
? "startup" : "non-startup",
867 igmp
->t_igmp_query_timer
= 0;
868 zassert(!igmp
->t_igmp_query_timer
);
869 THREAD_TIMER_ON(master
, igmp
->t_igmp_query_timer
,
870 pim_igmp_general_query
,
871 igmp
, query_interval
);
874 void pim_igmp_general_query_off(struct igmp_sock
*igmp
)
878 if (PIM_DEBUG_IGMP_TRACE
) {
879 if (igmp
->t_igmp_query_timer
) {
880 char ifaddr_str
[100];
881 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
882 zlog_debug("IGMP querier %s fd=%d cancelling query TIMER event on %s",
883 ifaddr_str
, igmp
->fd
, igmp
->interface
->name
);
886 THREAD_OFF(igmp
->t_igmp_query_timer
);
887 zassert(!igmp
->t_igmp_query_timer
);
890 /* Issue IGMP general query */
891 static int pim_igmp_general_query(struct thread
*t
)
893 char query_buf
[PIM_IGMP_BUFSIZE_WRITE
];
894 struct igmp_sock
*igmp
;
895 struct in_addr dst_addr
;
896 struct in_addr group_addr
;
897 struct pim_interface
*pim_ifp
;
901 igmp
= THREAD_ARG(t
);
904 zassert(igmp
->interface
);
905 zassert(igmp
->interface
->info
);
907 pim_ifp
= igmp
->interface
->info
;
910 RFC3376: 4.1.12. IP Destination Addresses for Queries
912 In IGMPv3, General Queries are sent with an IP destination address
913 of 224.0.0.1, the all-systems multicast address. Group-Specific
914 and Group-and-Source-Specific Queries are sent with an IP
915 destination address equal to the multicast address of interest.
918 dst_addr
.s_addr
= htonl(INADDR_ALLHOSTS_GROUP
);
919 group_addr
.s_addr
= PIM_NET_INADDR_ANY
;
921 if (PIM_DEBUG_IGMP_TRACE
) {
922 char querier_str
[100];
924 pim_inet4_dump("<querier?>", igmp
->ifaddr
, querier_str
,
925 sizeof(querier_str
));
926 pim_inet4_dump("<dst?>", dst_addr
, dst_str
, sizeof(dst_str
));
927 zlog_debug("Querier %s issuing IGMP general query to %s on %s",
928 querier_str
, dst_str
, igmp
->interface
->name
);
931 pim_igmp_send_membership_query(0 /* igmp_group */,
933 igmp
->interface
->name
,
939 pim_ifp
->igmp_query_max_response_time_dsec
,
940 1 /* s_flag: always set for general queries */,
941 igmp
->querier_robustness_variable
,
942 igmp
->querier_query_interval
);
944 pim_igmp_general_query_on(igmp
);
949 static int pim_igmp_read(struct thread
*t
);
951 static void igmp_read_on(struct igmp_sock
*igmp
)
955 if (PIM_DEBUG_IGMP_TRACE_DETAIL
) {
956 zlog_debug("Scheduling READ event on IGMP socket fd=%d",
959 igmp
->t_igmp_read
= 0;
960 zassert(!igmp
->t_igmp_read
);
961 THREAD_READ_ON(master
, igmp
->t_igmp_read
, pim_igmp_read
, igmp
, igmp
->fd
);
964 static int pim_igmp_read(struct thread
*t
)
966 struct igmp_sock
*igmp
;
968 struct sockaddr_in from
;
969 struct sockaddr_in to
;
970 socklen_t fromlen
= sizeof(from
);
971 socklen_t tolen
= sizeof(to
);
972 uint8_t buf
[PIM_IGMP_BUFSIZE_READ
];
975 int result
= -1; /* defaults to bad */
979 igmp
= THREAD_ARG(t
);
985 zassert(fd
== igmp
->fd
);
987 len
= pim_socket_recvfromto(fd
, buf
, sizeof(buf
),
992 zlog_warn("Failure receiving IP IGMP packet on fd=%d: errno=%d: %s",
993 fd
, errno
, safe_strerror(errno
));
997 if (PIM_DEBUG_IGMP_PACKETS
) {
1001 if (!inet_ntop(AF_INET
, &from
.sin_addr
, from_str
, sizeof(from_str
)))
1002 sprintf(from_str
, "<from?>");
1003 if (!inet_ntop(AF_INET
, &to
.sin_addr
, to_str
, sizeof(to_str
)))
1004 sprintf(to_str
, "<to?>");
1006 zlog_debug("Recv IP IGMP pkt size=%d from %s to %s on fd=%d on ifindex=%d (sock_ifindex=%d)",
1007 len
, from_str
, to_str
, fd
, ifindex
, igmp
->interface
->ifindex
);
1010 #ifdef PIM_CHECK_RECV_IFINDEX_SANITY
1011 /* ifindex sanity check */
1012 if (ifindex
!= (int) igmp
->interface
->ifindex
) {
1015 struct interface
*ifp
;
1017 if (!inet_ntop(AF_INET
, &from
.sin_addr
, from_str
, sizeof(from_str
)))
1018 sprintf(from_str
, "<from?>");
1019 if (!inet_ntop(AF_INET
, &to
.sin_addr
, to_str
, sizeof(to_str
)))
1020 sprintf(to_str
, "<to?>");
1022 ifp
= if_lookup_by_index(ifindex
);
1024 zassert(ifindex
== (int) ifp
->ifindex
);
1027 #ifdef PIM_REPORT_RECV_IFINDEX_MISMATCH
1028 zlog_warn("Interface mismatch: recv IGMP pkt from %s to %s on fd=%d: recv_ifindex=%d (%s) sock_ifindex=%d (%s)",
1029 from_str
, to_str
, fd
,
1030 ifindex
, ifp
? ifp
->name
: "<if-notfound>",
1031 igmp
->interface
->ifindex
, igmp
->interface
->name
);
1037 if (pim_igmp_packet(igmp
, (char *)buf
, len
)) {
1041 result
= 0; /* good */
1049 static void sock_close(struct igmp_sock
*igmp
)
1051 pim_igmp_other_querier_timer_off(igmp
);
1052 pim_igmp_general_query_off(igmp
);
1054 if (PIM_DEBUG_IGMP_TRACE_DETAIL
) {
1055 if (igmp
->t_igmp_read
) {
1056 zlog_debug("Cancelling READ event on IGMP socket %s fd=%d on interface %s",
1057 inet_ntoa(igmp
->ifaddr
), igmp
->fd
,
1058 igmp
->interface
->name
);
1061 THREAD_OFF(igmp
->t_igmp_read
);
1062 zassert(!igmp
->t_igmp_read
);
1064 if (close(igmp
->fd
)) {
1065 zlog_err("Failure closing IGMP socket %s fd=%d on interface %s: errno=%d: %s",
1066 inet_ntoa(igmp
->ifaddr
), igmp
->fd
, igmp
->interface
->name
,
1067 errno
, safe_strerror(errno
));
1070 if (PIM_DEBUG_IGMP_TRACE_DETAIL
) {
1071 zlog_debug("Deleted IGMP socket %s fd=%d on interface %s",
1072 inet_ntoa(igmp
->ifaddr
), igmp
->fd
, igmp
->interface
->name
);
1076 void igmp_startup_mode_on(struct igmp_sock
*igmp
)
1078 struct pim_interface
*pim_ifp
;
1080 pim_ifp
= igmp
->interface
->info
;
1083 RFC 3376: 8.7. Startup Query Count
1085 The Startup Query Count is the number of Queries sent out on
1086 startup, separated by the Startup Query Interval. Default: the
1087 Robustness Variable.
1089 igmp
->startup_query_count
= igmp
->querier_robustness_variable
;
1092 Since we're (re)starting, reset QQI to default Query Interval
1094 igmp
->querier_query_interval
= pim_ifp
->igmp_default_query_interval
;
1097 static void igmp_group_free(struct igmp_group
*group
)
1099 list_free(group
->group_source_list
);
1101 XFREE(MTYPE_PIM_IGMP_GROUP
, group
);
1104 static void igmp_group_delete(struct igmp_group
*group
)
1106 struct listnode
*src_node
;
1107 struct listnode
*src_nextnode
;
1108 struct igmp_source
*src
;
1110 if (PIM_DEBUG_IGMP_TRACE
) {
1111 char group_str
[100];
1112 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1113 zlog_debug("Deleting IGMP group %s from socket %d interface %s",
1115 group
->group_igmp_sock
->fd
,
1116 group
->group_igmp_sock
->interface
->name
);
1119 for (ALL_LIST_ELEMENTS(group
->group_source_list
, src_node
, src_nextnode
, src
)) {
1120 igmp_source_delete(src
);
1123 if (group
->t_group_query_retransmit_timer
) {
1124 THREAD_OFF(group
->t_group_query_retransmit_timer
);
1127 group_timer_off(group
);
1128 listnode_delete(group
->group_igmp_sock
->igmp_group_list
, group
);
1129 igmp_group_free(group
);
1132 void igmp_group_delete_empty_include(struct igmp_group
*group
)
1134 zassert(!group
->group_filtermode_isexcl
);
1135 zassert(!listcount(group
->group_source_list
));
1137 igmp_group_delete(group
);
1140 void igmp_sock_free(struct igmp_sock
*igmp
)
1142 zassert(!igmp
->t_igmp_read
);
1143 zassert(!igmp
->t_igmp_query_timer
);
1144 zassert(!igmp
->t_other_querier_timer
);
1145 zassert(igmp
->igmp_group_list
);
1146 zassert(!listcount(igmp
->igmp_group_list
));
1148 list_free(igmp
->igmp_group_list
);
1150 XFREE(MTYPE_PIM_IGMP_SOCKET
, igmp
);
1153 void igmp_sock_delete(struct igmp_sock
*igmp
)
1155 struct pim_interface
*pim_ifp
;
1156 struct listnode
*grp_node
;
1157 struct listnode
*grp_nextnode
;
1158 struct igmp_group
*grp
;
1160 for (ALL_LIST_ELEMENTS(igmp
->igmp_group_list
, grp_node
, grp_nextnode
, grp
)) {
1161 igmp_group_delete(grp
);
1166 pim_ifp
= igmp
->interface
->info
;
1168 listnode_delete(pim_ifp
->igmp_socket_list
, igmp
);
1170 igmp_sock_free(igmp
);
1173 static struct igmp_sock
*igmp_sock_new(int fd
,
1174 struct in_addr ifaddr
,
1175 struct interface
*ifp
)
1177 struct pim_interface
*pim_ifp
;
1178 struct igmp_sock
*igmp
;
1180 pim_ifp
= ifp
->info
;
1182 if (PIM_DEBUG_IGMP_TRACE
) {
1183 zlog_debug("Creating IGMP socket fd=%d for address %s on interface %s",
1184 fd
, inet_ntoa(ifaddr
), ifp
->name
);
1187 igmp
= XMALLOC(MTYPE_PIM_IGMP_SOCKET
, sizeof(*igmp
));
1189 zlog_warn("%s %s: XMALLOC() failure",
1190 __FILE__
, __PRETTY_FUNCTION__
);
1194 igmp
->igmp_group_list
= list_new();
1195 if (!igmp
->igmp_group_list
) {
1196 zlog_err("%s %s: failure: igmp_group_list = list_new()",
1197 __FILE__
, __PRETTY_FUNCTION__
);
1200 igmp
->igmp_group_list
->del
= (void (*)(void *)) igmp_group_free
;
1203 igmp
->interface
= ifp
;
1204 igmp
->ifaddr
= ifaddr
;
1205 igmp
->t_igmp_read
= 0;
1206 igmp
->t_igmp_query_timer
= 0;
1207 igmp
->t_other_querier_timer
= 0; /* no other querier present */
1208 igmp
->querier_robustness_variable
= pim_ifp
->igmp_default_robustness_variable
;
1209 igmp
->sock_creation
= pim_time_monotonic_sec();
1212 igmp_startup_mode_on() will reset QQI:
1214 igmp->querier_query_interval = pim_ifp->igmp_default_query_interval;
1216 igmp_startup_mode_on(igmp
);
1219 pim_igmp_general_query_on(igmp
);
1224 struct igmp_sock
*pim_igmp_sock_add(struct list
*igmp_sock_list
,
1225 struct in_addr ifaddr
,
1226 struct interface
*ifp
)
1228 struct pim_interface
*pim_ifp
;
1229 struct igmp_sock
*igmp
;
1232 pim_ifp
= ifp
->info
;
1234 fd
= igmp_sock_open(ifaddr
, ifp
->ifindex
, pim_ifp
->options
);
1236 zlog_warn("Could not open IGMP socket for %s on %s",
1237 inet_ntoa(ifaddr
), ifp
->name
);
1241 igmp
= igmp_sock_new(fd
, ifaddr
, ifp
);
1243 zlog_err("%s %s: igmp_sock_new() failure",
1244 __FILE__
, __PRETTY_FUNCTION__
);
1249 listnode_add(igmp_sock_list
, igmp
);
1251 #ifdef IGMP_SOCK_DUMP
1252 igmp_sock_dump(igmp_sock_array
);
1259 RFC 3376: 6.5. Switching Router Filter-Modes
1261 When a router's filter-mode for a group is EXCLUDE and the group
1262 timer expires, the router filter-mode for the group transitions to
1265 A router uses source records with running source timers as its state
1266 for the switch to a filter-mode of INCLUDE. If there are any source
1267 records with source timers greater than zero (i.e., requested to be
1268 forwarded), a router switches to filter-mode of INCLUDE using those
1269 source records. Source records whose timers are zero (from the
1270 previous EXCLUDE mode) are deleted.
1272 static int igmp_group_timer(struct thread
*t
)
1274 struct igmp_group
*group
;
1277 group
= THREAD_ARG(t
);
1280 if (PIM_DEBUG_IGMP_TRACE
) {
1281 char group_str
[100];
1282 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1283 zlog_debug("%s: Timer for group %s on interface %s",
1284 __PRETTY_FUNCTION__
,
1285 group_str
, group
->group_igmp_sock
->interface
->name
);
1288 zassert(group
->group_filtermode_isexcl
);
1290 group
->t_group_timer
= NULL
;
1291 group
->group_filtermode_isexcl
= 0;
1293 /* Any source (*,G) is forwarded only if mode is EXCLUDE {empty} */
1294 igmp_anysource_forward_stop(group
);
1296 igmp_source_delete_expired(group
->group_source_list
);
1298 zassert(!group
->t_group_timer
);
1299 zassert(!group
->group_filtermode_isexcl
);
1302 RFC 3376: 6.2.2. Definition of Group Timers
1304 If there are no more source records for the group, delete group
1307 if (listcount(group
->group_source_list
) < 1) {
1308 igmp_group_delete_empty_include(group
);
1314 static void group_timer_off(struct igmp_group
*group
)
1316 if (!group
->t_group_timer
)
1319 if (PIM_DEBUG_IGMP_TRACE
) {
1320 char group_str
[100];
1321 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1322 zlog_debug("Cancelling TIMER event for group %s on %s",
1323 group_str
, group
->group_igmp_sock
->interface
->name
);
1326 THREAD_OFF(group
->t_group_timer
);
1327 zassert(!group
->t_group_timer
);
1330 void igmp_group_timer_on(struct igmp_group
*group
,
1331 long interval_msec
, const char *ifname
)
1333 group_timer_off(group
);
1335 if (PIM_DEBUG_IGMP_EVENTS
) {
1336 char group_str
[100];
1337 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1338 zlog_debug("Scheduling %ld.%03ld sec TIMER event for group %s on %s",
1339 interval_msec
/ 1000,
1340 interval_msec
% 1000,
1345 RFC 3376: 6.2.2. Definition of Group Timers
1347 The group timer is only used when a group is in EXCLUDE mode and
1348 it represents the time for the *filter-mode* of the group to
1349 expire and switch to INCLUDE mode.
1351 zassert(group
->group_filtermode_isexcl
);
1353 THREAD_TIMER_MSEC_ON(master
, group
->t_group_timer
,
1355 group
, interval_msec
);
1359 find_group_by_addr (struct igmp_sock
*igmp
,
1360 struct in_addr group_addr
)
1362 struct igmp_group
*group
;
1363 struct listnode
*node
;
1365 for (ALL_LIST_ELEMENTS_RO(igmp
->igmp_group_list
, node
, group
))
1366 if (group_addr
.s_addr
== group
->group_addr
.s_addr
)
1372 struct igmp_group
*igmp_add_group_by_addr(struct igmp_sock
*igmp
,
1373 struct in_addr group_addr
)
1375 struct igmp_group
*group
;
1377 group
= find_group_by_addr(igmp
, group_addr
);
1383 Non-existant group is created as INCLUDE {empty}:
1385 RFC 3376 - 5.1. Action on Change of Interface State
1387 If no interface state existed for that multicast address before
1388 the change (i.e., the change consisted of creating a new
1389 per-interface record), or if no state exists after the change
1390 (i.e., the change consisted of deleting a per-interface record),
1391 then the "non-existent" state is considered to have a filter mode
1392 of INCLUDE and an empty source list.
1395 group
= XMALLOC(MTYPE_PIM_IGMP_GROUP
, sizeof(*group
));
1397 zlog_warn("%s %s: XMALLOC() failure",
1398 __FILE__
, __PRETTY_FUNCTION__
);
1399 return 0; /* error, not found, could not create */
1402 group
->group_source_list
= list_new();
1403 if (!group
->group_source_list
) {
1404 zlog_warn("%s %s: list_new() failure",
1405 __FILE__
, __PRETTY_FUNCTION__
);
1406 XFREE(MTYPE_PIM_IGMP_GROUP
, group
); /* discard group */
1407 return 0; /* error, not found, could not initialize */
1409 group
->group_source_list
->del
= (void (*)(void *)) igmp_source_free
;
1411 group
->t_group_timer
= NULL
;
1412 group
->t_group_query_retransmit_timer
= NULL
;
1413 group
->group_specific_query_retransmit_count
= 0;
1414 group
->group_addr
= group_addr
;
1415 group
->group_igmp_sock
= igmp
;
1416 group
->last_igmp_v1_report_dsec
= -1;
1417 group
->last_igmp_v2_report_dsec
= -1;
1418 group
->group_creation
= pim_time_monotonic_sec();
1420 /* initialize new group as INCLUDE {empty} */
1421 group
->group_filtermode_isexcl
= 0; /* 0=INCLUDE, 1=EXCLUDE */
1423 listnode_add(igmp
->igmp_group_list
, group
);
1425 if (PIM_DEBUG_IGMP_TRACE
) {
1426 char group_str
[100];
1427 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1428 zlog_debug("Creating new IGMP group %s on socket %d interface %s",
1429 group_str
, igmp
->fd
, igmp
->interface
->name
);
1433 RFC 3376: 6.2.2. Definition of Group Timers
1435 The group timer is only used when a group is in EXCLUDE mode and
1436 it represents the time for the *filter-mode* of the group to
1437 expire and switch to INCLUDE mode.
1439 zassert(!group
->group_filtermode_isexcl
); /* INCLUDE mode */
1440 zassert(!group
->t_group_timer
); /* group timer == 0 */
1442 /* Any source (*,G) is forwarded only if mode is EXCLUDE {empty} */
1443 igmp_anysource_forward_stop(group
);