diff mbox series

[RFC] batman-adv: convert ifmcaddr6 to RCU

Message ID 20210417073209.21651-1-sven@narfation.org
State RFC, archived
Delegated to: Simon Wunderlich
Headers show
Series [RFC] batman-adv: convert ifmcaddr6 to RCU | expand

Commit Message

Sven Eckelmann April 17, 2021, 7:32 a.m. UTC
From: Taehee Yoo <ap420073@gmail.com>

The ifmcaddr6 has been protected by inet6_dev->lock(rwlock) so that
the critical section is atomic context. In order to switch this context,
changing locking is needed. The ifmcaddr6 actually already protected by
RTNL So if it's converted to use RCU, its control path context can be
switched to sleepable.

Suggested-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This patch is already upstream. But the compat code is missing in
batman-adv. So we have to find a way to call the read_lock_bh/read_unlock_bh
without adding it in multicast.c and not to use rcu_dereference without 
removing it from multicast.c... does anyone have an idea?

 net/batman-adv/multicast.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series


diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index 28166402..1d63c8cb 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -454,8 +454,9 @@  batadv_mcast_mla_softif_get_ipv6(struct net_device *dev,
 		return 0;
-	read_lock_bh(&in6_dev->lock);
-	for (pmc6 = in6_dev->mc_list; pmc6; pmc6 = pmc6->next) {
+	for (pmc6 = rcu_dereference(in6_dev->mc_list);
+	     pmc6;
+	     pmc6 = rcu_dereference(pmc6->next)) {
 		if (IPV6_ADDR_MC_SCOPE(&pmc6->mca_addr) <
@@ -484,7 +485,6 @@  batadv_mcast_mla_softif_get_ipv6(struct net_device *dev,
 		hlist_add_head(&new->list, mcast_list);
-	read_unlock_bh(&in6_dev->lock);
 	return ret;