developer | 4f0d2ba | 2023-08-21 17:33:25 +0800 | [diff] [blame] | 1 | --- a/net/xfrm/xfrm_output.c |
| 2 | +++ b/net/xfrm/xfrm_output.c |
| 3 | @@ -410,7 +410,7 @@ static int xfrm_output_one(struct sk_buf |
| 4 | struct xfrm_state *x = dst->xfrm; |
| 5 | struct net *net = xs_net(x); |
| 6 | |
| 7 | - if (err <= 0 || x->xso.type == XFRM_DEV_OFFLOAD_PACKET) |
| 8 | + if (err <= 0) |
| 9 | goto resume; |
| 10 | |
| 11 | do { |
developer | 2d41861 | 2023-10-19 16:40:53 +0800 | [diff] [blame] | 12 | @@ -570,12 +570,10 @@ int xfrm_output(struct sock *sk, struct |
developer | 4f0d2ba | 2023-08-21 17:33:25 +0800 | [diff] [blame] | 13 | |
developer | 2d41861 | 2023-10-19 16:40:53 +0800 | [diff] [blame] | 14 | if (x->xso.type == XFRM_DEV_OFFLOAD_PACKET) { |
| 15 | if (!xfrm_dev_offload_ok(skb, x)) { |
developer | 4f0d2ba | 2023-08-21 17:33:25 +0800 | [diff] [blame] | 16 | - XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR); |
| 17 | - kfree_skb(skb); |
| 18 | - return -EHOSTUNREACH; |
developer | 2d41861 | 2023-10-19 16:40:53 +0800 | [diff] [blame] | 19 | + secpath_reset(skb); |
| 20 | + goto sw_path; |
| 21 | } |
developer | 4f0d2ba | 2023-08-21 17:33:25 +0800 | [diff] [blame] | 22 | - |
| 23 | - return xfrm_output_resume(skb, 0); |
developer | 2d41861 | 2023-10-19 16:40:53 +0800 | [diff] [blame] | 24 | + return 0; |
| 25 | } |
developer | 4f0d2ba | 2023-08-21 17:33:25 +0800 | [diff] [blame] | 26 | |
developer | 2d41861 | 2023-10-19 16:40:53 +0800 | [diff] [blame] | 27 | secpath_reset(skb); |
| 28 | @@ -606,6 +604,7 @@ int xfrm_output(struct sock *sk, struct |
| 29 | if (x->xso.dev && x->xso.dev->features & NETIF_F_HW_ESP_TX_CSUM) |
| 30 | goto out; |
| 31 | } else { |
| 32 | +sw_path: |
| 33 | if (skb_is_gso(skb)) |
| 34 | return xfrm_output_gso(net, sk, skb); |
| 35 | } |
developer | 61b20f8 | 2023-11-20 20:16:03 +0800 | [diff] [blame] | 36 | --- a/net/xfrm/xfrm_policy.c |
| 37 | +++ b/net/xfrm/xfrm_policy.c |
| 38 | @@ -3703,6 +3703,10 @@ int __xfrm_policy_check(struct sock *sk, |
| 39 | } |
| 40 | } |
| 41 | #endif |
| 42 | + /* Inbound HW offload packets, pass the check directly */ |
| 43 | + if (pol->xdo.type == XFRM_DEV_OFFLOAD_PACKET && |
| 44 | + (pol->xdo.dir == XFRM_DEV_OFFLOAD_IN || pol->xdo.dir == XFRM_DEV_OFFLOAD_FWD)) |
| 45 | + return 1; |
| 46 | |
| 47 | if (pol->action == XFRM_POLICY_ALLOW) { |
| 48 | static struct sec_path dummy; |
| 49 | @@ -3712,6 +3716,14 @@ int __xfrm_policy_check(struct sock *sk, |
| 50 | int ti = 0; |
| 51 | int i, k; |
| 52 | |
| 53 | + /* Strongswan install FWD policy for inbound HW offload |
| 54 | + * packets. But cannot find corresponding packet offload |
| 55 | + * state here and will be drop. So, we bypass following |
| 56 | + * check for FWD policy with acction allow. |
| 57 | + */ |
| 58 | + if (dir == XFRM_POLICY_FWD) |
| 59 | + return 1; |
| 60 | + |
| 61 | sp = skb_sec_path(skb); |
| 62 | if (!sp) |
| 63 | sp = &dummy; |