Commit b7f4c0ba authored by David S. Miller's avatar David S. Miller

Merge branch 'vxlan_gso_check'

Joe Stringer says:

====================
Implement ndo_gso_check() for vxlan nics

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 may
differ. This patch series implements a generic ndo_gso_check() for detecting
VXLAN, then reuses it for these NICs.

Implementation shamelessly stolen from Tom Herbert (with minor fixups):
http://thread.gmane.org/gmane.linux.network/332428/focus=333111

v2: Drop i40e/fm10k patches (code diverged; handling separately).
    Refactor common code into vxlan_gso_check() helper.
    Minor style fixes.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 8a5809e0 795a05c1
......@@ -4421,6 +4421,11 @@ static void be_del_vxlan_port(struct net_device *netdev, sa_family_t sa_family,
"Disabled VxLAN offloads for UDP port %d\n",
be16_to_cpu(port));
}
static bool be_gso_check(struct sk_buff *skb, struct net_device *dev)
{
return vxlan_gso_check(skb);
}
#endif
static const struct net_device_ops be_netdev_ops = {
......@@ -4450,6 +4455,7 @@ static const struct net_device_ops be_netdev_ops = {
#ifdef CONFIG_BE2NET_VXLAN
.ndo_add_vxlan_port = be_add_vxlan_port,
.ndo_del_vxlan_port = be_del_vxlan_port,
.ndo_gso_check = be_gso_check,
#endif
};
......
......@@ -2355,6 +2355,11 @@ static void mlx4_en_del_vxlan_port(struct net_device *dev,
queue_work(priv->mdev->workqueue, &priv->vxlan_del_task);
}
static bool mlx4_en_gso_check(struct sk_buff *skb, struct net_device *dev)
{
return vxlan_gso_check(skb);
}
#endif
static const struct net_device_ops mlx4_netdev_ops = {
......@@ -2386,6 +2391,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
#ifdef CONFIG_MLX4_EN_VXLAN
.ndo_add_vxlan_port = mlx4_en_add_vxlan_port,
.ndo_del_vxlan_port = mlx4_en_del_vxlan_port,
.ndo_gso_check = mlx4_en_gso_check,
#endif
};
......
......@@ -503,6 +503,11 @@ static void qlcnic_del_vxlan_port(struct net_device *netdev,
adapter->flags |= QLCNIC_DEL_VXLAN_PORT;
}
static bool qlcnic_gso_check(struct sk_buff *skb, struct net_device *dev)
{
return vxlan_gso_check(skb);
}
#endif
static const struct net_device_ops qlcnic_netdev_ops = {
......@@ -526,6 +531,7 @@ static const struct net_device_ops qlcnic_netdev_ops = {
#ifdef CONFIG_QLCNIC_VXLAN
.ndo_add_vxlan_port = qlcnic_add_vxlan_port,
.ndo_del_vxlan_port = qlcnic_del_vxlan_port,
.ndo_gso_check = qlcnic_gso_check,
#endif
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = qlcnic_poll_controller,
......
......@@ -1571,6 +1571,19 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
return false;
}
bool vxlan_gso_check(struct sk_buff *skb)
{
if ((skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL) &&
(skb->inner_protocol_type != ENCAP_TYPE_ETHER ||
skb->inner_protocol != htons(ETH_P_TEB) ||
(skb_inner_mac_header(skb) - skb_transport_header(skb) !=
sizeof(struct udphdr) + sizeof(struct vxlanhdr))))
return false;
return true;
}
EXPORT_SYMBOL_GPL(vxlan_gso_check);
#if IS_ENABLED(CONFIG_IPV6)
static int vxlan6_xmit_skb(struct vxlan_sock *vs,
struct dst_entry *dst, struct sk_buff *skb,
......
......@@ -45,6 +45,8 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
__be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
__be16 src_port, __be16 dst_port, __be32 vni, bool xnet);
bool vxlan_gso_check(struct sk_buff *skb);
/* IP header + UDP + VXLAN + Ethernet header */
#define VXLAN_HEADROOM (20 + 8 + 8 + 14)
/* IPv6 header + UDP + VXLAN + Ethernet header */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment