* [PATCH net-next 0/7] IPSec offload improvements
@ 2017-08-01 9:49 ilant
2017-08-01 9:49 ` [PATCH net-next 1/7] esp4: Support RX checksum with crypto offload ilant
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: ilant @ 2017-08-01 9:49 UTC (permalink / raw)
To: Steffen Klassert, netdev; +Cc: Ilan Tayari
From: Ilan Tayari <ilant@mellanox.com>
Hi Steffen,
This patchset introduces several improvements to IPSec offload.
We would like to see these merged in 4.14.
Patches 1-4 add RX checksum offload support.
This gives a big performance boost.
These patches have been submitted before but were not merged.
Note that patches 1-2 changed slightly with a call to skb_pull_rcsum.
Patch 5 adds automatic loading of XFRM offload modules, but only
if crypto-offload is explicitly requested by user.
This avoid issues in the field where user forgets to load the
module manually and so crypto-offload does not happen.
Patch 6 fixes the leftover xfrm_offload in RX SKBs.
This solves some issues with forwarding.
Patch 7 allows IPSec GSO on local sockets, with or without
crypto-offload.
This also gives a large performance boost.
Thanks,
Ilan.
Ilan Tayari (4):
esp4: Support RX checksum with crypto offload
esp6: Support RX checksum with crypto offload
xfrm: Auto-load xfrm offload modules
xfrm: Clear RX SKB secpath xfrm_offload
Steffen Klassert (1):
net: Allow IPsec GSO for local sockets
Yossi Kuperman (2):
xfrm6: Fix CHECKSUM_COMPLETE after IPv6 header push
esp6: Fix RX checksum after header pull
include/net/xfrm.h | 23 ++++++++++++++++++++++-
net/core/sock.c | 2 +-
net/ipv4/esp4.c | 14 +++++++++++---
net/ipv4/esp4_offload.c | 5 ++++-
net/ipv6/esp6.c | 16 +++++++++++++---
net/ipv6/esp6_offload.c | 5 ++++-
net/ipv6/xfrm6_input.c | 4 +++-
net/xfrm/xfrm_device.c | 2 +-
net/xfrm/xfrm_input.c | 2 ++
net/xfrm/xfrm_state.c | 16 ++++++++++++----
net/xfrm/xfrm_user.c | 2 +-
11 files changed, 74 insertions(+), 17 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net-next 1/7] esp4: Support RX checksum with crypto offload
2017-08-01 9:49 [PATCH net-next 0/7] IPSec offload improvements ilant
@ 2017-08-01 9:49 ` ilant
2017-08-01 9:49 ` [PATCH net-next 2/7] esp6: " ilant
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ilant @ 2017-08-01 9:49 UTC (permalink / raw)
To: Steffen Klassert, netdev; +Cc: Ilan Tayari, Ariel Levkovich
From: Ilan Tayari <ilant@mellanox.com>
Keep the device's reported ip_summed indication in case crypto
was offloaded by the device. Subtract the csum values of the
stripped parts (esp header+iv, esp trailer+auth_data) to keep
value correct.
Note: CHECKSUM_COMPLETE should be indicated only if skb->csum
has the post-decryption offload csum value.
Signed-off-by: Ariel Levkovich <lariel@mellanox.com>
Signed-off-by: Ilan Tayari <ilant@mellanox.com>
---
net/ipv4/esp4.c | 14 +++++++++++---
net/ipv4/esp4_offload.c | 4 +++-
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 0cbee0a666ff..741acd7b9646 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -510,7 +510,8 @@ int esp_input_done2(struct sk_buff *skb, int err)
int elen = skb->len - hlen;
int ihl;
u8 nexthdr[2];
- int padlen;
+ int padlen, trimlen;
+ __wsum csumdiff;
if (!xo || (xo && !(xo->flags & CRYPTO_DONE)))
kfree(ESP_SKB_CB(skb)->tmp);
@@ -568,8 +569,15 @@ int esp_input_done2(struct sk_buff *skb, int err)
skb->ip_summed = CHECKSUM_UNNECESSARY;
}
- pskb_trim(skb, skb->len - alen - padlen - 2);
- __skb_pull(skb, hlen);
+ trimlen = alen + padlen + 2;
+ if (skb->ip_summed == CHECKSUM_COMPLETE) {
+ csumdiff = skb_checksum(skb, skb->len - trimlen, trimlen, 0);
+ skb->csum = csum_block_sub(skb->csum, csumdiff,
+ skb->len - trimlen);
+ }
+ pskb_trim(skb, skb->len - trimlen);
+
+ skb_pull_rcsum(skb, hlen);
if (x->props.mode == XFRM_MODE_TUNNEL)
skb_reset_transport_header(skb);
else
diff --git a/net/ipv4/esp4_offload.c b/net/ipv4/esp4_offload.c
index e0666016a764..05831dea00f4 100644
--- a/net/ipv4/esp4_offload.c
+++ b/net/ipv4/esp4_offload.c
@@ -182,11 +182,13 @@ static struct sk_buff *esp4_gso_segment(struct sk_buff *skb,
static int esp_input_tail(struct xfrm_state *x, struct sk_buff *skb)
{
struct crypto_aead *aead = x->data;
+ struct xfrm_offload *xo = xfrm_offload(skb);
if (!pskb_may_pull(skb, sizeof(struct ip_esp_hdr) + crypto_aead_ivsize(aead)))
return -EINVAL;
- skb->ip_summed = CHECKSUM_NONE;
+ if (!(xo->flags & CRYPTO_DONE))
+ skb->ip_summed = CHECKSUM_NONE;
return esp_input_done2(skb, 0);
}
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next 2/7] esp6: Support RX checksum with crypto offload
2017-08-01 9:49 [PATCH net-next 0/7] IPSec offload improvements ilant
2017-08-01 9:49 ` [PATCH net-next 1/7] esp4: Support RX checksum with crypto offload ilant
@ 2017-08-01 9:49 ` ilant
2017-08-01 9:49 ` [PATCH net-next 3/7] xfrm6: Fix CHECKSUM_COMPLETE after IPv6 header push ilant
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ilant @ 2017-08-01 9:49 UTC (permalink / raw)
To: Steffen Klassert, netdev; +Cc: Ilan Tayari, Ariel Levkovich
From: Ilan Tayari <ilant@mellanox.com>
Keep the device's reported ip_summed indication in case crypto
was offloaded by the device. Subtract the csum values of the
stripped parts (esp header+iv, esp trailer+auth_data) to keep
value correct.
Note: CHECKSUM_COMPLETE should be indicated only if skb->csum
has the post-decryption offload csum value.
Signed-off-by: Ariel Levkovich <lariel@mellanox.com>
Signed-off-by: Ilan Tayari <ilant@mellanox.com>
---
net/ipv6/esp6.c | 14 +++++++++++---
net/ipv6/esp6_offload.c | 4 +++-
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 9ed35473dcb5..0ca1db62e381 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -470,7 +470,8 @@ int esp6_input_done2(struct sk_buff *skb, int err)
int hlen = sizeof(struct ip_esp_hdr) + crypto_aead_ivsize(aead);
int elen = skb->len - hlen;
int hdr_len = skb_network_header_len(skb);
- int padlen;
+ int padlen, trimlen;
+ __wsum csumdiff;
u8 nexthdr[2];
if (!xo || (xo && !(xo->flags & CRYPTO_DONE)))
@@ -492,8 +493,15 @@ int esp6_input_done2(struct sk_buff *skb, int err)
/* ... check padding bits here. Silly. :-) */
- pskb_trim(skb, skb->len - alen - padlen - 2);
- __skb_pull(skb, hlen);
+ trimlen = alen + padlen + 2;
+ if (skb->ip_summed == CHECKSUM_COMPLETE) {
+ csumdiff = skb_checksum(skb, skb->len - trimlen, trimlen, 0);
+ skb->csum = csum_block_sub(skb->csum, csumdiff,
+ skb->len - trimlen);
+ }
+ pskb_trim(skb, skb->len - trimlen);
+
+ skb_pull_rcsum(skb, hlen);
if (x->props.mode == XFRM_MODE_TUNNEL)
skb_reset_transport_header(skb);
else
diff --git a/net/ipv6/esp6_offload.c b/net/ipv6/esp6_offload.c
index f02f131f6435..eec3add177fe 100644
--- a/net/ipv6/esp6_offload.c
+++ b/net/ipv6/esp6_offload.c
@@ -209,11 +209,13 @@ static struct sk_buff *esp6_gso_segment(struct sk_buff *skb,
static int esp6_input_tail(struct xfrm_state *x, struct sk_buff *skb)
{
struct crypto_aead *aead = x->data;
+ struct xfrm_offload *xo = xfrm_offload(skb);
if (!pskb_may_pull(skb, sizeof(struct ip_esp_hdr) + crypto_aead_ivsize(aead)))
return -EINVAL;
- skb->ip_summed = CHECKSUM_NONE;
+ if (!(xo->flags & CRYPTO_DONE))
+ skb->ip_summed = CHECKSUM_NONE;
return esp6_input_done2(skb, 0);
}
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next 3/7] xfrm6: Fix CHECKSUM_COMPLETE after IPv6 header push
2017-08-01 9:49 [PATCH net-next 0/7] IPSec offload improvements ilant
2017-08-01 9:49 ` [PATCH net-next 1/7] esp4: Support RX checksum with crypto offload ilant
2017-08-01 9:49 ` [PATCH net-next 2/7] esp6: " ilant
@ 2017-08-01 9:49 ` ilant
2017-08-01 9:49 ` [PATCH net-next 4/7] esp6: Fix RX checksum after header pull ilant
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ilant @ 2017-08-01 9:49 UTC (permalink / raw)
To: Steffen Klassert, netdev; +Cc: Yossi Kuperman, Ilan Tayari
From: Yossi Kuperman <yossiku@mellanox.com>
xfrm6_transport_finish rebuilds the IPv6 header based on the
original one and pushes it back without fixing skb->csum.
Therefore, CHECKSUM_COMPLETE is no longer valid and the packet
gets dropped.
Fix skb->csum by calling skb_postpush_rcsum.
Note: A valid IPv4 header has checksum 0, unlike IPv6. Thus,
the change is not needed in the sibling xfrm4_transport_finish
function.
Signed-off-by: Yossi Kuperman <yossiku@mellanox.com>
Signed-off-by: Ilan Tayari <ilant@mellanox.com>
---
net/ipv6/xfrm6_input.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c
index 3ef5d913e7a3..f95943a13abc 100644
--- a/net/ipv6/xfrm6_input.c
+++ b/net/ipv6/xfrm6_input.c
@@ -34,6 +34,7 @@ EXPORT_SYMBOL(xfrm6_rcv_spi);
int xfrm6_transport_finish(struct sk_buff *skb, int async)
{
struct xfrm_offload *xo = xfrm_offload(skb);
+ int nhlen = skb->data - skb_network_header(skb);
skb_network_header(skb)[IP6CB(skb)->nhoff] =
XFRM_MODE_SKB_CB(skb)->protocol;
@@ -43,8 +44,9 @@ int xfrm6_transport_finish(struct sk_buff *skb, int async)
return 1;
#endif
- __skb_push(skb, skb->data - skb_network_header(skb));
+ __skb_push(skb, nhlen);
ipv6_hdr(skb)->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
+ skb_postpush_rcsum(skb, skb_network_header(skb), nhlen);
if (xo && (xo->flags & XFRM_GRO)) {
skb_mac_header_rebuild(skb);
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next 4/7] esp6: Fix RX checksum after header pull
2017-08-01 9:49 [PATCH net-next 0/7] IPSec offload improvements ilant
` (2 preceding siblings ...)
2017-08-01 9:49 ` [PATCH net-next 3/7] xfrm6: Fix CHECKSUM_COMPLETE after IPv6 header push ilant
@ 2017-08-01 9:49 ` ilant
2017-08-01 9:49 ` [PATCH net-next 5/7] xfrm: Auto-load xfrm offload modules ilant
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ilant @ 2017-08-01 9:49 UTC (permalink / raw)
To: Steffen Klassert, netdev; +Cc: Yossi Kuperman, Ilan Tayari
From: Yossi Kuperman <yossiku@mellanox.com>
Both ip6_input_finish (non-GRO) and esp6_gro_receive (GRO) strip
the IPv6 header without adjusting skb->csum accordingly. As a
result CHECKSUM_COMPLETE breaks and "hw csum failure" is written
to the kernel log by netdev_rx_csum_fault (dev.c).
Fix skb->csum by substracting the checksum value of the pulled IPv6
header using a call to skb_postpull_rcsum.
This affects both transport and tunnel modes.
Note that the fix occurs far from the place that the header was
pulled. This is based on existing code, see:
ipv6_srh_rcv() in exthdrs.c and rawv6_rcv() in raw.c
Signed-off-by: Yossi Kuperman <yossiku@mellanox.com>
Signed-off-by: Ilan Tayari <ilant@mellanox.com>
---
net/ipv6/esp6.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 0ca1db62e381..74bde202eb9a 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -495,6 +495,8 @@ int esp6_input_done2(struct sk_buff *skb, int err)
trimlen = alen + padlen + 2;
if (skb->ip_summed == CHECKSUM_COMPLETE) {
+ skb_postpull_rcsum(skb, skb_network_header(skb),
+ skb_network_header_len(skb));
csumdiff = skb_checksum(skb, skb->len - trimlen, trimlen, 0);
skb->csum = csum_block_sub(skb->csum, csumdiff,
skb->len - trimlen);
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next 5/7] xfrm: Auto-load xfrm offload modules
2017-08-01 9:49 [PATCH net-next 0/7] IPSec offload improvements ilant
` (3 preceding siblings ...)
2017-08-01 9:49 ` [PATCH net-next 4/7] esp6: Fix RX checksum after header pull ilant
@ 2017-08-01 9:49 ` ilant
2017-08-01 9:49 ` [PATCH net-next 6/7] xfrm: Clear RX SKB secpath xfrm_offload ilant
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ilant @ 2017-08-01 9:49 UTC (permalink / raw)
To: Steffen Klassert, netdev; +Cc: Ilan Tayari
From: Ilan Tayari <ilant@mellanox.com>
IPSec crypto offload depends on the protocol-specific
offload module (such as esp_offload.ko).
When the user installs an SA with crypto-offload, load
the offload module automatically, in the same way
that the protocol module is loaded (such as esp.ko)
Signed-off-by: Ilan Tayari <ilant@mellanox.com>
---
include/net/xfrm.h | 4 +++-
net/ipv4/esp4_offload.c | 1 +
net/ipv6/esp6_offload.c | 1 +
net/xfrm/xfrm_device.c | 2 +-
net/xfrm/xfrm_state.c | 16 ++++++++++++----
net/xfrm/xfrm_user.c | 2 +-
6 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index afb4929d7232..5a360100136c 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -43,6 +43,8 @@
MODULE_ALIAS("xfrm-mode-" __stringify(family) "-" __stringify(encap))
#define MODULE_ALIAS_XFRM_TYPE(family, proto) \
MODULE_ALIAS("xfrm-type-" __stringify(family) "-" __stringify(proto))
+#define MODULE_ALIAS_XFRM_OFFLOAD_TYPE(family, proto) \
+ MODULE_ALIAS("xfrm-offload-" __stringify(family) "-" __stringify(proto))
#ifdef CONFIG_XFRM_STATISTICS
#define XFRM_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.xfrm_statistics, field)
@@ -1558,7 +1560,7 @@ void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si);
u32 xfrm_replay_seqhi(struct xfrm_state *x, __be32 net_seq);
int xfrm_init_replay(struct xfrm_state *x);
int xfrm_state_mtu(struct xfrm_state *x, int mtu);
-int __xfrm_init_state(struct xfrm_state *x, bool init_replay);
+int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload);
int xfrm_init_state(struct xfrm_state *x);
int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb);
int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type);
diff --git a/net/ipv4/esp4_offload.c b/net/ipv4/esp4_offload.c
index 05831dea00f4..aca1c85f0795 100644
--- a/net/ipv4/esp4_offload.c
+++ b/net/ipv4/esp4_offload.c
@@ -305,3 +305,4 @@ module_init(esp4_offload_init);
module_exit(esp4_offload_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Steffen Klassert <steffen.klassert@secunet.com>");
+MODULE_ALIAS_XFRM_OFFLOAD_TYPE(AF_INET, XFRM_PROTO_ESP);
diff --git a/net/ipv6/esp6_offload.c b/net/ipv6/esp6_offload.c
index eec3add177fe..8d4e2ba9163d 100644
--- a/net/ipv6/esp6_offload.c
+++ b/net/ipv6/esp6_offload.c
@@ -334,3 +334,4 @@ module_init(esp6_offload_init);
module_exit(esp6_offload_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Steffen Klassert <steffen.klassert@secunet.com>");
+MODULE_ALIAS_XFRM_OFFLOAD_TYPE(AF_INET6, XFRM_PROTO_ESP);
diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
index 5cd7a244e88d..1904127f5fb8 100644
--- a/net/xfrm/xfrm_device.c
+++ b/net/xfrm/xfrm_device.c
@@ -63,7 +63,7 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
xfrm_address_t *daddr;
if (!x->type_offload)
- return 0;
+ return -EINVAL;
/* We don't yet support UDP encapsulation, TFC padding and ESN. */
if (x->encap || x->tfcpad || (x->props.flags & XFRM_STATE_ESN))
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 82cbbce69b79..a41e2ef789c0 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -296,12 +296,14 @@ int xfrm_unregister_type_offload(const struct xfrm_type_offload *type,
}
EXPORT_SYMBOL(xfrm_unregister_type_offload);
-static const struct xfrm_type_offload *xfrm_get_type_offload(u8 proto, unsigned short family)
+static const struct xfrm_type_offload *
+xfrm_get_type_offload(u8 proto, unsigned short family, bool try_load)
{
struct xfrm_state_afinfo *afinfo;
const struct xfrm_type_offload **typemap;
const struct xfrm_type_offload *type;
+retry:
afinfo = xfrm_state_get_afinfo(family);
if (unlikely(afinfo == NULL))
return NULL;
@@ -311,6 +313,12 @@ static const struct xfrm_type_offload *xfrm_get_type_offload(u8 proto, unsigned
if ((type && !try_module_get(type->owner)))
type = NULL;
+ if (!type && try_load) {
+ request_module("xfrm-offload-%d-%d", family, proto);
+ try_load = 0;
+ goto retry;
+ }
+
rcu_read_unlock();
return type;
}
@@ -2165,7 +2173,7 @@ int xfrm_state_mtu(struct xfrm_state *x, int mtu)
return mtu - x->props.header_len;
}
-int __xfrm_init_state(struct xfrm_state *x, bool init_replay)
+int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload)
{
struct xfrm_state_afinfo *afinfo;
struct xfrm_mode *inner_mode;
@@ -2230,7 +2238,7 @@ int __xfrm_init_state(struct xfrm_state *x, bool init_replay)
if (x->type == NULL)
goto error;
- x->type_offload = xfrm_get_type_offload(x->id.proto, family);
+ x->type_offload = xfrm_get_type_offload(x->id.proto, family, offload);
err = x->type->init_state(x);
if (err)
@@ -2258,7 +2266,7 @@ EXPORT_SYMBOL(__xfrm_init_state);
int xfrm_init_state(struct xfrm_state *x)
{
- return __xfrm_init_state(x, true);
+ return __xfrm_init_state(x, true, false);
}
EXPORT_SYMBOL(xfrm_init_state);
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 1b539b7dcfab..ffe8d5ef09eb 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -584,7 +584,7 @@ static struct xfrm_state *xfrm_state_construct(struct net *net,
xfrm_mark_get(attrs, &x->mark);
- err = __xfrm_init_state(x, false);
+ err = __xfrm_init_state(x, false, attrs[XFRMA_OFFLOAD_DEV]);
if (err)
goto error;
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next 6/7] xfrm: Clear RX SKB secpath xfrm_offload
2017-08-01 9:49 [PATCH net-next 0/7] IPSec offload improvements ilant
` (4 preceding siblings ...)
2017-08-01 9:49 ` [PATCH net-next 5/7] xfrm: Auto-load xfrm offload modules ilant
@ 2017-08-01 9:49 ` ilant
2017-08-01 9:49 ` [PATCH net-next 7/7] net: Allow IPsec GSO for local sockets ilant
2017-08-03 11:02 ` [PATCH net-next 0/7] IPSec offload improvements Steffen Klassert
7 siblings, 0 replies; 9+ messages in thread
From: ilant @ 2017-08-01 9:49 UTC (permalink / raw)
To: Steffen Klassert, netdev; +Cc: Ilan Tayari
From: Ilan Tayari <ilant@mellanox.com>
If an incoming packet undergoes XFRM crypto-offload, its secpath is
filled with xfrm_offload struct denoting offload information.
If the SKB is then forwarded to a device which supports crypto-
offload, the stack wrongfully attempts to offload it (even though
the output SA may not exist on the device) due to the leftover
secpath xo.
Clear the ingress xo by zeroizing secpath->olen just before
delivering the decapsulated packet to the network stack.
Fixes: d77e38e612a0 ("xfrm: Add an IPsec hardware offloading API")
Signed-off-by: Ilan Tayari <ilant@mellanox.com>
---
net/xfrm/xfrm_input.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index 923205e279f7..f07eec59dcae 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -424,6 +424,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
nf_reset(skb);
if (decaps) {
+ skb->sp->olen = 0;
skb_dst_drop(skb);
gro_cells_receive(&gro_cells, skb);
return 0;
@@ -434,6 +435,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
err = x->inner_mode->afinfo->transport_finish(skb, xfrm_gro || async);
if (xfrm_gro) {
+ skb->sp->olen = 0;
skb_dst_drop(skb);
gro_cells_receive(&gro_cells, skb);
return err;
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next 7/7] net: Allow IPsec GSO for local sockets
2017-08-01 9:49 [PATCH net-next 0/7] IPSec offload improvements ilant
` (5 preceding siblings ...)
2017-08-01 9:49 ` [PATCH net-next 6/7] xfrm: Clear RX SKB secpath xfrm_offload ilant
@ 2017-08-01 9:49 ` ilant
2017-08-03 11:02 ` [PATCH net-next 0/7] IPSec offload improvements Steffen Klassert
7 siblings, 0 replies; 9+ messages in thread
From: ilant @ 2017-08-01 9:49 UTC (permalink / raw)
To: Steffen Klassert, netdev; +Cc: Ilan Tayari
From: Steffen Klassert <steffen.klassert@secunet.com>
This patch allows local sockets to make use of XFRM GSO code path.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Ilan Tayari <ilant@mellanox.com>
---
include/net/xfrm.h | 19 +++++++++++++++++++
net/core/sock.c | 2 +-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 5a360100136c..18d7de34a5c3 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1858,6 +1858,20 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
struct xfrm_user_offload *xuo);
bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x);
+static inline bool xfrm_dst_offload_ok(struct dst_entry *dst)
+{
+ struct xfrm_state *x = dst->xfrm;
+
+ if (!x || !x->type_offload)
+ return false;
+
+ if (x->xso.offload_handle && (x->xso.dev == dst->path->dev) &&
+ !dst->child->xfrm)
+ return true;
+
+ return false;
+}
+
static inline void xfrm_dev_state_delete(struct xfrm_state *x)
{
struct xfrm_state_offload *xso = &x->xso;
@@ -1900,6 +1914,11 @@ static inline bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x
{
return false;
}
+
+static inline bool xfrm_dst_offload_ok(struct dst_entry *dst)
+{
+ return false;
+}
#endif
static inline int xfrm_mark_get(struct nlattr **attrs, struct xfrm_mark *m)
diff --git a/net/core/sock.c b/net/core/sock.c
index ac2a404c73eb..e4b45d027d8b 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1757,7 +1757,7 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE;
sk->sk_route_caps &= ~sk->sk_route_nocaps;
if (sk_can_gso(sk)) {
- if (dst->header_len) {
+ if (dst->header_len && !xfrm_dst_offload_ok(dst)) {
sk->sk_route_caps &= ~NETIF_F_GSO_MASK;
} else {
sk->sk_route_caps |= NETIF_F_SG | NETIF_F_HW_CSUM;
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net-next 0/7] IPSec offload improvements
2017-08-01 9:49 [PATCH net-next 0/7] IPSec offload improvements ilant
` (6 preceding siblings ...)
2017-08-01 9:49 ` [PATCH net-next 7/7] net: Allow IPsec GSO for local sockets ilant
@ 2017-08-03 11:02 ` Steffen Klassert
7 siblings, 0 replies; 9+ messages in thread
From: Steffen Klassert @ 2017-08-03 11:02 UTC (permalink / raw)
To: ilant; +Cc: netdev
On Tue, Aug 01, 2017 at 12:49:03PM +0300, ilant@mellanox.com wrote:
> From: Ilan Tayari <ilant@mellanox.com>
>
> Hi Steffen,
>
> This patchset introduces several improvements to IPSec offload.
> We would like to see these merged in 4.14.
>
> Patches 1-4 add RX checksum offload support.
> This gives a big performance boost.
> These patches have been submitted before but were not merged.
> Note that patches 1-2 changed slightly with a call to skb_pull_rcsum.
>
> Patch 5 adds automatic loading of XFRM offload modules, but only
> if crypto-offload is explicitly requested by user.
> This avoid issues in the field where user forgets to load the
> module manually and so crypto-offload does not happen.
>
> Patch 6 fixes the leftover xfrm_offload in RX SKBs.
> This solves some issues with forwarding.
>
> Patch 7 allows IPSec GSO on local sockets, with or without
> crypto-offload.
> This also gives a large performance boost.
>
> Thanks,
> Ilan.
>
> Ilan Tayari (4):
> esp4: Support RX checksum with crypto offload
> esp6: Support RX checksum with crypto offload
> xfrm: Auto-load xfrm offload modules
> xfrm: Clear RX SKB secpath xfrm_offload
>
> Steffen Klassert (1):
> net: Allow IPsec GSO for local sockets
>
> Yossi Kuperman (2):
> xfrm6: Fix CHECKSUM_COMPLETE after IPv6 header push
> esp6: Fix RX checksum after header pull
All applied to ipsec-next, thanks a lot!
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-08-03 11:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-01 9:49 [PATCH net-next 0/7] IPSec offload improvements ilant
2017-08-01 9:49 ` [PATCH net-next 1/7] esp4: Support RX checksum with crypto offload ilant
2017-08-01 9:49 ` [PATCH net-next 2/7] esp6: " ilant
2017-08-01 9:49 ` [PATCH net-next 3/7] xfrm6: Fix CHECKSUM_COMPLETE after IPv6 header push ilant
2017-08-01 9:49 ` [PATCH net-next 4/7] esp6: Fix RX checksum after header pull ilant
2017-08-01 9:49 ` [PATCH net-next 5/7] xfrm: Auto-load xfrm offload modules ilant
2017-08-01 9:49 ` [PATCH net-next 6/7] xfrm: Clear RX SKB secpath xfrm_offload ilant
2017-08-01 9:49 ` [PATCH net-next 7/7] net: Allow IPsec GSO for local sockets ilant
2017-08-03 11:02 ` [PATCH net-next 0/7] IPSec offload improvements Steffen Klassert
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.