tunneling: Add generic Tunnel segmentation.
Subsystems (5)
PATCH 3/4 tunneling: Add generic Tunnel segmentation.
Adds generic tunneling 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.
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/core/ethtool.c | 1 + net/ipv4/af_inet.c | 6 ++- net/ipv4/tcp.c | 1 + net/ipv4/udp.c | 115 ++++++++++++++++++++++++++++++--------- net/ipv6/ip6_offload.c | 1 + net/ipv6/udp_offload.c | 10 +++- 8 files changed, 112 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/core/ethtool.c +1 -0
@@ -78,6 +78,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] [NETIF_F_TSO6_BIT] = "tx-tcp6-segmentation", [NETIF_F_FSO_BIT] = "tx-fcoe-segmentation", [NETIF_F_GSO_GRE_BIT] = "tx-gre-segmentation", + [NETIF_F_GSO_UDP_TUNNEL_BIT] = "tx-udp_tnl-segmentation", [NETIF_F_FCOE_CRC_BIT] = "tx-checksum-fcoe-crc", [NETIF_F_SCTP_CSUM_BIT] = "tx-checksum-sctp",
net/ipv4/af_inet.c +5 -1
@@ -1283,6 +1283,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 ;
@@ -1293,6 +1294,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;
@@ -1307,6 +1309,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);
@@ -1326,7 +1330,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 +90 -25
147 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