Skip to content

Commit f7e8542

Browse files
Mike Yuklassert
authored andcommitted
xfrm: Support crypto offload for inbound IPv6 ESP packets not in GRO path
IPsec crypt offload supports outbound IPv6 ESP packets, but it doesn't support inbound IPv6 ESP packets. This change enables the crypto offload for inbound IPv6 ESP packets that are not handled through GRO code path. If HW drivers add the offload information to the skb, the packet will be handled in the crypto offload rx code path. Apart from the change in crypto offload rx code path, the change in xfrm_policy_check is also needed. Exampe of RX data path: +-----------+ +-------+ | HW Driver |-->| wlan0 |--------+ +-----------+ +-------+ | v +---------------+ +------+ +------>| Network Stack |-->| Apps | | +---------------+ +------+ | | | v +--------+ +------------+ | ipsec1 |<--| XFRM Stack | +--------+ +------------+ Test: Enabled both in/out IPsec crypto offload, and verified IPv6 ESP packets on Android device on both wifi/cellular network Signed-off-by: Mike Yu <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent f531d13 commit f7e8542

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

net/xfrm/xfrm_input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
471471
struct xfrm_offload *xo = xfrm_offload(skb);
472472
struct sec_path *sp;
473473

474-
if (encap_type < 0 || (xo && xo->flags & XFRM_GRO)) {
474+
if (encap_type < 0 || (xo && (xo->flags & XFRM_GRO || encap_type == 0))) {
475475
x = xfrm_input_state(skb);
476476

477477
if (unlikely(x->dir && x->dir != XFRM_SA_DIR_IN)) {

net/xfrm/xfrm_policy.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3718,12 +3718,15 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,
37183718
pol = xfrm_in_fwd_icmp(skb, &fl, family, if_id);
37193719

37203720
if (!pol) {
3721+
const bool is_crypto_offload = sp &&
3722+
(xfrm_input_state(skb)->xso.type == XFRM_DEV_OFFLOAD_CRYPTO);
3723+
37213724
if (net->xfrm.policy_default[dir] == XFRM_USERPOLICY_BLOCK) {
37223725
XFRM_INC_STATS(net, LINUX_MIB_XFRMINNOPOLS);
37233726
return 0;
37243727
}
37253728

3726-
if (sp && secpath_has_nontransport(sp, 0, &xerr_idx)) {
3729+
if (sp && secpath_has_nontransport(sp, 0, &xerr_idx) && !is_crypto_offload) {
37273730
xfrm_secpath_reject(xerr_idx, skb, &fl);
37283731
XFRM_INC_STATS(net, LINUX_MIB_XFRMINNOPOLS);
37293732
return 0;

0 commit comments

Comments
 (0)