netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net/ipv6: prefer rcu_access_pointer() over rcu_dereference()
@ 2019-02-15 17:15 Paolo Abeni
  2019-02-15 22:13 ` David Ahern
  2019-02-16  4:26 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Abeni @ 2019-02-15 17:15 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, David Ahern

rt6_cache_allowed_for_pmtu() checks for rt->from presence, but
it does not access the RCU protected pointer. We can use
rcu_access_pointer() and clean-up the code a bit. No functional
changes intended.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/ipv6/route.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index dc066fdf7e46..87a0561136dd 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2277,14 +2277,8 @@ static void rt6_do_update_pmtu(struct rt6_info *rt, u32 mtu)
 
 static bool rt6_cache_allowed_for_pmtu(const struct rt6_info *rt)
 {
-	bool from_set;
-
-	rcu_read_lock();
-	from_set = !!rcu_dereference(rt->from);
-	rcu_read_unlock();
-
 	return !(rt->rt6i_flags & RTF_CACHE) &&
-		(rt->rt6i_flags & RTF_PCPU || from_set);
+		(rt->rt6i_flags & RTF_PCPU || rcu_access_pointer(rt->from));
 }
 
 static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net/ipv6: prefer rcu_access_pointer() over rcu_dereference()
  2019-02-15 17:15 [PATCH net-next] net/ipv6: prefer rcu_access_pointer() over rcu_dereference() Paolo Abeni
@ 2019-02-15 22:13 ` David Ahern
  2019-02-16  4:26 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2019-02-15 22:13 UTC (permalink / raw)
  To: Paolo Abeni, netdev; +Cc: David S. Miller

On 2/15/19 10:15 AM, Paolo Abeni wrote:
> rt6_cache_allowed_for_pmtu() checks for rt->from presence, but
> it does not access the RCU protected pointer. We can use
> rcu_access_pointer() and clean-up the code a bit. No functional
> changes intended.
> 
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
>  net/ipv6/route.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index dc066fdf7e46..87a0561136dd 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -2277,14 +2277,8 @@ static void rt6_do_update_pmtu(struct rt6_info *rt, u32 mtu)
>  
>  static bool rt6_cache_allowed_for_pmtu(const struct rt6_info *rt)
>  {
> -	bool from_set;
> -
> -	rcu_read_lock();
> -	from_set = !!rcu_dereference(rt->from);
> -	rcu_read_unlock();
> -
>  	return !(rt->rt6i_flags & RTF_CACHE) &&
> -		(rt->rt6i_flags & RTF_PCPU || from_set);
> +		(rt->rt6i_flags & RTF_PCPU || rcu_access_pointer(rt->from));
>  }
>  
>  static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk,
> 

good cleanup

Reviewed-by: David Ahern <dsahern@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net/ipv6: prefer rcu_access_pointer() over rcu_dereference()
  2019-02-15 17:15 [PATCH net-next] net/ipv6: prefer rcu_access_pointer() over rcu_dereference() Paolo Abeni
  2019-02-15 22:13 ` David Ahern
@ 2019-02-16  4:26 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-02-16  4:26 UTC (permalink / raw)
  To: pabeni; +Cc: netdev, dsahern

From: Paolo Abeni <pabeni@redhat.com>
Date: Fri, 15 Feb 2019 18:15:37 +0100

> rt6_cache_allowed_for_pmtu() checks for rt->from presence, but
> it does not access the RCU protected pointer. We can use
> rcu_access_pointer() and clean-up the code a bit. No functional
> changes intended.
> 
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-16  4:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-15 17:15 [PATCH net-next] net/ipv6: prefer rcu_access_pointer() over rcu_dereference() Paolo Abeni
2019-02-15 22:13 ` David Ahern
2019-02-16  4:26 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).