Skip to content

Commit 390dcd4

Browse files
T-Xsimonwunderlich
authored andcommitted
batman-adv: mcast: avoid redundant multicast TT entries with bridges
When a bridge is added on top of bat0 we set the WANT_ALL_UNSNOOPABLES flag. Which means we sign up for all traffic for ff02::1/128 and 224.0.0.0/24. When the node itself had IPv6 enabled or joined a group in 224.0.0.0/24 itself then so far this would result in a multicast TT entry which is redundant to the WANT_ALL_UNSNOOPABLES. With this patch such redundant TT entries are avoided. Signed-off-by: Linus Lüssing <[email protected]> Signed-off-by: Sven Eckelmann <[email protected]> Signed-off-by: Simon Wunderlich <[email protected]>
1 parent 5c50680 commit 390dcd4

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

net/batman-adv/multicast.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ batadv_mcast_mla_softif_get_ipv4(struct net_device *dev,
230230

231231
for (pmc = rcu_dereference(in_dev->mc_list); pmc;
232232
pmc = rcu_dereference(pmc->next_rcu)) {
233+
if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES &&
234+
ipv4_is_local_multicast(pmc->multiaddr))
235+
continue;
236+
233237
ip_eth_mc_map(pmc->multiaddr, mcast_addr);
234238

235239
if (batadv_mcast_mla_is_duplicate(mcast_addr, mcast_list))
@@ -293,6 +297,10 @@ batadv_mcast_mla_softif_get_ipv6(struct net_device *dev,
293297
IPV6_ADDR_SCOPE_LINKLOCAL)
294298
continue;
295299

300+
if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES &&
301+
ipv6_addr_is_ll_all_nodes(&pmc6->mca_addr))
302+
continue;
303+
296304
ipv6_eth_mc_map(&pmc6->mca_addr, mcast_addr);
297305

298306
if (batadv_mcast_mla_is_duplicate(mcast_addr, mcast_list))
@@ -413,9 +421,8 @@ static int batadv_mcast_mla_bridge_get(struct net_device *dev,
413421
struct batadv_mcast_mla_flags *flags)
414422
{
415423
struct list_head bridge_mcast_list = LIST_HEAD_INIT(bridge_mcast_list);
416-
bool all_ipv4 = flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV4;
417-
bool all_ipv6 = flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV6;
418424
struct br_ip_list *br_ip_entry, *tmp;
425+
u8 tvlv_flags = flags->tvlv_flags;
419426
struct batadv_hw_addr *new;
420427
u8 mcast_addr[ETH_ALEN];
421428
int ret;
@@ -428,11 +435,25 @@ static int batadv_mcast_mla_bridge_get(struct net_device *dev,
428435
goto out;
429436

430437
list_for_each_entry(br_ip_entry, &bridge_mcast_list, list) {
431-
if (all_ipv4 && br_ip_entry->addr.proto == htons(ETH_P_IP))
432-
continue;
438+
if (br_ip_entry->addr.proto == htons(ETH_P_IP)) {
439+
if (tvlv_flags & BATADV_MCAST_WANT_ALL_IPV4)
440+
continue;
433441

434-
if (all_ipv6 && br_ip_entry->addr.proto == htons(ETH_P_IPV6))
435-
continue;
442+
if (tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES &&
443+
ipv4_is_local_multicast(br_ip_entry->addr.u.ip4))
444+
continue;
445+
}
446+
447+
#if IS_ENABLED(CONFIG_IPV6)
448+
if (br_ip_entry->addr.proto == htons(ETH_P_IPV6)) {
449+
if (tvlv_flags & BATADV_MCAST_WANT_ALL_IPV6)
450+
continue;
451+
452+
if (tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES &&
453+
ipv6_addr_is_ll_all_nodes(&br_ip_entry->addr.u.ip6))
454+
continue;
455+
}
456+
#endif
436457

437458
batadv_mcast_mla_br_addr_cpy(mcast_addr, &br_ip_entry->addr);
438459
if (batadv_mcast_mla_is_duplicate(mcast_addr, mcast_list))

0 commit comments

Comments
 (0)