diff options
Diffstat (limited to 'net/ipv4/geneve.c')
-rw-r--r-- | net/ipv4/geneve.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/net/ipv4/geneve.c b/net/ipv4/geneve.c index 5a47188b01e9..95e47c97585e 100644 --- a/net/ipv4/geneve.c +++ b/net/ipv4/geneve.c | |||
@@ -296,6 +296,7 @@ struct geneve_sock *geneve_sock_add(struct net *net, __be16 port, | |||
296 | geneve_rcv_t *rcv, void *data, | 296 | geneve_rcv_t *rcv, void *data, |
297 | bool no_share, bool ipv6) | 297 | bool no_share, bool ipv6) |
298 | { | 298 | { |
299 | struct geneve_net *gn = net_generic(net, geneve_net_id); | ||
299 | struct geneve_sock *gs; | 300 | struct geneve_sock *gs; |
300 | 301 | ||
301 | gs = geneve_socket_create(net, port, rcv, data, ipv6); | 302 | gs = geneve_socket_create(net, port, rcv, data, ipv6); |
@@ -305,15 +306,15 @@ struct geneve_sock *geneve_sock_add(struct net *net, __be16 port, | |||
305 | if (no_share) /* Return error if sharing is not allowed. */ | 306 | if (no_share) /* Return error if sharing is not allowed. */ |
306 | return ERR_PTR(-EINVAL); | 307 | return ERR_PTR(-EINVAL); |
307 | 308 | ||
309 | spin_lock(&gn->sock_lock); | ||
308 | gs = geneve_find_sock(net, port); | 310 | gs = geneve_find_sock(net, port); |
309 | if (gs) { | 311 | if (gs && ((gs->rcv != rcv) || |
310 | if (gs->rcv == rcv) | 312 | !atomic_add_unless(&gs->refcnt, 1, 0))) |
311 | atomic_inc(&gs->refcnt); | ||
312 | else | ||
313 | gs = ERR_PTR(-EBUSY); | 313 | gs = ERR_PTR(-EBUSY); |
314 | } else { | 314 | spin_unlock(&gn->sock_lock); |
315 | |||
316 | if (!gs) | ||
315 | gs = ERR_PTR(-EINVAL); | 317 | gs = ERR_PTR(-EINVAL); |
316 | } | ||
317 | 318 | ||
318 | return gs; | 319 | return gs; |
319 | } | 320 | } |