Commit 17452347 authored by Pedro Tammela's avatar Pedro Tammela Committed by David S. Miller

net: rtnl: use rcu_replace_pointer_rtnl in rtnl_unregister_*

With the introduction of the rcu_replace_pointer_rtnl helper,
cleanup the rtnl_unregister_* functions to use the helper instead
of open coding it.
Signed-off-by: default avatarPedro Tammela <pctammela@mojatatu.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarNikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 32da0f00
...@@ -342,8 +342,7 @@ int rtnl_unregister(int protocol, int msgtype) ...@@ -342,8 +342,7 @@ int rtnl_unregister(int protocol, int msgtype)
return -ENOENT; return -ENOENT;
} }
link = rtnl_dereference(tab[msgindex]); link = rcu_replace_pointer_rtnl(tab[msgindex], NULL);
RCU_INIT_POINTER(tab[msgindex], NULL);
rtnl_unlock(); rtnl_unlock();
kfree_rcu(link, rcu); kfree_rcu(link, rcu);
...@@ -368,18 +367,13 @@ void rtnl_unregister_all(int protocol) ...@@ -368,18 +367,13 @@ void rtnl_unregister_all(int protocol)
BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX); BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX);
rtnl_lock(); rtnl_lock();
tab = rtnl_dereference(rtnl_msg_handlers[protocol]); tab = rcu_replace_pointer_rtnl(rtnl_msg_handlers[protocol], NULL);
if (!tab) { if (!tab) {
rtnl_unlock(); rtnl_unlock();
return; return;
} }
RCU_INIT_POINTER(rtnl_msg_handlers[protocol], NULL);
for (msgindex = 0; msgindex < RTM_NR_MSGTYPES; msgindex++) { for (msgindex = 0; msgindex < RTM_NR_MSGTYPES; msgindex++) {
link = rtnl_dereference(tab[msgindex]); link = rcu_replace_pointer_rtnl(tab[msgindex], NULL);
if (!link)
continue;
RCU_INIT_POINTER(tab[msgindex], NULL);
kfree_rcu(link, rcu); kfree_rcu(link, rcu);
} }
rtnl_unlock(); rtnl_unlock();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment