netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Feng Wang <wangfe@google.com>
To: netdev@vger.kernel.org, steffen.klassert@secunet.com,
	 antony.antony@secunet.com
Cc: wangfe@google.com
Subject: [PATCH] xfrm: add SA information to the offloaded packet
Date: Mon, 12 Aug 2024 11:23:17 -0700	[thread overview]
Message-ID: <20240812182317.1962756-1-wangfe@google.com> (raw)

From: wangfe <wangfe@google.com>

In packet offload mode, append Security Association (SA) information
to each packet, replicating the crypto offload implementation.
The XFRM_XMIT flag is set to enable packet to be returned immediately
from the validate_xmit_xfrm function, thus aligning with the existing
code path for packet offload mode.

Signed-off-by: wangfe <wangfe@google.com>
---
 net/xfrm/xfrm_output.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index e5722c95b8bb..a12588e7b060 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -706,6 +706,8 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb)
 	struct xfrm_state *x = skb_dst(skb)->xfrm;
 	int family;
 	int err;
+	struct xfrm_offload *xo;
+	struct sec_path *sp;
 
 	family = (x->xso.type != XFRM_DEV_OFFLOAD_PACKET) ? x->outer_mode.family
 		: skb_dst(skb)->ops->family;
@@ -728,6 +730,25 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb)
 			kfree_skb(skb);
 			return -EHOSTUNREACH;
 		}
+		sp = secpath_set(skb);
+		if (!sp) {
+			XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
+			kfree_skb(skb);
+			return -ENOMEM;
+		}
+
+		sp->olen++;
+		sp->xvec[sp->len++] = x;
+		xfrm_state_hold(x);
+
+		xo = xfrm_offload(skb);
+		if (!xo) {
+			secpath_reset(skb);
+			XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
+			kfree_skb(skb);
+			return -EINVAL;
+		}
+		xo->flags |= XFRM_XMIT;
 
 		return xfrm_output_resume(sk, skb, 0);
 	}
-- 
2.46.0.rc2.264.g509ed76dc8-goog


             reply	other threads:[~2024-08-12 18:23 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-12 18:23 Feng Wang [this message]
2024-08-19  6:06 ` [PATCH] xfrm: add SA information to the offloaded packet Steffen Klassert
2024-08-22 20:11   ` Feng Wang
  -- strict thread matches above, loose matches on Subject: below --
2024-08-22 20:02 Feng Wang
2024-08-28  5:32 ` Steffen Klassert
2024-08-28 11:26   ` Leon Romanovsky
2024-08-28 21:25     ` Feng Wang
2024-08-29 10:38       ` Leon Romanovsky
2024-08-29 21:19         ` Feng Wang
2024-08-30 14:30           ` Leon Romanovsky
2024-08-31  0:27             ` Feng Wang
2024-08-31 17:36               ` Leon Romanovsky
2024-08-31 17:39   ` Leon Romanovsky
2024-09-02  7:44     ` Steffen Klassert
2024-09-02  9:44       ` Leon Romanovsky
2024-09-03 18:19         ` Feng Wang
2024-09-03 19:04           ` Leon Romanovsky
2024-09-04 17:41             ` Feng Wang
2024-09-05  7:49               ` Leon Romanovsky
2024-09-05 18:18                 ` Feng Wang
2024-09-09  9:09         ` Steffen Klassert
2024-09-09 10:02           ` Steffen Klassert
2024-09-11 10:40           ` Leon Romanovsky
2024-09-11 23:43             ` Feng Wang
2024-09-16  8:10               ` Leon Romanovsky
2024-09-24 10:07               ` Steffen Klassert
2024-09-24 10:34             ` Steffen Klassert
2024-09-24 17:57               ` Feng Wang
2024-09-24 18:10                 ` Steffen Klassert
2024-09-25  8:19                   ` Leon Romanovsky
2024-09-25  8:29               ` Leon Romanovsky
2024-09-02  7:47 ` Steffen Klassert
2024-11-12 19:22 Feng Wang
2024-11-14 10:27 ` Leon Romanovsky
2024-11-18 19:28   ` Feng Wang
2024-11-19 12:51     ` Leon Romanovsky
2024-11-19 19:15   ` Feng Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240812182317.1962756-1-wangfe@google.com \
    --to=wangfe@google.com \
    --cc=antony.antony@secunet.com \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).