fib_trie: Push rcu_read_lock/unlock to callers
This change is to start cleaning up some of the rcu_read_lock/unlock handling. I realized while reviewing the code there are several spots that I don't believe are being handled correctly or are masking warnings by locally calling rcu_read_lock/unlock instead of calling them at the correct level. A common example is a call to fib_get_table followed by fib_table_lookup. The rcu_read_lock/unlock ought to wrap both but there are several spots where they were not wrapped. Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
98293e8d2f
commit
345e9b5426
@@ -222,16 +222,19 @@ static inline struct fib_table *fib_new_table(struct net *net, u32 id)
|
||||
static inline int fib_lookup(struct net *net, const struct flowi4 *flp,
|
||||
struct fib_result *res)
|
||||
{
|
||||
struct fib_table *table;
|
||||
int err = -ENETUNREACH;
|
||||
|
||||
table = fib_get_table(net, RT_TABLE_LOCAL);
|
||||
if (!fib_table_lookup(table, flp, res, FIB_LOOKUP_NOREF))
|
||||
return 0;
|
||||
rcu_read_lock();
|
||||
|
||||
table = fib_get_table(net, RT_TABLE_MAIN);
|
||||
if (!fib_table_lookup(table, flp, res, FIB_LOOKUP_NOREF))
|
||||
return 0;
|
||||
return -ENETUNREACH;
|
||||
if (!fib_table_lookup(fib_get_table(net, RT_TABLE_LOCAL), flp, res,
|
||||
FIB_LOOKUP_NOREF) ||
|
||||
!fib_table_lookup(fib_get_table(net, RT_TABLE_MAIN), flp, res,
|
||||
FIB_LOOKUP_NOREF))
|
||||
err = 0;
|
||||
|
||||
rcu_read_unlock();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
#else /* CONFIG_IP_MULTIPLE_TABLES */
|
||||
@@ -247,20 +250,25 @@ static inline int fib_lookup(struct net *net, struct flowi4 *flp,
|
||||
struct fib_result *res)
|
||||
{
|
||||
if (!net->ipv4.fib_has_custom_rules) {
|
||||
int err = -ENETUNREACH;
|
||||
|
||||
rcu_read_lock();
|
||||
|
||||
res->tclassid = 0;
|
||||
if (net->ipv4.fib_local &&
|
||||
!fib_table_lookup(net->ipv4.fib_local, flp, res,
|
||||
FIB_LOOKUP_NOREF))
|
||||
return 0;
|
||||
if (net->ipv4.fib_main &&
|
||||
!fib_table_lookup(net->ipv4.fib_main, flp, res,
|
||||
FIB_LOOKUP_NOREF))
|
||||
return 0;
|
||||
if (net->ipv4.fib_default &&
|
||||
!fib_table_lookup(net->ipv4.fib_default, flp, res,
|
||||
FIB_LOOKUP_NOREF))
|
||||
return 0;
|
||||
return -ENETUNREACH;
|
||||
if ((net->ipv4.fib_local &&
|
||||
!fib_table_lookup(net->ipv4.fib_local, flp, res,
|
||||
FIB_LOOKUP_NOREF)) ||
|
||||
(net->ipv4.fib_main &&
|
||||
!fib_table_lookup(net->ipv4.fib_main, flp, res,
|
||||
FIB_LOOKUP_NOREF)) ||
|
||||
(net->ipv4.fib_default &&
|
||||
!fib_table_lookup(net->ipv4.fib_default, flp, res,
|
||||
FIB_LOOKUP_NOREF)))
|
||||
err = 0;
|
||||
|
||||
rcu_read_unlock();
|
||||
|
||||
return err;
|
||||
}
|
||||
return __fib_lookup(net, flp, res);
|
||||
}
|
||||
|
Reference in New Issue
Block a user