blob: 17ae47002fcc4980a880783bcc12417284e99914 [file] [log] [blame]
developer4f0d2ba2023-08-21 17:33:25 +08001--- 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 {
developer2d418612023-10-19 16:40:53 +080012@@ -570,12 +570,10 @@ int xfrm_output(struct sock *sk, struct
developer4f0d2ba2023-08-21 17:33:25 +080013
developer2d418612023-10-19 16:40:53 +080014 if (x->xso.type == XFRM_DEV_OFFLOAD_PACKET) {
15 if (!xfrm_dev_offload_ok(skb, x)) {
developer4f0d2ba2023-08-21 17:33:25 +080016- XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
17- kfree_skb(skb);
18- return -EHOSTUNREACH;
developer2d418612023-10-19 16:40:53 +080019+ secpath_reset(skb);
20+ goto sw_path;
21 }
developer4f0d2ba2023-08-21 17:33:25 +080022-
23- return xfrm_output_resume(skb, 0);
developer2d418612023-10-19 16:40:53 +080024+ return 0;
25 }
developer4f0d2ba2023-08-21 17:33:25 +080026
developer2d418612023-10-19 16:40:53 +080027 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 }
developer61b20f82023-11-20 20:16:03 +080036--- 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;