* [PATCH v2] batman-adv: Get inet(6) device inside RCU protected region
@ 2019-06-27 17:22 Sven Eckelmann
2019-06-27 17:48 ` Sven Eckelmann
0 siblings, 1 reply; 2+ messages in thread
From: Sven Eckelmann @ 2019-06-27 17:22 UTC (permalink / raw)
To: b.a.t.m.a.n
It is not necessary to get the inet(6)_dev outside of the rcu protected
region by using reference counting. Instead, the in(6)_dev_get can be
replaced by the non-refcnt function and everything can be moved inside the
rcu protected region.
Fixes: 0a7733468f95 ("batman-adv: mcast: detect, distribute and maintain multicast router presence")
Reported-by: David Miller <davem@davemloft.net>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
v2:
* leave read_lock_bh for in6_dev->mc_list
net/batman-adv/multicast.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index 40ceab95..67d7f830 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -379,11 +379,14 @@ batadv_mcast_mla_softif_get_ipv4(struct net_device *dev,
if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV4)
return 0;
- in_dev = in_dev_get(dev);
- if (!in_dev)
+ rcu_read_lock();
+
+ in_dev = __in_dev_get_rcu(dev);
+ if (!in_dev) {
+ rcu_read_unlock();
return 0;
+ }
- rcu_read_lock();
for (pmc = rcu_dereference(in_dev->mc_list); pmc;
pmc = rcu_dereference(pmc->next_rcu)) {
if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES &&
@@ -410,7 +413,6 @@ batadv_mcast_mla_softif_get_ipv4(struct net_device *dev,
ret++;
}
rcu_read_unlock();
- in_dev_put(in_dev);
return ret;
}
@@ -444,9 +446,13 @@ batadv_mcast_mla_softif_get_ipv6(struct net_device *dev,
if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV6)
return 0;
- in6_dev = in6_dev_get(dev);
- if (!in6_dev)
+ rcu_read_lock();
+
+ in6_dev = __in6_dev_get(dev);
+ if (!in6_dev) {
+ rcu_read_unlock();
return 0;
+ }
read_lock_bh(&in6_dev->lock);
for (pmc6 = in6_dev->mc_list; pmc6; pmc6 = pmc6->next) {
@@ -479,7 +485,7 @@ batadv_mcast_mla_softif_get_ipv6(struct net_device *dev,
ret++;
}
read_unlock_bh(&in6_dev->lock);
- in6_dev_put(in6_dev);
+ rcu_read_unlock();
return ret;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] batman-adv: Get inet(6) device inside RCU protected region
2019-06-27 17:22 [PATCH v2] batman-adv: Get inet(6) device inside RCU protected region Sven Eckelmann
@ 2019-06-27 17:48 ` Sven Eckelmann
0 siblings, 0 replies; 2+ messages in thread
From: Sven Eckelmann @ 2019-06-27 17:48 UTC (permalink / raw)
To: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 527 bytes --]
On Thursday, 27 June 2019 19:22:06 CEST Sven Eckelmann wrote:
> It is not necessary to get the inet(6)_dev outside of the rcu protected
> region by using reference counting. Instead, the in(6)_dev_get can be
> replaced by the non-refcnt function and everything can be moved inside the
> rcu protected region.
>
> Fixes: 0a7733468f95 ("batman-adv: mcast: detect, distribute and maintain multicast router presence")
Fixes: 2b0f11124aad ("batman-adv: mcast: collect softif listeners from IP lists instead")
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-27 17:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-27 17:22 [PATCH v2] batman-adv: Get inet(6) device inside RCU protected region Sven Eckelmann
2019-06-27 17:48 ` Sven Eckelmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.