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:
Alexander Duyck
2014-12-31 10:56:24 -08:00
committed by David S. Miller
parent 98293e8d2f
commit 345e9b5426
4 changed files with 115 additions and 123 deletions

View File

@@ -81,27 +81,25 @@ static int fib4_rule_action(struct fib_rule *rule, struct flowi *flp,
break;
case FR_ACT_UNREACHABLE:
err = -ENETUNREACH;
goto errout;
return -ENETUNREACH;
case FR_ACT_PROHIBIT:
err = -EACCES;
goto errout;
return -EACCES;
case FR_ACT_BLACKHOLE:
default:
err = -EINVAL;
goto errout;
return -EINVAL;
}
tbl = fib_get_table(rule->fr_net, rule->table);
if (!tbl)
goto errout;
rcu_read_lock();
err = fib_table_lookup(tbl, &flp->u.ip4, (struct fib_result *) arg->result, arg->flags);
if (err > 0)
err = -EAGAIN;
errout:
tbl = fib_get_table(rule->fr_net, rule->table);
if (tbl)
err = fib_table_lookup(tbl, &flp->u.ip4,
(struct fib_result *)arg->result,
arg->flags);
rcu_read_unlock();
return err;
}