aboutsummaryrefslogtreecommitdiff
path: root/net/core/sock_reuseport.c
diff options
context:
space:
mode:
authorAlex Shi <alex.shi@linaro.org>2017-11-30 12:03:38 +0800
committerAlex Shi <alex.shi@linaro.org>2017-11-30 12:03:38 +0800
commit1184d6e8873282bcb4ba1d57da1cdd423a0f42d6 (patch)
tree66bf3b45f218c738312d40e90c52f25069709892 /net/core/sock_reuseport.c
parent382ac60c32998318f133b8b84030aa83a8f600fe (diff)
parent4e22accddef27103c4fba20b9613b7bf52129be6 (diff)
Merge remote-tracking branch 'rt-stable/v4.9-rt' into linux-linaro-lsk-v4.9-rtlsk-v4.9-17.11-rt
Diffstat (limited to 'net/core/sock_reuseport.c')
-rw-r--r--net/core/sock_reuseport.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c
index 9a1a352fd1eb..77f396b679ce 100644
--- a/net/core/sock_reuseport.c
+++ b/net/core/sock_reuseport.c
@@ -36,9 +36,14 @@ int reuseport_alloc(struct sock *sk)
* soft irq of receive path or setsockopt from process context
*/
spin_lock_bh(&reuseport_lock);
- WARN_ONCE(rcu_dereference_protected(sk->sk_reuseport_cb,
- lockdep_is_held(&reuseport_lock)),
- "multiple allocations for the same socket");
+
+ /* Allocation attempts can occur concurrently via the setsockopt path
+ * and the bind/hash path. Nothing to do when we lose the race.
+ */
+ if (rcu_dereference_protected(sk->sk_reuseport_cb,
+ lockdep_is_held(&reuseport_lock)))
+ goto out;
+
reuse = __reuseport_alloc(INIT_SOCKS);
if (!reuse) {
spin_unlock_bh(&reuseport_lock);
@@ -49,6 +54,7 @@ int reuseport_alloc(struct sock *sk)
reuse->num_socks = 1;
rcu_assign_pointer(sk->sk_reuseport_cb, reuse);
+out:
spin_unlock_bh(&reuseport_lock);
return 0;