netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] fib_trie: remove duplicated rcu lock
@ 2013-10-13  0:13 baker.kernel
  2013-10-13  3:58 ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: baker.kernel @ 2013-10-13  0:13 UTC (permalink / raw)
  To: davem; +Cc: kuznet, jmorris, yoshfuji, kaber, netdev, linux-kernel,
	baker.zhang

From: "baker.zhang" <baker.kernel@gmail.com>

fib_table_lookup has included the rcu lock protection.

Signed-off-by: baker.zhang <baker.kernel@gmail.com>
---
 net/ipv4/fib_frontend.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index b3f627a..0e9127d 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -170,12 +170,10 @@ static inline unsigned int __inet_dev_addr_type(struct net *net,
 	local_table = fib_get_table(net, RT_TABLE_LOCAL);
 	if (local_table) {
 		ret = RTN_UNICAST;
-		rcu_read_lock();
 		if (!fib_table_lookup(local_table, &fl4, &res, FIB_LOOKUP_NOREF)) {
 			if (!dev || dev == res.fi->fib_dev)
 				ret = res.type;
 		}
-		rcu_read_unlock();
 	}
 	return ret;
 }
@@ -933,7 +931,6 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb)
 		local_bh_disable();
 
 		frn->tb_id = tb->tb_id;
-		rcu_read_lock();
 		frn->err = fib_table_lookup(tb, &fl4, &res, FIB_LOOKUP_NOREF);
 
 		if (!frn->err) {
@@ -942,7 +939,6 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb)
 			frn->type = res.type;
 			frn->scope = res.scope;
 		}
-		rcu_read_unlock();
 		local_bh_enable();
 	}
 }
-- 
1.8.1.2

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

* Re: [PATCH net-next] fib_trie: remove duplicated rcu lock
  2013-10-13  0:13 [PATCH net-next] fib_trie: remove duplicated rcu lock baker.kernel
@ 2013-10-13  3:58 ` Eric Dumazet
  2013-10-13 11:50   ` [PATCH v2 " baker.kernel
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2013-10-13  3:58 UTC (permalink / raw)
  To: baker.kernel
  Cc: davem, kuznet, jmorris, yoshfuji, kaber, netdev, linux-kernel

On Sun, 2013-10-13 at 08:13 +0800, baker.kernel@gmail.com wrote:
> From: "baker.zhang" <baker.kernel@gmail.com>
> 
> fib_table_lookup has included the rcu lock protection.
> 
> Signed-off-by: baker.zhang <baker.kernel@gmail.com>
> ---
>  net/ipv4/fib_frontend.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
> index b3f627a..0e9127d 100644
> --- a/net/ipv4/fib_frontend.c
> +++ b/net/ipv4/fib_frontend.c
> @@ -170,12 +170,10 @@ static inline unsigned int __inet_dev_addr_type(struct net *net,
>  	local_table = fib_get_table(net, RT_TABLE_LOCAL);
>  	if (local_table) {
>  		ret = RTN_UNICAST;
> -		rcu_read_lock();
>  		if (!fib_table_lookup(local_table, &fl4, &res, FIB_LOOKUP_NOREF)) {
>  			if (!dev || dev == res.fi->fib_dev)
>  				ret = res.type;
>  		}
> -		rcu_read_unlock();
>  	}

This looks very wrong.

res.fi could disappear, and we crash.

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

* [PATCH v2 net-next] fib_trie: remove duplicated rcu lock
  2013-10-13  3:58 ` Eric Dumazet
@ 2013-10-13 11:50   ` baker.kernel
  2013-10-18 17:54     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: baker.kernel @ 2013-10-13 11:50 UTC (permalink / raw)
  To: davem, eric.dumazet
  Cc: kuznet, jmorris, yoshfuji, kaber, netdev, linux-kernel,
	baker.zhang

From: "baker.zhang" <baker.kernel@gmail.com>

fib_table_lookup has included the rcu lock protection.

Signed-off-by: baker.zhang <baker.kernel@gmail.com>
---
Thanks for Eric Dumazet's review.
The V1 patch remove a necessary rcu read lock.

 net/ipv4/fib_frontend.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index b3f627a..d846304 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -933,7 +933,6 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb)
 		local_bh_disable();
 
 		frn->tb_id = tb->tb_id;
-		rcu_read_lock();
 		frn->err = fib_table_lookup(tb, &fl4, &res, FIB_LOOKUP_NOREF);
 
 		if (!frn->err) {
@@ -942,7 +941,6 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb)
 			frn->type = res.type;
 			frn->scope = res.scope;
 		}
-		rcu_read_unlock();
 		local_bh_enable();
 	}
 }
-- 
1.8.1.2

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

* Re: [PATCH v2 net-next] fib_trie: remove duplicated rcu lock
  2013-10-13 11:50   ` [PATCH v2 " baker.kernel
@ 2013-10-18 17:54     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2013-10-18 17:54 UTC (permalink / raw)
  To: baker.kernel
  Cc: eric.dumazet, kuznet, jmorris, yoshfuji, kaber, netdev,
	linux-kernel

From: baker.kernel@gmail.com
Date: Sun, 13 Oct 2013 19:50:09 +0800

> From: "baker.zhang" <baker.kernel@gmail.com>
> 
> fib_table_lookup has included the rcu lock protection.
> 
> Signed-off-by: baker.zhang <baker.kernel@gmail.com>

Applied, thanks.

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

end of thread, other threads:[~2013-10-18 17:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-13  0:13 [PATCH net-next] fib_trie: remove duplicated rcu lock baker.kernel
2013-10-13  3:58 ` Eric Dumazet
2013-10-13 11:50   ` [PATCH v2 " baker.kernel
2013-10-18 17:54     ` 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).