mlxsw: spectrum_router: Do not assume RTNL is taken during nexthop init

RTNL is going to be removed from route insertion path, so use
__in_dev_get_rcu() from an RCU read-side critical section instead of
__in_dev_get_rtnl() which assumes RTNL is taken.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Ido Schimmel 2020-02-20 09:07:53 +02:00 committed by David S. Miller
parent eb833eec3b
commit c43ef22843
1 changed files with 6 additions and 2 deletions

View File

@ -3840,10 +3840,14 @@ static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp,
if (!dev)
return 0;
in_dev = __in_dev_get_rtnl(dev);
rcu_read_lock();
in_dev = __in_dev_get_rcu(dev);
if (in_dev && IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev) &&
fib_nh->fib_nh_flags & RTNH_F_LINKDOWN)
fib_nh->fib_nh_flags & RTNH_F_LINKDOWN) {
rcu_read_unlock();
return 0;
}
rcu_read_unlock();
err = mlxsw_sp_nexthop4_type_init(mlxsw_sp, nh, fib_nh);
if (err)