tunneling: Add generic UDP-Tunnel TSO.
Subsystems (5)
PATCH 3/4 tunneling: Add generic UDP-Tunnel TSO.
Adds generic tunneling TCP segment offloading support for IPv4-UDP based tunnels.
GSO type is added to request this offload for a skb. netdev feature NETIF_F_UDP_TUNNEL is added for hardware offloaded udp-tunnel support. Currently no device supports this feature, software offload is used.
This can be used by tunneling protocols like VXLAN.
--- include/linux/netdev_features.h | 7 ++- include/linux/skbuff.h | 2 + net/ipv4/af_inet.c | 6 ++- net/ipv4/tcp.c | 1 + net/ipv4/udp.c | 113 ++++++++++++++++++++++++++++++--------- net/ipv6/ip6_offload.c | 1 + net/ipv6/udp_offload.c | 10 +++- 7 files changed, 109 insertions(+), 31 deletions(-)
include/linux/netdev_features.h +4 -3
@@ -42,9 +42,9 @@ enum {NETIF_F_TSO6_BIT ,/* ... TCPv6 segmentation */ NETIF_F_FSO_BIT ,/* ... FCoE segmentation */ NETIF_F_GSO_GRE_BIT ,/* ... GRE with TSO */ -/**/ NETIF_F_GSO_LAST ,/* [can't be last bit, see GSO_MASK] */ -NETIF_F_GSO_RESERVED2 /* ... free (fill GSO_MASK to 8 bits) */ - =NETIF_F_GSO_LAST , +NETIF_F_GSO_UDP_TUNNEL_BIT ,/* ... UDP TUNNEL with TSO */ +/**/ NETIF_F_GSO_LAST =/* last bit, see GSO_MASK */ +NETIF_F_GSO_UDP_TUNNEL_BIT ,NETIF_F_FCOE_CRC_BIT ,/* FCoE CRC32 */ NETIF_F_SCTP_CSUM_BIT, /* SCTP checksum offload */
@@ -103,6 +103,7 @@ enum {#define NETIF_F_RXFCS __NETIF_F(RXFCS)#define NETIF_F_RXALL __NETIF_F(RXALL)#define NETIF_F_GRE_GSO __NETIF_F(GSO_GRE) +#define NETIF_F_UDP_TUNNEL __NETIF_F(UDP_TUNNEL)/* Features valid for ethtool to change */ /* = all defined minus driver/device-class-related */
include/linux/skbuff.h +2 -0
@@ -316,6 +316,8 @@ enum {SKB_GSO_FCOE =1 <<5 ,SKB_GSO_GRE =1 <<6 , + + SKB_GSO_UDP_TUNNEL = 1 << 7, };#if BITS_PER_LONG >32
net/ipv4/af_inet.c +5 -1
@@ -1278,6 +1278,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb,int ihl;int id;unsigned int offset =0 ; +bool tunnel;if (!(features &NETIF_F_V4_CSUM )) features &= ~NETIF_F_SG ;
@@ -1288,6 +1289,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb,SKB_GSO_DODGY |SKB_GSO_TCP_ECN |SKB_GSO_GRE | +SKB_GSO_UDP_TUNNEL | 0))) goto out;
@@ -1302,6 +1304,8 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb,if (unlikely (!pskb_may_pull (skb, ihl))) goto out; + tunnel = !!skb->encapsulation; +__skb_pull (skb, ihl);skb_reset_transport_header (skb); iph =ip_hdr (skb);
@@ -1321,7 +1325,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, skb = segs; do { iph = ip_hdr(skb); - if (proto == IPPROTO_UDP) { + if (!tunnel && proto == IPPROTO_UDP) { iph->id = htons(id); iph->frag_off = htons(offset >> 3); if (skb->next != NULL)
net/ipv4/tcp.c +1 -0
@@ -3044,6 +3044,7 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb,SKB_GSO_TCP_ECN |SKB_GSO_TCPV6 |SKB_GSO_GRE | +SKB_GSO_UDP_TUNNEL | 0) || !(type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)))) goto out;
net/ipv4/udp.c +88 -25
145 lines not on this page · raw message
net/ipv6/ip6_offload.c +1 -0
@@ -100,6 +100,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,SKB_GSO_DODGY |SKB_GSO_TCP_ECN |SKB_GSO_GRE | +SKB_GSO_UDP_TUNNEL |SKB_GSO_TCPV6 | 0))) goto out;
net/ipv6/udp_offload.c +8 -2
@@ -21,6 +21,10 @@ static int udp6_ufo_send_check(struct sk_buff *skb)const struct ipv6hdr *ipv6h;struct udphdr *uh; +/* UDP Tunnel offload on ipv6 is not yet supported. */ +if (skb->encapsulation) +return -EINVAL ; +if (!pskb_may_pull (skb,sizeof (*uh)))return -EINVAL ;
@@ -56,8 +60,10 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,/* Packet is from an untrusted source, reset gso_segs. */ int type =skb_shinfo (skb)->gso_type; -if (unlikely (type & ~(SKB_GSO_UDP |SKB_GSO_DODGY | -SKB_GSO_GRE ) || +if (unlikely (type & ~(SKB_GSO_UDP | +SKB_GSO_DODGY | +SKB_GSO_UDP_TUNNEL | +SKB_GSO_GRE ) || !(type & (SKB_GSO_UDP )))) goto out;
Signature · 1 line
1.7.1
net/ipv4/udp.c void __init udp_init(void) · line 2315
Quoted 5 lines · Pravin B Shelar
net/ipv4/udp.c +5
-0+/* segment inner packet. */ + segs =skb_mac_gso_segment (skb, skb->dev->hw_enc_features); +if (!segs ||IS_ERR (segs)) + goto out; +
It seems that hw_enc_features is 0 for all devices.
We should at least inherit NETIF_F_SG
(and presumably netdev_fix_features() should not remove NETIF_F_SG if CSUM is not supported, as we now copy the data _if_ needed in skb_checksum_help())
Quoted 10 lines · Eric Dumazet
net/ipv4/udp.c void __init udp_init(void) · line 2315
Quoted 5 lines · Pravin B Shelar
net/ipv4/udp.c +5
-0+/* segment inner packet. */ + segs =skb_mac_gso_segment (skb, skb->dev->hw_enc_features); +if (!segs ||IS_ERR (segs)) + goto out; +It seems that
hw_enc_featuresis 0 for all devices.
right.
Quoted 2 lines
We should at least inherit
NETIF_F_SG
ok.
Quoted 4 lines
(and presumably
netdev_fix_features()should not removeNETIF_F_SGif CSUM is not supported, as we now copy the data _if_ needed inskb_checksum_help())
yes, that is useful. I have separate patch to kill this dependency, I will sent it.
Thanks.
2013/2/16 Pravin B Shelar <[email protected]>:
Quoted 39 lines
Adds generic tunneling TCP segment offloading support for IPv4-UDP based tunnels.
GSO type is added to request this offload for a skb. netdev featureNETIF_F_UDP_TUNNELis added for hardware offloaded udp-tunnel support. Currently no device supports this feature, software offload is used.This can be used by tunneling protocols like VXLAN.
CC Jesse Gross <[email protected]>Signed-off-by Pravin B Shelar <[email protected]>--- include/linux/netdev_features.h | 7 ++- include/linux/skbuff.h | 2 + net/ipv4/af_inet.c | 6 ++- net/ipv4/tcp.c | 1 + net/ipv4/udp.c | 113 ++++++++++++++++++++++++++++++--------- net/ipv6/ip6_offload.c | 1 + net/ipv6/udp_offload.c | 10 +++- 7 files changed, 109 insertions(+), 31 deletions(-)include/linux/netdev_features.h +3
-3@@ -42,9 +42,9 @@ enum {NETIF_F_TSO6_BIT ,/* ... TCPv6 segmentation */ NETIF_F_FSO_BIT ,/* ... FCoE segmentation */ NETIF_F_GSO_GRE_BIT ,/* ... GRE with TSO */ -/**/ NETIF_F_GSO_LAST ,/* [can't be last bit, see GSO_MASK] */ -NETIF_F_GSO_RESERVED2 /* ... free (fill GSO_MASK to 8 bits) */ - =NETIF_F_GSO_LAST , +NETIF_F_GSO_UDP_TUNNEL_BIT ,/* ... UDP TUNNEL with TSO */ +/**/ NETIF_F_GSO_LAST =/* last bit, see GSO_MASK */ +NETIF_F_GSO_UDP_TUNNEL_BIT ,NETIF_F_FCOE_CRC_BIT ,/* FCoE CRC32 */ NETIF_F_SCTP_CSUM_BIT, /* SCTP checksum offload */
include/linux/netdev_features.h enum { · line 106
Quoted 4 lines
include/linux/netdev_features.h +1
-0@@ -103,6 +103,7 @@ enum {#define NETIF_F_RXFCS __NETIF_F(RXFCS)#define NETIF_F_RXALL __NETIF_F(RXALL)#define NETIF_F_GRE_GSO __NETIF_F(GSO_GRE) +#define NETIF_F_UDP_TUNNEL __NETIF_F(UDP_TUNNEL)
You might want to add it to NETIF_F_GSO_SOFTWARE mask since this feature has software fallback.
Best Regards,
Michał Mirosław