diff options
author | Joe Stringer <joestringer@nicira.com> | 2014-11-13 19:38:12 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-14 17:12:48 -0500 |
commit | 23e62de33d179e229e4c1dfd93f90a3c7355c519 (patch) | |
tree | a08dd11592ac4910158cb478749b092cb81317b0 | |
parent | 8a5809e0dd83831ff38f027786428031289505e6 (diff) |
net: Add vxlan_gso_check() helper
Most NICs that report NETIF_F_GSO_UDP_TUNNEL support VXLAN, and not
other UDP-based encapsulation protocols where the format and size of the
header differs. This patch implements a generic ndo_gso_check() for
VXLAN which will only advertise GSO support when the skb looks like it
contains VXLAN (or no UDP tunnelling at all).
Implementation shamelessly stolen from Tom Herbert:
http://thread.gmane.org/gmane.linux.network/332428/focus=333111
Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/vxlan.c | 13 | ||||
-rw-r--r-- | include/net/vxlan.h | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index fa9dc45b75a6..6b658638b456 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
@@ -1571,6 +1571,19 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb) | |||
1571 | return false; | 1571 | return false; |
1572 | } | 1572 | } |
1573 | 1573 | ||
1574 | bool vxlan_gso_check(struct sk_buff *skb) | ||
1575 | { | ||
1576 | if ((skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL) && | ||
1577 | (skb->inner_protocol_type != ENCAP_TYPE_ETHER || | ||
1578 | skb->inner_protocol != htons(ETH_P_TEB) || | ||
1579 | (skb_inner_mac_header(skb) - skb_transport_header(skb) != | ||
1580 | sizeof(struct udphdr) + sizeof(struct vxlanhdr)))) | ||
1581 | return false; | ||
1582 | |||
1583 | return true; | ||
1584 | } | ||
1585 | EXPORT_SYMBOL_GPL(vxlan_gso_check); | ||
1586 | |||
1574 | #if IS_ENABLED(CONFIG_IPV6) | 1587 | #if IS_ENABLED(CONFIG_IPV6) |
1575 | static int vxlan6_xmit_skb(struct vxlan_sock *vs, | 1588 | static int vxlan6_xmit_skb(struct vxlan_sock *vs, |
1576 | struct dst_entry *dst, struct sk_buff *skb, | 1589 | struct dst_entry *dst, struct sk_buff *skb, |
diff --git a/include/net/vxlan.h b/include/net/vxlan.h index d5f59f3fc35d..afadf8e53f20 100644 --- a/include/net/vxlan.h +++ b/include/net/vxlan.h | |||
@@ -45,6 +45,8 @@ int vxlan_xmit_skb(struct vxlan_sock *vs, | |||
45 | __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df, | 45 | __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df, |
46 | __be16 src_port, __be16 dst_port, __be32 vni, bool xnet); | 46 | __be16 src_port, __be16 dst_port, __be32 vni, bool xnet); |
47 | 47 | ||
48 | bool vxlan_gso_check(struct sk_buff *skb); | ||
49 | |||
48 | /* IP header + UDP + VXLAN + Ethernet header */ | 50 | /* IP header + UDP + VXLAN + Ethernet header */ |
49 | #define VXLAN_HEADROOM (20 + 8 + 8 + 14) | 51 | #define VXLAN_HEADROOM (20 + 8 + 8 + 14) |
50 | /* IPv6 header + UDP + VXLAN + Ethernet header */ | 52 | /* IPv6 header + UDP + VXLAN + Ethernet header */ |