Skip to content

Commit cb32f51

Browse files
edumazetdavem330
authored andcommitted
ipip: add GSO/TSO support
Now inet_gso_segment() is stackable, its relatively easy to implement GSO/TSO support for IPIP Performance results, when segmentation is done after tunnel device (as no NIC is yet enabled for TSO IPIP support) : Before patch : lpq83:~# ./netperf -H 7.7.9.84 -Cc MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 7.7.9.84 () port 0 AF_INET Recv Send Send Utilization Service Demand Socket Socket Message Elapsed Send Recv Send Recv Size Size Size Time Throughput local remote local remote bytes bytes bytes secs. 10^6bits/s % S % S us/KB us/KB 87380 16384 16384 10.00 3357.88 5.09 3.70 2.983 2.167 After patch : lpq83:~# ./netperf -H 7.7.9.84 -Cc MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 7.7.9.84 () port 0 AF_INET Recv Send Send Utilization Service Demand Socket Socket Message Elapsed Send Recv Send Recv Size Size Size Time Throughput local remote local remote bytes bytes bytes secs. 10^6bits/s % S % S us/KB us/KB 87380 16384 16384 10.00 7710.19 4.52 6.62 1.152 1.687 Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3347c96 commit cb32f51

File tree

11 files changed

+29
-8
lines changed

11 files changed

+29
-8
lines changed

include/linux/netdev_features.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ enum {
4242
NETIF_F_TSO6_BIT, /* ... TCPv6 segmentation */
4343
NETIF_F_FSO_BIT, /* ... FCoE segmentation */
4444
NETIF_F_GSO_GRE_BIT, /* ... GRE with TSO */
45+
NETIF_F_GSO_IPIP_BIT, /* ... IPIP tunnel with TSO */
4546
NETIF_F_GSO_UDP_TUNNEL_BIT, /* ... UDP TUNNEL with TSO */
4647
NETIF_F_GSO_MPLS_BIT, /* ... MPLS segmentation */
4748
/**/NETIF_F_GSO_LAST = /* last bit, see GSO_MASK */
@@ -107,6 +108,7 @@ enum {
107108
#define NETIF_F_RXFCS __NETIF_F(RXFCS)
108109
#define NETIF_F_RXALL __NETIF_F(RXALL)
109110
#define NETIF_F_GSO_GRE __NETIF_F(GSO_GRE)
111+
#define NETIF_F_GSO_IPIP __NETIF_F(GSO_IPIP)
110112
#define NETIF_F_GSO_UDP_TUNNEL __NETIF_F(GSO_UDP_TUNNEL)
111113
#define NETIF_F_GSO_MPLS __NETIF_F(GSO_MPLS)
112114
#define NETIF_F_HW_VLAN_STAG_FILTER __NETIF_F(HW_VLAN_STAG_FILTER)

include/linux/skbuff.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,11 @@ enum {
318318

319319
SKB_GSO_GRE = 1 << 6,
320320

321-
SKB_GSO_UDP_TUNNEL = 1 << 7,
321+
SKB_GSO_IPIP = 1 << 7,
322322

323-
SKB_GSO_MPLS = 1 << 8,
323+
SKB_GSO_UDP_TUNNEL = 1 << 8,
324+
325+
SKB_GSO_MPLS = 1 << 9,
324326
};
325327

326328
#if BITS_PER_LONG > 32

net/core/ethtool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN]
8181
[NETIF_F_TSO6_BIT] = "tx-tcp6-segmentation",
8282
[NETIF_F_FSO_BIT] = "tx-fcoe-segmentation",
8383
[NETIF_F_GSO_GRE_BIT] = "tx-gre-segmentation",
84+
[NETIF_F_GSO_IPIP_BIT] = "tx-ipip-segmentation",
8485
[NETIF_F_GSO_UDP_TUNNEL_BIT] = "tx-udp_tnl-segmentation",
8586
[NETIF_F_GSO_MPLS_BIT] = "tx-mpls-segmentation",
8687

net/ipv4/af_inet.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb,
12911291
SKB_GSO_DODGY |
12921292
SKB_GSO_TCP_ECN |
12931293
SKB_GSO_GRE |
1294+
SKB_GSO_IPIP |
12941295
SKB_GSO_TCPV6 |
12951296
SKB_GSO_UDP_TUNNEL |
12961297
SKB_GSO_MPLS |
@@ -1656,6 +1657,13 @@ static struct packet_offload ip_packet_offload __read_mostly = {
16561657
},
16571658
};
16581659

1660+
static const struct net_offload ipip_offload = {
1661+
.callbacks = {
1662+
.gso_send_check = inet_gso_send_check,
1663+
.gso_segment = inet_gso_segment,
1664+
},
1665+
};
1666+
16591667
static int __init ipv4_offload_init(void)
16601668
{
16611669
/*
@@ -1667,6 +1675,7 @@ static int __init ipv4_offload_init(void)
16671675
pr_crit("%s: Cannot add TCP protocol offload\n", __func__);
16681676

16691677
dev_add_offload(&ip_packet_offload);
1678+
inet_add_offload(&ipip_offload, IPPROTO_IPIP);
16701679
return 0;
16711680
}
16721681

net/ipv4/gre_offload.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
3939
SKB_GSO_UDP |
4040
SKB_GSO_DODGY |
4141
SKB_GSO_TCP_ECN |
42-
SKB_GSO_GRE)))
42+
SKB_GSO_GRE |
43+
SKB_GSO_IPIP)))
4344
goto out;
4445

4546
if (unlikely(!pskb_may_pull(skb, sizeof(*greh))))

net/ipv4/ipip.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,17 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
220220
if (unlikely(skb->protocol != htons(ETH_P_IP)))
221221
goto tx_error;
222222

223-
if (likely(!skb->encapsulation)) {
224-
skb_reset_inner_headers(skb);
225-
skb->encapsulation = 1;
226-
}
223+
skb = iptunnel_handle_offloads(skb, false, SKB_GSO_IPIP);
224+
if (IS_ERR(skb))
225+
goto out;
227226

228227
ip_tunnel_xmit(skb, dev, tiph, tiph->protocol);
229228
return NETDEV_TX_OK;
230229

231230
tx_error:
232-
dev->stats.tx_errors++;
233231
dev_kfree_skb(skb);
232+
out:
233+
dev->stats.tx_errors++;
234234
return NETDEV_TX_OK;
235235
}
236236

@@ -275,6 +275,7 @@ static const struct net_device_ops ipip_netdev_ops = {
275275
#define IPIP_FEATURES (NETIF_F_SG | \
276276
NETIF_F_FRAGLIST | \
277277
NETIF_F_HIGHDMA | \
278+
NETIF_F_GSO_SOFTWARE | \
278279
NETIF_F_HW_CSUM)
279280

280281
static void ipip_tunnel_setup(struct net_device *dev)

net/ipv4/tcp_offload.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
5656
SKB_GSO_TCP_ECN |
5757
SKB_GSO_TCPV6 |
5858
SKB_GSO_GRE |
59+
SKB_GSO_IPIP |
5960
SKB_GSO_MPLS |
6061
SKB_GSO_UDP_TUNNEL |
6162
0) ||

net/ipv4/udp_offload.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
5252

5353
if (unlikely(type & ~(SKB_GSO_UDP | SKB_GSO_DODGY |
5454
SKB_GSO_UDP_TUNNEL |
55+
SKB_GSO_IPIP |
5556
SKB_GSO_GRE | SKB_GSO_MPLS) ||
5657
!(type & (SKB_GSO_UDP))))
5758
goto out;

net/ipv6/ip6_offload.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
9696
SKB_GSO_DODGY |
9797
SKB_GSO_TCP_ECN |
9898
SKB_GSO_GRE |
99+
SKB_GSO_IPIP |
99100
SKB_GSO_UDP_TUNNEL |
100101
SKB_GSO_MPLS |
101102
SKB_GSO_TCPV6 |

net/ipv6/udp_offload.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
6464
SKB_GSO_DODGY |
6565
SKB_GSO_UDP_TUNNEL |
6666
SKB_GSO_GRE |
67+
SKB_GSO_IPIP |
6768
SKB_GSO_MPLS) ||
6869
!(type & (SKB_GSO_UDP))))
6970
goto out;

0 commit comments

Comments
 (0)