summaryrefslogtreecommitdiffstats
path: root/net/netlink/af_netlink.c
diff options
context:
space:
mode:
authorCong Wang <xiyou.wangcong@gmail.com>2017-12-07 00:03:20 +0100
committerDavid S. Miller <davem@davemloft.net>2017-12-11 16:56:55 +0100
commitb1042d356305cd183459dea145fd59c0f7491e00 (patch)
tree63526e2298526f0d7de20b826de772385b1fd3aa /net/netlink/af_netlink.c
parentnetlink: make netlink tap per netns (diff)
downloadlinux-b1042d356305cd183459dea145fd59c0f7491e00.tar.xz
linux-b1042d356305cd183459dea145fd59c0f7491e00.zip
netlink: convert netlink tap spinlock to mutex
Both netlink_add_tap() and netlink_remove_tap() are called in process context, no need to bother spinlock. Note, in fact, currently we always hold RTNL when calling these two functions, so we don't need any other lock at all, but keeping this lock doesn't harm anything. Cc: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to '')
-rw-r--r--net/netlink/af_netlink.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 1dda94c9695a..b0fe1fb12b99 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -176,7 +176,7 @@ static unsigned int netlink_tap_net_id;
struct netlink_tap_net {
struct list_head netlink_tap_all;
- spinlock_t netlink_tap_lock;
+ struct mutex netlink_tap_lock;
};
int netlink_add_tap(struct netlink_tap *nt)
@@ -187,9 +187,9 @@ int netlink_add_tap(struct netlink_tap *nt)
if (unlikely(nt->dev->type != ARPHRD_NETLINK))
return -EINVAL;
- spin_lock(&nn->netlink_tap_lock);
+ mutex_lock(&nn->netlink_tap_lock);
list_add_rcu(&nt->list, &nn->netlink_tap_all);
- spin_unlock(&nn->netlink_tap_lock);
+ mutex_unlock(&nn->netlink_tap_lock);
__module_get(nt->module);
@@ -204,7 +204,7 @@ static int __netlink_remove_tap(struct netlink_tap *nt)
bool found = false;
struct netlink_tap *tmp;
- spin_lock(&nn->netlink_tap_lock);
+ mutex_lock(&nn->netlink_tap_lock);
list_for_each_entry(tmp, &nn->netlink_tap_all, list) {
if (nt == tmp) {
@@ -216,7 +216,7 @@ static int __netlink_remove_tap(struct netlink_tap *nt)
pr_warn("__netlink_remove_tap: %p not found\n", nt);
out:
- spin_unlock(&nn->netlink_tap_lock);
+ mutex_unlock(&nn->netlink_tap_lock);
if (found)
module_put(nt->module);
@@ -240,7 +240,7 @@ static __net_init int netlink_tap_init_net(struct net *net)
struct netlink_tap_net *nn = net_generic(net, netlink_tap_net_id);
INIT_LIST_HEAD(&nn->netlink_tap_all);
- spin_lock_init(&nn->netlink_tap_lock);
+ mutex_init(&nn->netlink_tap_lock);
return 0;
}