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$ $
29 #include "pim_igmpv3.h"
30 #include "pim_iface.h"
32 #include "pim_mroute.h"
36 #include "pim_zebra.h"
38 #define IGMP_GRP_REC_TYPE_MODE_IS_INCLUDE (1)
39 #define IGMP_GRP_REC_TYPE_MODE_IS_EXCLUDE (2)
40 #define IGMP_GRP_REC_TYPE_CHANGE_TO_INCLUDE_MODE (3)
41 #define IGMP_GRP_REC_TYPE_CHANGE_TO_EXCLUDE_MODE (4)
42 #define IGMP_GRP_REC_TYPE_ALLOW_NEW_SOURCES (5)
43 #define IGMP_GRP_REC_TYPE_BLOCK_OLD_SOURCES (6)
45 static void group_timer_off(struct igmp_group
*group
);
47 static struct igmp_group
*find_group_by_addr(struct igmp_sock
*igmp
,
48 struct in_addr group_addr
);
50 static int igmp_sock_open(struct in_addr ifaddr
, int ifindex
, uint32_t pim_options
)
56 fd
= pim_socket_mcast(IPPROTO_IGMP
, ifaddr
, 1 /* loop=true */);
60 if (PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(pim_options
)) {
61 if (inet_aton(PIM_ALL_ROUTERS
, &group
)) {
62 if (!pim_socket_join(fd
, group
, ifaddr
, ifindex
))
66 zlog_warn("%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s",
67 __FILE__
, __PRETTY_FUNCTION__
, fd
, inet_ntoa(ifaddr
),
68 PIM_ALL_ROUTERS
, errno
, safe_strerror(errno
));
73 IGMP routers periodically send IGMP general queries to AllSystems=224.0.0.1
74 IGMP routers must receive general queries for querier election.
76 if (inet_aton(PIM_ALL_SYSTEMS
, &group
)) {
77 if (!pim_socket_join(fd
, group
, ifaddr
, ifindex
))
81 zlog_warn("%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s",
82 __FILE__
, __PRETTY_FUNCTION__
, fd
, inet_ntoa(ifaddr
),
83 PIM_ALL_SYSTEMS
, errno
, safe_strerror(errno
));
86 if (inet_aton(PIM_ALL_IGMP_ROUTERS
, &group
)) {
87 if (!pim_socket_join(fd
, group
, ifaddr
, ifindex
)) {
92 zlog_warn("%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s",
93 __FILE__
, __PRETTY_FUNCTION__
, fd
, inet_ntoa(ifaddr
),
94 PIM_ALL_IGMP_ROUTERS
, errno
, safe_strerror(errno
));
98 zlog_err("IGMP socket fd=%d could not join any group on interface address %s",
99 fd
, inet_ntoa(ifaddr
));
107 #undef IGMP_SOCK_DUMP
109 #ifdef IGMP_SOCK_DUMP
110 static void igmp_sock_dump(array_t
*igmp_sock_array
)
112 int size
= array_size(igmp_sock_array
);
113 for (int i
= 0; i
< size
; ++i
) {
115 struct igmp_sock
*igmp
= array_get(igmp_sock_array
, i
);
117 zlog_debug("%s %s: [%d/%d] igmp_addr=%s fd=%d",
118 __FILE__
, __PRETTY_FUNCTION__
,
120 inet_ntoa(igmp
->ifaddr
),
126 struct igmp_sock
*pim_igmp_sock_lookup_ifaddr(struct list
*igmp_sock_list
,
127 struct in_addr ifaddr
)
129 struct listnode
*sock_node
;
130 struct igmp_sock
*igmp
;
132 #ifdef IGMP_SOCK_DUMP
133 igmp_sock_dump(igmp_sock_list
);
136 for (ALL_LIST_ELEMENTS_RO(igmp_sock_list
, sock_node
, igmp
))
137 if (ifaddr
.s_addr
== igmp
->ifaddr
.s_addr
)
143 struct igmp_sock
*igmp_sock_lookup_by_fd(struct list
*igmp_sock_list
,
146 struct listnode
*sock_node
;
147 struct igmp_sock
*igmp
;
149 for (ALL_LIST_ELEMENTS_RO(igmp_sock_list
, sock_node
, igmp
))
156 static int pim_igmp_other_querier_expire(struct thread
*t
)
158 struct igmp_sock
*igmp
;
161 igmp
= THREAD_ARG(t
);
164 zassert(igmp
->t_other_querier_timer
);
165 zassert(!igmp
->t_igmp_query_timer
);
167 if (PIM_DEBUG_IGMP_TRACE
) {
168 char ifaddr_str
[100];
169 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
170 zlog_debug("%s: Querier %s resuming",
175 igmp
->t_other_querier_timer
= 0;
178 We are the current querier, then
179 re-start sending general queries.
181 pim_igmp_general_query_on(igmp
);
186 void pim_igmp_other_querier_timer_on(struct igmp_sock
*igmp
)
188 long other_querier_present_interval_msec
;
189 struct pim_interface
*pim_ifp
;
192 zassert(igmp
->interface
);
193 zassert(igmp
->interface
->info
);
195 pim_ifp
= igmp
->interface
->info
;
197 if (igmp
->t_other_querier_timer
) {
199 There is other querier present already,
200 then reset the other-querier-present timer.
203 if (PIM_DEBUG_IGMP_TRACE
) {
204 char ifaddr_str
[100];
205 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
206 zlog_debug("Querier %s resetting TIMER event for Other-Querier-Present",
210 THREAD_OFF(igmp
->t_other_querier_timer
);
211 zassert(!igmp
->t_other_querier_timer
);
215 We are the current querier, then stop sending general queries:
216 igmp->t_igmp_query_timer = 0;
218 pim_igmp_general_query_off(igmp
);
222 Since this socket is starting the other-querier-present timer,
223 there should not be periodic query timer for this socket.
225 zassert(!igmp
->t_igmp_query_timer
);
228 RFC 3376: 8.5. Other Querier Present Interval
230 The Other Querier Present Interval is the length of time that must
231 pass before a multicast router decides that there is no longer
232 another multicast router which should be the querier. This value
233 MUST be ((the Robustness Variable) times (the Query Interval)) plus
234 (one half of one Query Response Interval).
236 other_querier_present_interval_msec = \
237 igmp->querier_robustness_variable * \
238 1000 * igmp->querier_query_interval + \
239 100 * (pim_ifp->query_max_response_time_dsec >> 1);
241 other_querier_present_interval_msec
=
242 PIM_IGMP_OQPI_MSEC(igmp
->querier_robustness_variable
,
243 igmp
->querier_query_interval
,
244 pim_ifp
->igmp_query_max_response_time_dsec
);
246 if (PIM_DEBUG_IGMP_TRACE
) {
247 char ifaddr_str
[100];
248 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
249 zlog_debug("Querier %s scheduling %ld.%03ld sec TIMER event for Other-Querier-Present",
251 other_querier_present_interval_msec
/ 1000,
252 other_querier_present_interval_msec
% 1000);
255 THREAD_TIMER_MSEC_ON(master
, igmp
->t_other_querier_timer
,
256 pim_igmp_other_querier_expire
,
257 igmp
, other_querier_present_interval_msec
);
260 void pim_igmp_other_querier_timer_off(struct igmp_sock
*igmp
)
264 if (PIM_DEBUG_IGMP_TRACE
) {
265 if (igmp
->t_other_querier_timer
) {
266 char ifaddr_str
[100];
267 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
268 zlog_debug("IGMP querier %s fd=%d cancelling other-querier-present TIMER event on %s",
269 ifaddr_str
, igmp
->fd
, igmp
->interface
->name
);
272 THREAD_OFF(igmp
->t_other_querier_timer
);
273 zassert(!igmp
->t_other_querier_timer
);
276 static int recv_igmp_query(struct igmp_sock
*igmp
, int query_version
,
278 struct in_addr from
, const char *from_str
,
279 char *igmp_msg
, int igmp_msg_len
)
281 struct interface
*ifp
;
282 struct pim_interface
*pim_ifp
;
283 uint8_t resv_s_qrv
= 0;
286 struct in_addr group_addr
;
287 uint16_t recv_checksum
;
291 //group_addr = *(struct in_addr *)(igmp_msg + 4);
292 memcpy(&group_addr
, igmp_msg
+ 4, sizeof(struct in_addr
));
294 ifp
= igmp
->interface
;
297 recv_checksum
= *(uint16_t *) (igmp_msg
+ IGMP_V3_CHECKSUM_OFFSET
);
299 /* for computing checksum */
300 *(uint16_t *) (igmp_msg
+ IGMP_V3_CHECKSUM_OFFSET
) = 0;
302 checksum
= in_cksum(igmp_msg
, igmp_msg_len
);
303 if (checksum
!= recv_checksum
) {
304 zlog_warn("Recv IGMP query v%d from %s on %s: checksum mismatch: received=%x computed=%x",
305 query_version
, from_str
, ifp
->name
, recv_checksum
, checksum
);
309 if (PIM_DEBUG_IGMP_PACKETS
) {
311 pim_inet4_dump("<group?>", group_addr
, group_str
, sizeof(group_str
));
312 zlog_debug("Recv IGMP query v%d from %s on %s: size=%d checksum=%x group=%s",
313 query_version
, from_str
, ifp
->name
,
314 igmp_msg_len
, checksum
, group_str
);
318 RFC 3376: 6.6.2. Querier Election
320 When a router receives a query with a lower IP address, it sets
321 the Other-Querier-Present timer to Other Querier Present Interval
322 and ceases to send queries on the network if it was the previously
325 if (ntohl(from
.s_addr
) < ntohl(igmp
->ifaddr
.s_addr
)) {
327 if (PIM_DEBUG_IGMP_TRACE
) {
328 char ifaddr_str
[100];
329 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
330 zlog_debug("%s: local address %s (%u) lost querier election to %s (%u)",
332 ifaddr_str
, ntohl(igmp
->ifaddr
.s_addr
),
333 from_str
, ntohl(from
.s_addr
));
336 pim_igmp_other_querier_timer_on(igmp
);
339 if (query_version
== 3) {
341 RFC 3376: 4.1.6. QRV (Querier's Robustness Variable)
343 Routers adopt the QRV value from the most recently received Query
344 as their own [Robustness Variable] value, unless that most
345 recently received QRV was zero, in which case the receivers use
346 the default [Robustness Variable] value specified in section 8.1
347 or a statically configured value.
349 resv_s_qrv
= igmp_msg
[8];
350 qrv
= 7 & resv_s_qrv
;
351 igmp
->querier_robustness_variable
= qrv
? qrv
: pim_ifp
->igmp_default_robustness_variable
;
355 RFC 3376: 4.1.7. QQIC (Querier's Query Interval Code)
357 Multicast routers that are not the current querier adopt the QQI
358 value from the most recently received Query as their own [Query
359 Interval] value, unless that most recently received QQI was zero,
360 in which case the receiving routers use the default.
362 if (igmp
->t_other_querier_timer
&& query_version
== 3) {
363 /* other querier present */
367 qqi
= igmp_msg_decode8to16(qqic
);
368 igmp
->querier_query_interval
= qqi
? qqi
: pim_ifp
->igmp_default_query_interval
;
370 if (PIM_DEBUG_IGMP_TRACE
) {
371 char ifaddr_str
[100];
372 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
373 zlog_debug("Querier %s new query interval is %s QQI=%u sec (recv QQIC=%02x from %s)",
375 qqi
? "recv-non-default" : "default",
376 igmp
->querier_query_interval
,
383 RFC 3376: 6.6.1. Timer Updates
385 When a router sends or receives a query with a clear Suppress
386 Router-Side Processing flag, it must update its timers to reflect
387 the correct timeout values for the group or sources being queried.
389 General queries don't trigger timer update.
391 if (query_version
== 3) {
392 s_flag
= (1 << 3) & resv_s_qrv
;
395 /* Neither V1 nor V2 have this field. Pimd should really go into
396 * a compatibility mode here and run as V2 (or V1) but it doesn't
397 * so for now, lets just set the flag to suppress these timer updates.
403 /* s_flag is clear */
405 if (PIM_INADDR_IS_ANY(group_addr
)) {
406 /* this is a general query */
408 /* log that general query should have the s_flag set */
409 zlog_warn("General IGMP query v%d from %s on %s: Suppress Router-Side Processing flag is clear",
410 query_version
, from_str
, ifp
->name
);
413 struct igmp_group
*group
;
415 /* this is a non-general query: perform timer updates */
417 group
= find_group_by_addr(igmp
, group_addr
);
419 int recv_num_sources
= ntohs(*(uint16_t *)(igmp_msg
+ IGMP_V3_NUMSOURCES_OFFSET
));
422 RFC 3376: 6.6.1. Timer Updates
423 Query Q(G,A): Source Timer for sources in A are lowered to LMQT
424 Query Q(G): Group Timer is lowered to LMQT
426 if (recv_num_sources
< 1) {
427 /* Query Q(G): Group Timer is lowered to LMQT */
429 igmp_group_timer_lower_to_lmqt(group
);
432 /* Query Q(G,A): Source Timer for sources in A are lowered to LMQT */
434 /* Scan sources in query and lower their timers to LMQT */
435 struct in_addr
*sources
= (struct in_addr
*)(igmp_msg
+ IGMP_V3_SOURCES_OFFSET
);
436 for (i
= 0; i
< recv_num_sources
; ++i
) {
437 //struct in_addr src_addr = sources[i];
438 //struct igmp_source *src = igmp_find_source_by_addr(group, src_addr);
439 struct in_addr src_addr
;
440 struct igmp_source
*src
;
441 memcpy(&src_addr
, sources
+ i
, sizeof(struct in_addr
));
442 src
= igmp_find_source_by_addr(group
, src_addr
);
444 igmp_source_timer_lower_to_lmqt(src
);
452 pim_inet4_dump("<group?>", group_addr
, group_str
, sizeof(group_str
));
453 zlog_warn("IGMP query v%d from %s on %s: could not find group %s for timer update",
454 query_version
, from_str
, ifp
->name
, group_str
);
457 } /* s_flag is clear: timer updates */
462 static int igmp_v3_report(struct igmp_sock
*igmp
,
463 struct in_addr from
, const char *from_str
,
464 char *igmp_msg
, int igmp_msg_len
)
466 uint16_t recv_checksum
;
469 uint8_t *group_record
;
470 uint8_t *report_pastend
= (uint8_t *) igmp_msg
+ igmp_msg_len
;
471 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
;
516 if ((group_record
+ IGMP_V3_GROUP_RECORD_MIN_SIZE
) > report_pastend
) {
517 zlog_warn("Recv IGMP report v3 from %s on %s: group record beyond report end",
518 from_str
, ifp
->name
);
522 rec_type
= group_record
[IGMP_V3_GROUP_RECORD_TYPE_OFFSET
];
523 rec_auxdatalen
= group_record
[IGMP_V3_GROUP_RECORD_AUXDATALEN_OFFSET
];
524 rec_num_sources
= ntohs(* (uint16_t *) (group_record
+ IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET
));
526 //rec_group = *(struct in_addr *)(group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET);
527 memcpy(&rec_group
, group_record
+ IGMP_V3_GROUP_RECORD_GROUP_OFFSET
, sizeof(struct in_addr
));
529 if (PIM_DEBUG_IGMP_PACKETS
) {
530 zlog_debug("Recv IGMP report v3 from %s on %s: record=%d type=%d auxdatalen=%d sources=%d group=%s",
531 from_str
, ifp
->name
, i
, rec_type
, rec_auxdatalen
, rec_num_sources
, inet_ntoa(rec_group
));
536 sources
= group_record
+ IGMP_V3_GROUP_RECORD_SOURCE_OFFSET
;
538 for (j
= 0, src
= sources
; j
< rec_num_sources
; ++j
, src
+= 4) {
540 if ((src
+ 4) > report_pastend
) {
541 zlog_warn("Recv IGMP report v3 from %s on %s: group source beyond report end",
542 from_str
, ifp
->name
);
546 if (PIM_DEBUG_IGMP_PACKETS
) {
549 if (!inet_ntop(AF_INET
, src
, src_str
, sizeof(src_str
)))
550 sprintf(src_str
, "<source?>");
552 zlog_debug("Recv IGMP report v3 from %s on %s: record=%d group=%s source=%s",
553 from_str
, ifp
->name
, i
, inet_ntoa(rec_group
), src_str
);
555 } /* for (sources) */
558 case IGMP_GRP_REC_TYPE_MODE_IS_INCLUDE
:
559 igmpv3_report_isin(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
561 case IGMP_GRP_REC_TYPE_MODE_IS_EXCLUDE
:
562 igmpv3_report_isex(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
564 case IGMP_GRP_REC_TYPE_CHANGE_TO_INCLUDE_MODE
:
565 igmpv3_report_toin(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
567 case IGMP_GRP_REC_TYPE_CHANGE_TO_EXCLUDE_MODE
:
568 igmpv3_report_toex(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
570 case IGMP_GRP_REC_TYPE_ALLOW_NEW_SOURCES
:
571 igmpv3_report_allow(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
573 case IGMP_GRP_REC_TYPE_BLOCK_OLD_SOURCES
:
574 igmpv3_report_block(igmp
, from
, rec_group
, rec_num_sources
, (struct in_addr
*) sources
);
577 zlog_warn("Recv IGMP report v3 from %s on %s: unknown record type: type=%d",
578 from_str
, ifp
->name
, rec_type
);
581 group_record
+= 8 + (rec_num_sources
<< 2) + (rec_auxdatalen
<< 2);
583 } /* for (group records) */
588 static void on_trace(const char *label
,
589 struct interface
*ifp
, struct in_addr from
)
591 if (PIM_DEBUG_IGMP_TRACE
) {
593 pim_inet4_dump("<from?>", from
, from_str
, sizeof(from_str
));
594 zlog_debug("%s: from %s on %s",
595 label
, from_str
, ifp
->name
);
599 static int igmp_v2_report(struct igmp_sock
*igmp
,
600 struct in_addr from
, const char *from_str
,
601 char *igmp_msg
, int igmp_msg_len
)
603 struct interface
*ifp
= igmp
->interface
;
604 struct igmp_group
*group
;
605 struct in_addr group_addr
;
607 on_trace(__PRETTY_FUNCTION__
, igmp
->interface
, from
);
609 if (igmp_msg_len
!= IGMP_V12_MSG_SIZE
) {
610 zlog_warn("Recv IGMP report v2 from %s on %s: size=%d other than correct=%d",
611 from_str
, ifp
->name
, igmp_msg_len
, IGMP_V12_MSG_SIZE
);
615 if (PIM_DEBUG_IGMP_TRACE
) {
616 zlog_warn("%s %s: FIXME WRITEME",
617 __FILE__
, __PRETTY_FUNCTION__
);
620 //group_addr = *(struct in_addr *)(igmp_msg + 4);
621 memcpy(&group_addr
, igmp_msg
+ 4, sizeof(struct in_addr
));
623 /* non-existant group is created as INCLUDE {empty} */
624 group
= igmp_add_group_by_addr(igmp
, group_addr
);
629 group
->last_igmp_v2_report_dsec
= pim_time_monotonic_dsec();
634 static int igmp_v2_leave(struct igmp_sock
*igmp
,
635 struct in_addr from
, const char *from_str
,
636 char *igmp_msg
, int igmp_msg_len
)
638 struct interface
*ifp
= igmp
->interface
;
640 on_trace(__PRETTY_FUNCTION__
, igmp
->interface
, from
);
642 if (igmp_msg_len
!= IGMP_V12_MSG_SIZE
) {
643 zlog_warn("Recv IGMP leave v2 from %s on %s: size=%d other than correct=%d",
644 from_str
, ifp
->name
, igmp_msg_len
, IGMP_V12_MSG_SIZE
);
648 if (PIM_DEBUG_IGMP_TRACE
) {
649 zlog_warn("%s %s: FIXME WRITEME",
650 __FILE__
, __PRETTY_FUNCTION__
);
656 static int igmp_v1_report(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
;
661 struct igmp_group
*group
;
662 struct in_addr group_addr
;
664 on_trace(__PRETTY_FUNCTION__
, igmp
->interface
, from
);
666 if (igmp_msg_len
!= IGMP_V12_MSG_SIZE
) {
667 zlog_warn("Recv IGMP report v1 from %s on %s: size=%d other than correct=%d",
668 from_str
, ifp
->name
, igmp_msg_len
, IGMP_V12_MSG_SIZE
);
672 if (PIM_DEBUG_IGMP_TRACE
) {
673 zlog_warn("%s %s: FIXME WRITEME",
674 __FILE__
, __PRETTY_FUNCTION__
);
677 //group_addr = *(struct in_addr *)(igmp_msg + 4);
678 memcpy(&group_addr
, igmp_msg
+ 4, sizeof(struct in_addr
));
680 /* non-existant group is created as INCLUDE {empty} */
681 group
= igmp_add_group_by_addr(igmp
, group_addr
);
686 group
->last_igmp_v1_report_dsec
= pim_time_monotonic_dsec();
691 int pim_igmp_packet(struct igmp_sock
*igmp
, char *buf
, size_t len
)
694 size_t ip_hlen
; /* ip header length in bytes */
701 if (len
< sizeof(*ip_hdr
)) {
702 zlog_warn("IGMP packet size=%zu shorter than minimum=%zu",
703 len
, sizeof(*ip_hdr
));
707 ip_hdr
= (struct ip
*) buf
;
709 pim_inet4_dump("<src?>", ip_hdr
->ip_src
, from_str
, sizeof(from_str
));
710 pim_inet4_dump("<dst?>", ip_hdr
->ip_dst
, to_str
, sizeof(to_str
));
712 ip_hlen
= ip_hdr
->ip_hl
<< 2; /* ip_hl gives length in 4-byte words */
714 if (PIM_DEBUG_IGMP_PACKETS
) {
715 zlog_debug("Recv IP packet from %s to %s on %s: size=%zu ip_header_size=%zu ip_proto=%d",
716 from_str
, to_str
, igmp
->interface
->name
, len
, ip_hlen
, ip_hdr
->ip_p
);
719 if (ip_hdr
->ip_p
!= PIM_IP_PROTO_IGMP
) {
720 zlog_warn("IP packet protocol=%d is not IGMP=%d",
721 ip_hdr
->ip_p
, PIM_IP_PROTO_IGMP
);
725 if (ip_hlen
< PIM_IP_HEADER_MIN_LEN
) {
726 zlog_warn("IP packet header size=%zu shorter than minimum=%d",
727 ip_hlen
, PIM_IP_HEADER_MIN_LEN
);
730 if (ip_hlen
> PIM_IP_HEADER_MAX_LEN
) {
731 zlog_warn("IP packet header size=%zu greater than maximum=%d",
732 ip_hlen
, PIM_IP_HEADER_MAX_LEN
);
736 igmp_msg
= buf
+ ip_hlen
;
737 msg_type
= *igmp_msg
;
738 igmp_msg_len
= len
- ip_hlen
;
740 if (PIM_DEBUG_IGMP_PACKETS
) {
741 zlog_debug("Recv IGMP packet from %s to %s on %s: ttl=%d msg_type=%d msg_size=%d",
742 from_str
, to_str
, igmp
->interface
->name
, ip_hdr
->ip_ttl
, msg_type
,
746 if (igmp_msg_len
< PIM_IGMP_MIN_LEN
) {
747 zlog_warn("IGMP message size=%d shorter than minimum=%d",
748 igmp_msg_len
, PIM_IGMP_MIN_LEN
);
753 case PIM_IGMP_MEMBERSHIP_QUERY
:
755 int max_resp_code
= igmp_msg
[1];
759 RFC 3376: 7.1. Query Version Distinctions
760 IGMPv1 Query: length = 8 octets AND Max Resp Code field is zero
761 IGMPv2 Query: length = 8 octets AND Max Resp Code field is non-zero
762 IGMPv3 Query: length >= 12 octets
765 if (igmp_msg_len
== 8) {
766 query_version
= max_resp_code
? 2 : 1;
768 else if (igmp_msg_len
>= 12) {
772 zlog_warn("Unknown IGMP query version");
776 return recv_igmp_query(igmp
, query_version
, max_resp_code
,
777 ip_hdr
->ip_src
, from_str
,
778 igmp_msg
, igmp_msg_len
);
781 case PIM_IGMP_V3_MEMBERSHIP_REPORT
:
782 return igmp_v3_report(igmp
, ip_hdr
->ip_src
, from_str
,
783 igmp_msg
, igmp_msg_len
);
785 case PIM_IGMP_V2_MEMBERSHIP_REPORT
:
786 return igmp_v2_report(igmp
, ip_hdr
->ip_src
, from_str
,
787 igmp_msg
, igmp_msg_len
);
789 case PIM_IGMP_V1_MEMBERSHIP_REPORT
:
790 return igmp_v1_report(igmp
, ip_hdr
->ip_src
, from_str
,
791 igmp_msg
, igmp_msg_len
);
793 case PIM_IGMP_V2_LEAVE_GROUP
:
794 return igmp_v2_leave(igmp
, ip_hdr
->ip_src
, from_str
,
795 igmp_msg
, igmp_msg_len
);
798 zlog_warn("Ignoring unsupported IGMP message type: %d", msg_type
);
803 static int pim_igmp_general_query(struct thread
*t
);
805 void pim_igmp_general_query_on(struct igmp_sock
*igmp
)
807 struct pim_interface
*pim_ifp
;
812 zassert(igmp
->interface
);
815 Since this socket is starting as querier,
816 there should not exist a timer for other-querier-present.
818 zassert(!igmp
->t_other_querier_timer
);
819 pim_ifp
= igmp
->interface
->info
;
823 RFC 3376: 8.6. Startup Query Interval
825 The Startup Query Interval is the interval between General Queries
826 sent by a Querier on startup. Default: 1/4 the Query Interval.
828 startup_mode
= igmp
->startup_query_count
> 0;
830 --igmp
->startup_query_count
;
832 /* query_interval = pim_ifp->igmp_default_query_interval >> 2; */
833 query_interval
= PIM_IGMP_SQI(pim_ifp
->igmp_default_query_interval
);
836 query_interval
= igmp
->querier_query_interval
;
839 if (PIM_DEBUG_IGMP_TRACE
) {
840 char ifaddr_str
[100];
841 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
842 zlog_debug("Querier %s scheduling %d-second (%s) TIMER event for IGMP query on fd=%d",
845 startup_mode
? "startup" : "non-startup",
848 igmp
->t_igmp_query_timer
= 0;
849 zassert(!igmp
->t_igmp_query_timer
);
850 THREAD_TIMER_ON(master
, igmp
->t_igmp_query_timer
,
851 pim_igmp_general_query
,
852 igmp
, query_interval
);
855 void pim_igmp_general_query_off(struct igmp_sock
*igmp
)
859 if (PIM_DEBUG_IGMP_TRACE
) {
860 if (igmp
->t_igmp_query_timer
) {
861 char ifaddr_str
[100];
862 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
, sizeof(ifaddr_str
));
863 zlog_debug("IGMP querier %s fd=%d cancelling query TIMER event on %s",
864 ifaddr_str
, igmp
->fd
, igmp
->interface
->name
);
867 THREAD_OFF(igmp
->t_igmp_query_timer
);
868 zassert(!igmp
->t_igmp_query_timer
);
871 /* Issue IGMP general query */
872 static int pim_igmp_general_query(struct thread
*t
)
874 char query_buf
[PIM_IGMP_BUFSIZE_WRITE
];
875 struct igmp_sock
*igmp
;
876 struct in_addr dst_addr
;
877 struct in_addr group_addr
;
878 struct pim_interface
*pim_ifp
;
882 igmp
= THREAD_ARG(t
);
885 zassert(igmp
->interface
);
886 zassert(igmp
->interface
->info
);
888 pim_ifp
= igmp
->interface
->info
;
891 RFC3376: 4.1.12. IP Destination Addresses for Queries
893 In IGMPv3, General Queries are sent with an IP destination address
894 of 224.0.0.1, the all-systems multicast address. Group-Specific
895 and Group-and-Source-Specific Queries are sent with an IP
896 destination address equal to the multicast address of interest.
899 dst_addr
.s_addr
= htonl(INADDR_ALLHOSTS_GROUP
);
900 group_addr
.s_addr
= PIM_NET_INADDR_ANY
;
902 if (PIM_DEBUG_IGMP_TRACE
) {
903 char querier_str
[100];
905 pim_inet4_dump("<querier?>", igmp
->ifaddr
, querier_str
,
906 sizeof(querier_str
));
907 pim_inet4_dump("<dst?>", dst_addr
, dst_str
, sizeof(dst_str
));
908 zlog_debug("Querier %s issuing IGMP general query to %s on %s",
909 querier_str
, dst_str
, igmp
->interface
->name
);
912 pim_igmp_send_membership_query(0 /* igmp_group */,
914 igmp
->interface
->name
,
920 pim_ifp
->igmp_query_max_response_time_dsec
,
921 1 /* s_flag: always set for general queries */,
922 igmp
->querier_robustness_variable
,
923 igmp
->querier_query_interval
);
925 pim_igmp_general_query_on(igmp
);
930 static int pim_igmp_read(struct thread
*t
);
932 static void igmp_read_on(struct igmp_sock
*igmp
)
936 if (PIM_DEBUG_IGMP_TRACE
) {
937 zlog_debug("Scheduling READ event on IGMP socket fd=%d",
940 igmp
->t_igmp_read
= 0;
941 zassert(!igmp
->t_igmp_read
);
942 THREAD_READ_ON(master
, igmp
->t_igmp_read
, pim_igmp_read
, igmp
, igmp
->fd
);
945 static int pim_igmp_read(struct thread
*t
)
947 struct igmp_sock
*igmp
;
949 struct sockaddr_in from
;
950 struct sockaddr_in to
;
951 socklen_t fromlen
= sizeof(from
);
952 socklen_t tolen
= sizeof(to
);
953 uint8_t buf
[PIM_IGMP_BUFSIZE_READ
];
956 int result
= -1; /* defaults to bad */
960 igmp
= THREAD_ARG(t
);
966 zassert(fd
== igmp
->fd
);
968 len
= pim_socket_recvfromto(fd
, buf
, sizeof(buf
),
973 zlog_warn("Failure receiving IP IGMP packet on fd=%d: errno=%d: %s",
974 fd
, errno
, safe_strerror(errno
));
978 if (PIM_DEBUG_IGMP_PACKETS
) {
982 if (!inet_ntop(AF_INET
, &from
.sin_addr
, from_str
, sizeof(from_str
)))
983 sprintf(from_str
, "<from?>");
984 if (!inet_ntop(AF_INET
, &to
.sin_addr
, to_str
, sizeof(to_str
)))
985 sprintf(to_str
, "<to?>");
987 zlog_debug("Recv IP IGMP pkt size=%d from %s to %s on fd=%d on ifindex=%d (sock_ifindex=%d)",
988 len
, from_str
, to_str
, fd
, ifindex
, igmp
->interface
->ifindex
);
991 #ifdef PIM_CHECK_RECV_IFINDEX_SANITY
992 /* ifindex sanity check */
993 if (ifindex
!= (int) igmp
->interface
->ifindex
) {
996 struct interface
*ifp
;
998 if (!inet_ntop(AF_INET
, &from
.sin_addr
, from_str
, sizeof(from_str
)))
999 sprintf(from_str
, "<from?>");
1000 if (!inet_ntop(AF_INET
, &to
.sin_addr
, to_str
, sizeof(to_str
)))
1001 sprintf(to_str
, "<to?>");
1003 ifp
= if_lookup_by_index(ifindex
);
1005 zassert(ifindex
== (int) ifp
->ifindex
);
1008 #ifdef PIM_REPORT_RECV_IFINDEX_MISMATCH
1009 zlog_warn("Interface mismatch: recv IGMP pkt from %s to %s on fd=%d: recv_ifindex=%d (%s) sock_ifindex=%d (%s)",
1010 from_str
, to_str
, fd
,
1011 ifindex
, ifp
? ifp
->name
: "<if-notfound>",
1012 igmp
->interface
->ifindex
, igmp
->interface
->name
);
1018 if (pim_igmp_packet(igmp
, (char *)buf
, len
)) {
1022 result
= 0; /* good */
1030 static void sock_close(struct igmp_sock
*igmp
)
1032 pim_igmp_other_querier_timer_off(igmp
);
1033 pim_igmp_general_query_off(igmp
);
1035 if (PIM_DEBUG_IGMP_TRACE
) {
1036 if (igmp
->t_igmp_read
) {
1037 zlog_debug("Cancelling READ event on IGMP socket %s fd=%d on interface %s",
1038 inet_ntoa(igmp
->ifaddr
), igmp
->fd
,
1039 igmp
->interface
->name
);
1042 THREAD_OFF(igmp
->t_igmp_read
);
1043 zassert(!igmp
->t_igmp_read
);
1045 if (close(igmp
->fd
)) {
1046 zlog_err("Failure closing IGMP socket %s fd=%d on interface %s: errno=%d: %s",
1047 inet_ntoa(igmp
->ifaddr
), igmp
->fd
, igmp
->interface
->name
,
1048 errno
, safe_strerror(errno
));
1051 if (PIM_DEBUG_IGMP_TRACE
) {
1052 zlog_debug("Deleted IGMP socket %s fd=%d on interface %s",
1053 inet_ntoa(igmp
->ifaddr
), igmp
->fd
, igmp
->interface
->name
);
1057 void igmp_startup_mode_on(struct igmp_sock
*igmp
)
1059 struct pim_interface
*pim_ifp
;
1061 pim_ifp
= igmp
->interface
->info
;
1064 RFC 3376: 8.7. Startup Query Count
1066 The Startup Query Count is the number of Queries sent out on
1067 startup, separated by the Startup Query Interval. Default: the
1068 Robustness Variable.
1070 igmp
->startup_query_count
= igmp
->querier_robustness_variable
;
1073 Since we're (re)starting, reset QQI to default Query Interval
1075 igmp
->querier_query_interval
= pim_ifp
->igmp_default_query_interval
;
1078 static void igmp_group_free(struct igmp_group
*group
)
1080 zassert(!group
->t_group_query_retransmit_timer
);
1081 zassert(!group
->t_group_timer
);
1082 zassert(group
->group_source_list
);
1083 zassert(!listcount(group
->group_source_list
));
1085 list_free(group
->group_source_list
);
1087 XFREE(MTYPE_PIM_IGMP_GROUP
, group
);
1090 static void igmp_group_delete(struct igmp_group
*group
)
1092 struct listnode
*src_node
;
1093 struct listnode
*src_nextnode
;
1094 struct igmp_source
*src
;
1096 if (PIM_DEBUG_IGMP_TRACE
) {
1097 char group_str
[100];
1098 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1099 zlog_debug("Deleting IGMP group %s from socket %d interface %s",
1101 group
->group_igmp_sock
->fd
,
1102 group
->group_igmp_sock
->interface
->name
);
1105 for (ALL_LIST_ELEMENTS(group
->group_source_list
, src_node
, src_nextnode
, src
)) {
1106 igmp_source_delete(src
);
1109 if (group
->t_group_query_retransmit_timer
) {
1110 THREAD_OFF(group
->t_group_query_retransmit_timer
);
1111 zassert(!group
->t_group_query_retransmit_timer
);
1114 group_timer_off(group
);
1115 listnode_delete(group
->group_igmp_sock
->igmp_group_list
, group
);
1116 igmp_group_free(group
);
1119 void igmp_group_delete_empty_include(struct igmp_group
*group
)
1121 zassert(!group
->group_filtermode_isexcl
);
1122 zassert(!listcount(group
->group_source_list
));
1124 igmp_group_delete(group
);
1127 void igmp_sock_free(struct igmp_sock
*igmp
)
1129 zassert(!igmp
->t_igmp_read
);
1130 zassert(!igmp
->t_igmp_query_timer
);
1131 zassert(!igmp
->t_other_querier_timer
);
1132 zassert(igmp
->igmp_group_list
);
1133 zassert(!listcount(igmp
->igmp_group_list
));
1135 list_free(igmp
->igmp_group_list
);
1137 XFREE(MTYPE_PIM_IGMP_SOCKET
, igmp
);
1140 void igmp_sock_delete(struct igmp_sock
*igmp
)
1142 struct pim_interface
*pim_ifp
;
1143 struct listnode
*grp_node
;
1144 struct listnode
*grp_nextnode
;
1145 struct igmp_group
*grp
;
1147 for (ALL_LIST_ELEMENTS(igmp
->igmp_group_list
, grp_node
, grp_nextnode
, grp
)) {
1148 igmp_group_delete(grp
);
1153 pim_ifp
= igmp
->interface
->info
;
1155 listnode_delete(pim_ifp
->igmp_socket_list
, igmp
);
1157 igmp_sock_free(igmp
);
1160 static struct igmp_sock
*igmp_sock_new(int fd
,
1161 struct in_addr ifaddr
,
1162 struct interface
*ifp
)
1164 struct pim_interface
*pim_ifp
;
1165 struct igmp_sock
*igmp
;
1167 pim_ifp
= ifp
->info
;
1169 if (PIM_DEBUG_IGMP_TRACE
) {
1170 zlog_debug("Creating IGMP socket fd=%d for address %s on interface %s",
1171 fd
, inet_ntoa(ifaddr
), ifp
->name
);
1174 igmp
= XMALLOC(MTYPE_PIM_IGMP_SOCKET
, sizeof(*igmp
));
1176 zlog_warn("%s %s: XMALLOC() failure",
1177 __FILE__
, __PRETTY_FUNCTION__
);
1181 igmp
->igmp_group_list
= list_new();
1182 if (!igmp
->igmp_group_list
) {
1183 zlog_err("%s %s: failure: igmp_group_list = list_new()",
1184 __FILE__
, __PRETTY_FUNCTION__
);
1187 igmp
->igmp_group_list
->del
= (void (*)(void *)) igmp_group_free
;
1190 igmp
->interface
= ifp
;
1191 igmp
->ifaddr
= ifaddr
;
1192 igmp
->t_igmp_read
= 0;
1193 igmp
->t_igmp_query_timer
= 0;
1194 igmp
->t_other_querier_timer
= 0; /* no other querier present */
1195 igmp
->querier_robustness_variable
= pim_ifp
->igmp_default_robustness_variable
;
1196 igmp
->sock_creation
= pim_time_monotonic_sec();
1199 igmp_startup_mode_on() will reset QQI:
1201 igmp->querier_query_interval = pim_ifp->igmp_default_query_interval;
1203 igmp_startup_mode_on(igmp
);
1206 pim_igmp_general_query_on(igmp
);
1211 struct igmp_sock
*pim_igmp_sock_add(struct list
*igmp_sock_list
,
1212 struct in_addr ifaddr
,
1213 struct interface
*ifp
)
1215 struct pim_interface
*pim_ifp
;
1216 struct igmp_sock
*igmp
;
1219 pim_ifp
= ifp
->info
;
1221 fd
= igmp_sock_open(ifaddr
, ifp
->ifindex
, pim_ifp
->options
);
1223 zlog_warn("Could not open IGMP socket for %s on %s",
1224 inet_ntoa(ifaddr
), ifp
->name
);
1228 igmp
= igmp_sock_new(fd
, ifaddr
, ifp
);
1230 zlog_err("%s %s: igmp_sock_new() failure",
1231 __FILE__
, __PRETTY_FUNCTION__
);
1236 listnode_add(igmp_sock_list
, igmp
);
1238 #ifdef IGMP_SOCK_DUMP
1239 igmp_sock_dump(igmp_sock_array
);
1246 RFC 3376: 6.5. Switching Router Filter-Modes
1248 When a router's filter-mode for a group is EXCLUDE and the group
1249 timer expires, the router filter-mode for the group transitions to
1252 A router uses source records with running source timers as its state
1253 for the switch to a filter-mode of INCLUDE. If there are any source
1254 records with source timers greater than zero (i.e., requested to be
1255 forwarded), a router switches to filter-mode of INCLUDE using those
1256 source records. Source records whose timers are zero (from the
1257 previous EXCLUDE mode) are deleted.
1259 static int igmp_group_timer(struct thread
*t
)
1261 struct igmp_group
*group
;
1264 group
= THREAD_ARG(t
);
1267 if (PIM_DEBUG_IGMP_TRACE
) {
1268 char group_str
[100];
1269 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1270 zlog_debug("%s: Timer for group %s on interface %s",
1271 __PRETTY_FUNCTION__
,
1272 group_str
, group
->group_igmp_sock
->interface
->name
);
1275 zassert(group
->group_filtermode_isexcl
);
1277 group
->t_group_timer
= 0;
1278 group
->group_filtermode_isexcl
= 0;
1280 /* Any source (*,G) is forwarded only if mode is EXCLUDE {empty} */
1281 igmp_anysource_forward_stop(group
);
1283 igmp_source_delete_expired(group
->group_source_list
);
1285 zassert(!group
->t_group_timer
);
1286 zassert(!group
->group_filtermode_isexcl
);
1289 RFC 3376: 6.2.2. Definition of Group Timers
1291 If there are no more source records for the group, delete group
1294 if (listcount(group
->group_source_list
) < 1) {
1295 igmp_group_delete_empty_include(group
);
1301 static void group_timer_off(struct igmp_group
*group
)
1303 if (!group
->t_group_timer
)
1306 if (PIM_DEBUG_IGMP_TRACE
) {
1307 char group_str
[100];
1308 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1309 zlog_debug("Cancelling TIMER event for group %s on %s",
1310 group_str
, group
->group_igmp_sock
->interface
->name
);
1313 THREAD_OFF(group
->t_group_timer
);
1314 zassert(!group
->t_group_timer
);
1317 void igmp_group_timer_on(struct igmp_group
*group
,
1318 long interval_msec
, const char *ifname
)
1320 group_timer_off(group
);
1322 if (PIM_DEBUG_IGMP_EVENTS
) {
1323 char group_str
[100];
1324 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1325 zlog_debug("Scheduling %ld.%03ld sec TIMER event for group %s on %s",
1326 interval_msec
/ 1000,
1327 interval_msec
% 1000,
1332 RFC 3376: 6.2.2. Definition of Group Timers
1334 The group timer is only used when a group is in EXCLUDE mode and
1335 it represents the time for the *filter-mode* of the group to
1336 expire and switch to INCLUDE mode.
1338 zassert(group
->group_filtermode_isexcl
);
1340 THREAD_TIMER_MSEC_ON(master
, group
->t_group_timer
,
1342 group
, interval_msec
);
1345 static struct igmp_group
*find_group_by_addr(struct igmp_sock
*igmp
,
1346 struct in_addr group_addr
)
1348 struct igmp_group
*group
;
1349 struct listnode
*node
;
1351 for (ALL_LIST_ELEMENTS_RO(igmp
->igmp_group_list
, node
, group
))
1352 if (group_addr
.s_addr
== group
->group_addr
.s_addr
)
1358 struct igmp_group
*igmp_add_group_by_addr(struct igmp_sock
*igmp
,
1359 struct in_addr group_addr
)
1361 struct igmp_group
*group
;
1363 group
= find_group_by_addr(igmp
, group_addr
);
1369 Non-existant group is created as INCLUDE {empty}:
1371 RFC 3376 - 5.1. Action on Change of Interface State
1373 If no interface state existed for that multicast address before
1374 the change (i.e., the change consisted of creating a new
1375 per-interface record), or if no state exists after the change
1376 (i.e., the change consisted of deleting a per-interface record),
1377 then the "non-existent" state is considered to have a filter mode
1378 of INCLUDE and an empty source list.
1381 group
= XMALLOC(MTYPE_PIM_IGMP_GROUP
, sizeof(*group
));
1383 zlog_warn("%s %s: XMALLOC() failure",
1384 __FILE__
, __PRETTY_FUNCTION__
);
1385 return 0; /* error, not found, could not create */
1388 group
->group_source_list
= list_new();
1389 if (!group
->group_source_list
) {
1390 zlog_warn("%s %s: list_new() failure",
1391 __FILE__
, __PRETTY_FUNCTION__
);
1392 XFREE(MTYPE_PIM_IGMP_GROUP
, group
); /* discard group */
1393 return 0; /* error, not found, could not initialize */
1395 group
->group_source_list
->del
= (void (*)(void *)) igmp_source_free
;
1397 group
->t_group_timer
= NULL
;
1398 group
->t_group_query_retransmit_timer
= NULL
;
1399 group
->group_specific_query_retransmit_count
= 0;
1400 group
->group_addr
= group_addr
;
1401 group
->group_igmp_sock
= igmp
;
1402 group
->last_igmp_v1_report_dsec
= -1;
1403 group
->last_igmp_v2_report_dsec
= -1;
1404 group
->group_creation
= pim_time_monotonic_sec();
1406 /* initialize new group as INCLUDE {empty} */
1407 group
->group_filtermode_isexcl
= 0; /* 0=INCLUDE, 1=EXCLUDE */
1409 listnode_add(igmp
->igmp_group_list
, group
);
1411 if (PIM_DEBUG_IGMP_TRACE
) {
1412 char group_str
[100];
1413 pim_inet4_dump("<group?>", group
->group_addr
, group_str
, sizeof(group_str
));
1414 zlog_debug("Creating new IGMP group %s on socket %d interface %s",
1415 group_str
, igmp
->fd
, igmp
->interface
->name
);
1419 RFC 3376: 6.2.2. Definition of Group Timers
1421 The group timer is only used when a group is in EXCLUDE mode and
1422 it represents the time for the *filter-mode* of the group to
1423 expire and switch to INCLUDE mode.
1425 zassert(!group
->group_filtermode_isexcl
); /* INCLUDE mode */
1426 zassert(!group
->t_group_timer
); /* group timer == 0 */
1428 /* Any source (*,G) is forwarded only if mode is EXCLUDE {empty} */
1429 igmp_anysource_forward_stop(group
);