diff options
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/vxlan.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 31ecb03368c6..49d9f2291998 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
@@ -1985,9 +1985,8 @@ static int vxlan_init(struct net_device *dev) | |||
1985 | spin_lock(&vn->sock_lock); | 1985 | spin_lock(&vn->sock_lock); |
1986 | vs = vxlan_find_sock(vxlan->net, ipv6 ? AF_INET6 : AF_INET, | 1986 | vs = vxlan_find_sock(vxlan->net, ipv6 ? AF_INET6 : AF_INET, |
1987 | vxlan->dst_port); | 1987 | vxlan->dst_port); |
1988 | if (vs) { | 1988 | if (vs && atomic_add_unless(&vs->refcnt, 1, 0)) { |
1989 | /* If we have a socket with same port already, reuse it */ | 1989 | /* If we have a socket with same port already, reuse it */ |
1990 | atomic_inc(&vs->refcnt); | ||
1991 | vxlan_vs_add_dev(vs, vxlan); | 1990 | vxlan_vs_add_dev(vs, vxlan); |
1992 | } else { | 1991 | } else { |
1993 | /* otherwise make new socket outside of RTNL */ | 1992 | /* otherwise make new socket outside of RTNL */ |
@@ -2389,12 +2388,9 @@ struct vxlan_sock *vxlan_sock_add(struct net *net, __be16 port, | |||
2389 | 2388 | ||
2390 | spin_lock(&vn->sock_lock); | 2389 | spin_lock(&vn->sock_lock); |
2391 | vs = vxlan_find_sock(net, ipv6 ? AF_INET6 : AF_INET, port); | 2390 | vs = vxlan_find_sock(net, ipv6 ? AF_INET6 : AF_INET, port); |
2392 | if (vs) { | 2391 | if (vs && ((vs->rcv != rcv) || |
2393 | if (vs->rcv == rcv) | 2392 | !atomic_add_unless(&vs->refcnt, 1, 0))) |
2394 | atomic_inc(&vs->refcnt); | ||
2395 | else | ||
2396 | vs = ERR_PTR(-EBUSY); | 2393 | vs = ERR_PTR(-EBUSY); |
2397 | } | ||
2398 | spin_unlock(&vn->sock_lock); | 2394 | spin_unlock(&vn->sock_lock); |
2399 | 2395 | ||
2400 | if (!vs) | 2396 | if (!vs) |