summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorFerenc Fejes <fejes@inf.elte.hu>2020-05-30 23:09:00 +0200
committerAlexei Starovoitov <ast@kernel.org>2020-06-01 14:57:14 -0700
commit8ea204c2b658eaef55b4716fde469fb66c589a3d (patch)
treedc158cbccc05c8a068e015ada9d29d4f0a9d42c4 /net/core
parentbb2359f4dbe98e8863b4e885fc09269ef4682ec3 (diff)
net: Make locking in sock_bindtoindex optional
The sock_bindtoindex intended for kernel wide usage however it will lock the socket regardless of the context. This modification relax this behavior optionally: locking the socket will be optional by calling the sock_bindtoindex with lock_sk = true. The modification applied to all users of the sock_bindtoindex. Signed-off-by: Ferenc Fejes <fejes@inf.elte.hu> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/bee6355da40d9e991b2f2d12b67d55ebb5f5b207.1590871065.git.fejes@inf.elte.hu
Diffstat (limited to 'net/core')
-rw-r--r--net/core/sock.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index 61ec573221a6..6c4acf1f0220 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -594,13 +594,15 @@ out:
return ret;
}
-int sock_bindtoindex(struct sock *sk, int ifindex)
+int sock_bindtoindex(struct sock *sk, int ifindex, bool lock_sk)
{
int ret;
- lock_sock(sk);
+ if (lock_sk)
+ lock_sock(sk);
ret = sock_bindtoindex_locked(sk, ifindex);
- release_sock(sk);
+ if (lock_sk)
+ release_sock(sk);
return ret;
}
@@ -646,7 +648,7 @@ static int sock_setbindtodevice(struct sock *sk, char __user *optval,
goto out;
}
- return sock_bindtoindex(sk, index);
+ return sock_bindtoindex(sk, index, true);
out:
#endif