Message ID | 1415925495-59312-2-git-send-email-joestringer@nicira.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
On Fri, Nov 14, 2014 at 2:38 AM, Joe Stringer <joestringer@nicira.com> wrote: > 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> > --- > v2: Merge helpers for be2net, mlx4, qlcnic > Use (sizeof(struct udphdr) + sizeof(struct vxlanhdr)) > v1: Initial post > --- > drivers/net/vxlan.c | 13 +++++++++++++ > include/net/vxlan.h | 2 ++ > 2 files changed, 15 insertions(+) > > diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c > index fa9dc45..6b65863 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) > 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); Joe, any chance you can make the extra step and inline that in vxlan.h? this is fast path call... you will only need to move struct vxlanhdr there too. Or. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sunday, November 16, 2014 01:35:52 Or Gerlitz wrote: > On Fri, Nov 14, 2014 at 2:38 AM, Joe Stringer <joestringer@nicira.com> wrote: > > 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> > > --- > > v2: Merge helpers for be2net, mlx4, qlcnic > > > > Use (sizeof(struct udphdr) + sizeof(struct vxlanhdr)) > > > > v1: Initial post > > --- > > > > drivers/net/vxlan.c | 13 +++++++++++++ > > include/net/vxlan.h | 2 ++ > > 2 files changed, 15 insertions(+) > > > > diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c > > index fa9dc45..6b65863 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) > > > > 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); > > Joe, any chance you can make the extra step and inline that in > vxlan.h? this is fast path call... you will only need to move struct > vxlanhdr there too. Thanks for looking this over, I sent a patch. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index fa9dc45..6b65863 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) 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, diff --git a/include/net/vxlan.h b/include/net/vxlan.h index d5f59f3..afadf8e 100644 --- a/include/net/vxlan.h +++ b/include/net/vxlan.h @@ -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 */
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> --- v2: Merge helpers for be2net, mlx4, qlcnic Use (sizeof(struct udphdr) + sizeof(struct vxlanhdr)) v1: Initial post --- drivers/net/vxlan.c | 13 +++++++++++++ include/net/vxlan.h | 2 ++ 2 files changed, 15 insertions(+)