Skip to contentSkip to conversation

fib_trie: remove duplicated rcu lock

PATCH Superseded [email protected] 3 participants 4 messages Oct 13, 2013 – Oct 18, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fib_trie: remove duplicated rcu lock

From: "baker.zhang" <[email protected]>

fib_table_lookup has included the rcu lock protection.

---
 net/ipv4/fib_frontend.c | 4 ----
 1 file changed, 4 deletions(-)
net/ipv4/fib_frontend.c +0 -4
index b3f627a..0e9127d 100644
@@ -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();
 	}
 }
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 14 lines · On Sun, 2013-10-13 at 08:13 +0800, [email protected] wrote:

From: "baker.zhang" <[email protected]>

fib_table_lookup has included the rcu lock protection.

---
 net/ipv4/fib_frontend.c | 4 ----
 1 file changed, 4 deletions(-)
net/ipv4/fib_frontend.c +0 -0
index b3f627a..0e9127d 100644

net/ipv4/fib_frontend.c static inline unsigned int __inet_dev_addr_type(struct net *net, · line 177

Quoted 10 lines
net/ipv4/fib_frontend.c +0 -2
@@ -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.

#2 lore raw

PATCH v2 1/1 fib_trie: remove duplicated rcu lock

From: "baker.zhang" <[email protected]>

fib_table_lookup has included the rcu lock protection.

---
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(-)
net/ipv4/fib_frontend.c +0 -2
index b3f627a..d846304 100644
@@ -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();
 	}
 }
Signature · 1 line
1.8.1.2