Skip to content

Commit

Permalink
Merge branch 'vxlan_gso_check'
Browse files Browse the repository at this point in the history
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: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Nov 14, 2014
2 parents 8a5809e + 795a05c commit b7f4c0b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/net/ethernet/emulex/benet/be_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
};

Expand Down
6 changes: 6 additions & 0 deletions drivers/net/ethernet/mellanox/mlx4/en_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
};

Expand Down
6 changes: 6 additions & 0 deletions drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions drivers/net/vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions include/net/vxlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit b7f4c0b

Please sign in to comment.