@@ -127,7 +127,15 @@ static int send_igmp_report(struct net_if *iface,
127
127
}
128
128
129
129
for (i = 0 ; i < NET_IF_MAX_IPV4_MADDR ; i ++ ) {
130
- if (!ipv4 -> mcast [i ].is_used || !ipv4 -> mcast [i ].is_joined ) {
130
+ /* We don't need to send an IGMP membership report to the IGMP
131
+ * all systems multicast address of 224.0.0.1 so skip over it.
132
+ * Since the IGMP all systems multicast address is marked as
133
+ * used and joined during init time, we have to check this
134
+ * address separately to skip over it.
135
+ */
136
+ if (!ipv4 -> mcast [i ].is_used || !ipv4 -> mcast [i ].is_joined ||
137
+ net_ipv4_addr_cmp_raw ((uint8_t * )& ipv4 -> mcast [i ].address .in_addr ,
138
+ (uint8_t * )& all_systems )) {
131
139
continue ;
132
140
}
133
141
@@ -139,7 +147,15 @@ static int send_igmp_report(struct net_if *iface,
139
147
}
140
148
141
149
for (i = 0 ; i < NET_IF_MAX_IPV4_MADDR ; i ++ ) {
142
- if (!ipv4 -> mcast [i ].is_used || !ipv4 -> mcast [i ].is_joined ) {
150
+ /* We don't need to send an IGMP membership report to the IGMP
151
+ * all systems multicast address of 224.0.0.1 so skip over it.
152
+ * Since the IGMP all systems multicast address is marked as
153
+ * used and joined during init time, we have to check this
154
+ * address separately to skip over it.
155
+ */
156
+ if (!ipv4 -> mcast [i ].is_used || !ipv4 -> mcast [i ].is_joined ||
157
+ net_ipv4_addr_cmp_raw ((uint8_t * )& ipv4 -> mcast [i ].address .in_addr ,
158
+ (uint8_t * )& all_systems )) {
143
159
continue ;
144
160
}
145
161
@@ -326,3 +342,39 @@ int net_ipv4_igmp_leave(struct net_if *iface, const struct in_addr *addr)
326
342
sizeof (struct in_addr ));
327
343
return ret ;
328
344
}
345
+
346
+ void net_ipv4_igmp_init (struct net_if * iface )
347
+ {
348
+ struct net_if_mcast_addr * maddr ;
349
+
350
+ /* Ensure multicast addresses are available */
351
+ if (CONFIG_NET_IF_MCAST_IPV4_ADDR_COUNT < 1 ) {
352
+ return ;
353
+ }
354
+
355
+ /* This code adds the IGMP all systems 224.0.0.1 multicast address
356
+ * to the list of multicast addresses of the given interface.
357
+ * The address is marked as joined. However, an IGMP membership
358
+ * report is not generated for this address. Populating this
359
+ * address in the list of multicast addresses of the interface
360
+ * and marking it as joined is helpful for multicast hash filter
361
+ * implementations that need a list of multicast addresses it needs
362
+ * to add to the multicast hash filter after a multicast address
363
+ * has been removed from the membership list.
364
+ */
365
+ maddr = net_if_ipv4_maddr_lookup (& all_systems , & iface );
366
+ if (maddr && net_if_ipv4_maddr_is_joined (maddr )) {
367
+ return ;
368
+ }
369
+
370
+ if (!maddr ) {
371
+ maddr = net_if_ipv4_maddr_add (iface , & all_systems );
372
+ if (!maddr ) {
373
+ return ;
374
+ }
375
+ }
376
+
377
+ net_if_ipv4_maddr_join (maddr );
378
+
379
+ net_if_mcast_monitor (iface , & maddr -> address , true);
380
+ }
0 commit comments