diff options
Diffstat (limited to 'drivers/net/vxlan.c')
-rw-r--r-- | drivers/net/vxlan.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index ca309820d39e..fa9dc45b75a6 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
@@ -275,13 +275,15 @@ static inline struct vxlan_rdst *first_remote_rtnl(struct vxlan_fdb *fdb) | |||
275 | return list_first_entry(&fdb->remotes, struct vxlan_rdst, list); | 275 | return list_first_entry(&fdb->remotes, struct vxlan_rdst, list); |
276 | } | 276 | } |
277 | 277 | ||
278 | /* Find VXLAN socket based on network namespace and UDP port */ | 278 | /* Find VXLAN socket based on network namespace, address family and UDP port */ |
279 | static struct vxlan_sock *vxlan_find_sock(struct net *net, __be16 port) | 279 | static struct vxlan_sock *vxlan_find_sock(struct net *net, |
280 | sa_family_t family, __be16 port) | ||
280 | { | 281 | { |
281 | struct vxlan_sock *vs; | 282 | struct vxlan_sock *vs; |
282 | 283 | ||
283 | hlist_for_each_entry_rcu(vs, vs_head(net, port), hlist) { | 284 | hlist_for_each_entry_rcu(vs, vs_head(net, port), hlist) { |
284 | if (inet_sk(vs->sock->sk)->inet_sport == port) | 285 | if (inet_sk(vs->sock->sk)->inet_sport == port && |
286 | inet_sk(vs->sock->sk)->sk.sk_family == family) | ||
285 | return vs; | 287 | return vs; |
286 | } | 288 | } |
287 | return NULL; | 289 | return NULL; |
@@ -300,11 +302,12 @@ static struct vxlan_dev *vxlan_vs_find_vni(struct vxlan_sock *vs, u32 id) | |||
300 | } | 302 | } |
301 | 303 | ||
302 | /* Look up VNI in a per net namespace table */ | 304 | /* Look up VNI in a per net namespace table */ |
303 | static struct vxlan_dev *vxlan_find_vni(struct net *net, u32 id, __be16 port) | 305 | static struct vxlan_dev *vxlan_find_vni(struct net *net, u32 id, |
306 | sa_family_t family, __be16 port) | ||
304 | { | 307 | { |
305 | struct vxlan_sock *vs; | 308 | struct vxlan_sock *vs; |
306 | 309 | ||
307 | vs = vxlan_find_sock(net, port); | 310 | vs = vxlan_find_sock(net, family, port); |
308 | if (!vs) | 311 | if (!vs) |
309 | return NULL; | 312 | return NULL; |
310 | 313 | ||
@@ -621,6 +624,8 @@ static int vxlan_gro_complete(struct sk_buff *skb, int nhoff) | |||
621 | int vxlan_len = sizeof(struct vxlanhdr) + sizeof(struct ethhdr); | 624 | int vxlan_len = sizeof(struct vxlanhdr) + sizeof(struct ethhdr); |
622 | int err = -ENOSYS; | 625 | int err = -ENOSYS; |
623 | 626 | ||
627 | udp_tunnel_gro_complete(skb, nhoff); | ||
628 | |||
624 | eh = (struct ethhdr *)(skb->data + nhoff + sizeof(struct vxlanhdr)); | 629 | eh = (struct ethhdr *)(skb->data + nhoff + sizeof(struct vxlanhdr)); |
625 | type = eh->h_proto; | 630 | type = eh->h_proto; |
626 | 631 | ||
@@ -1771,7 +1776,8 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, | |||
1771 | struct vxlan_dev *dst_vxlan; | 1776 | struct vxlan_dev *dst_vxlan; |
1772 | 1777 | ||
1773 | ip_rt_put(rt); | 1778 | ip_rt_put(rt); |
1774 | dst_vxlan = vxlan_find_vni(vxlan->net, vni, dst_port); | 1779 | dst_vxlan = vxlan_find_vni(vxlan->net, vni, |
1780 | dst->sa.sa_family, dst_port); | ||
1775 | if (!dst_vxlan) | 1781 | if (!dst_vxlan) |
1776 | goto tx_error; | 1782 | goto tx_error; |
1777 | vxlan_encap_bypass(skb, vxlan, dst_vxlan); | 1783 | vxlan_encap_bypass(skb, vxlan, dst_vxlan); |
@@ -1825,7 +1831,8 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, | |||
1825 | struct vxlan_dev *dst_vxlan; | 1831 | struct vxlan_dev *dst_vxlan; |
1826 | 1832 | ||
1827 | dst_release(ndst); | 1833 | dst_release(ndst); |
1828 | dst_vxlan = vxlan_find_vni(vxlan->net, vni, dst_port); | 1834 | dst_vxlan = vxlan_find_vni(vxlan->net, vni, |
1835 | dst->sa.sa_family, dst_port); | ||
1829 | if (!dst_vxlan) | 1836 | if (!dst_vxlan) |
1830 | goto tx_error; | 1837 | goto tx_error; |
1831 | vxlan_encap_bypass(skb, vxlan, dst_vxlan); | 1838 | vxlan_encap_bypass(skb, vxlan, dst_vxlan); |
@@ -1985,13 +1992,15 @@ static int vxlan_init(struct net_device *dev) | |||
1985 | struct vxlan_dev *vxlan = netdev_priv(dev); | 1992 | struct vxlan_dev *vxlan = netdev_priv(dev); |
1986 | struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); | 1993 | struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); |
1987 | struct vxlan_sock *vs; | 1994 | struct vxlan_sock *vs; |
1995 | bool ipv6 = vxlan->flags & VXLAN_F_IPV6; | ||
1988 | 1996 | ||
1989 | dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); | 1997 | dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); |
1990 | if (!dev->tstats) | 1998 | if (!dev->tstats) |
1991 | return -ENOMEM; | 1999 | return -ENOMEM; |
1992 | 2000 | ||
1993 | spin_lock(&vn->sock_lock); | 2001 | spin_lock(&vn->sock_lock); |
1994 | vs = vxlan_find_sock(vxlan->net, vxlan->dst_port); | 2002 | vs = vxlan_find_sock(vxlan->net, ipv6 ? AF_INET6 : AF_INET, |
2003 | vxlan->dst_port); | ||
1995 | if (vs) { | 2004 | if (vs) { |
1996 | /* If we have a socket with same port already, reuse it */ | 2005 | /* If we have a socket with same port already, reuse it */ |
1997 | atomic_inc(&vs->refcnt); | 2006 | atomic_inc(&vs->refcnt); |
@@ -2382,6 +2391,7 @@ struct vxlan_sock *vxlan_sock_add(struct net *net, __be16 port, | |||
2382 | { | 2391 | { |
2383 | struct vxlan_net *vn = net_generic(net, vxlan_net_id); | 2392 | struct vxlan_net *vn = net_generic(net, vxlan_net_id); |
2384 | struct vxlan_sock *vs; | 2393 | struct vxlan_sock *vs; |
2394 | bool ipv6 = flags & VXLAN_F_IPV6; | ||
2385 | 2395 | ||
2386 | vs = vxlan_socket_create(net, port, rcv, data, flags); | 2396 | vs = vxlan_socket_create(net, port, rcv, data, flags); |
2387 | if (!IS_ERR(vs)) | 2397 | if (!IS_ERR(vs)) |
@@ -2391,7 +2401,7 @@ struct vxlan_sock *vxlan_sock_add(struct net *net, __be16 port, | |||
2391 | return vs; | 2401 | return vs; |
2392 | 2402 | ||
2393 | spin_lock(&vn->sock_lock); | 2403 | spin_lock(&vn->sock_lock); |
2394 | vs = vxlan_find_sock(net, port); | 2404 | vs = vxlan_find_sock(net, ipv6 ? AF_INET6 : AF_INET, port); |
2395 | if (vs) { | 2405 | if (vs) { |
2396 | if (vs->rcv == rcv) | 2406 | if (vs->rcv == rcv) |
2397 | atomic_inc(&vs->refcnt); | 2407 | atomic_inc(&vs->refcnt); |
@@ -2550,7 +2560,8 @@ static int vxlan_newlink(struct net *net, struct net_device *dev, | |||
2550 | nla_get_u8(data[IFLA_VXLAN_UDP_ZERO_CSUM6_RX])) | 2560 | nla_get_u8(data[IFLA_VXLAN_UDP_ZERO_CSUM6_RX])) |
2551 | vxlan->flags |= VXLAN_F_UDP_ZERO_CSUM6_RX; | 2561 | vxlan->flags |= VXLAN_F_UDP_ZERO_CSUM6_RX; |
2552 | 2562 | ||
2553 | if (vxlan_find_vni(net, vni, vxlan->dst_port)) { | 2563 | if (vxlan_find_vni(net, vni, use_ipv6 ? AF_INET6 : AF_INET, |
2564 | vxlan->dst_port)) { | ||
2554 | pr_info("duplicate VNI %u\n", vni); | 2565 | pr_info("duplicate VNI %u\n", vni); |
2555 | return -EEXIST; | 2566 | return -EEXIST; |
2556 | } | 2567 | } |