DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nithin Dabilpuram <ndabilpuram@marvell.com>
To: Akhil Goyal <gakhil@marvell.com>
Cc: <jerinj@marvell.com>, <dev@dpdk.org>,
	Nithin Dabilpuram <ndabilpuram@marvell.com>
Subject: [PATCH v2 4/5] app/test: update L2 header based on tunnel IP version
Date: Thu, 18 Aug 2022 00:41:45 +0530	[thread overview]
Message-ID: <20220817191146.30085-4-ndabilpuram@marvell.com> (raw)
In-Reply-To: <20220817191146.30085-1-ndabilpuram@marvell.com>

Update L2 header based on tunnel IP version.

Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
---
 app/test/test_security_inline_proto.c | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/app/test/test_security_inline_proto.c b/app/test/test_security_inline_proto.c
index 5f26a04..b282e7d 100644
--- a/app/test/test_security_inline_proto.c
+++ b/app/test/test_security_inline_proto.c
@@ -418,15 +418,29 @@ copy_buf_to_pkt_segs(const uint8_t *buf, unsigned int len,
 	rte_memcpy(seg_buf, buf + copied, (size_t) len);
 }
 
+static bool
+is_outer_ipv4(struct ipsec_test_data *td)
+{
+	bool outer_ipv4;
+
+	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS ||
+	    td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT)
+		outer_ipv4 = (((td->input_text.data[0] & 0xF0) >> 4) == IPVERSION);
+	else
+		outer_ipv4 = (td->ipsec_xform.tunnel.type == RTE_SECURITY_IPSEC_TUNNEL_IPV4);
+	return outer_ipv4;
+}
+
 static inline struct rte_mbuf *
-init_packet(struct rte_mempool *mp, const uint8_t *data, unsigned int len)
+init_packet(struct rte_mempool *mp, const uint8_t *data, unsigned int len, bool outer_ipv4)
 {
 	struct rte_mbuf *pkt;
 
 	pkt = rte_pktmbuf_alloc(mp);
 	if (pkt == NULL)
 		return NULL;
-	if (((data[0] & 0xF0) >> 4) == IPVERSION) {
+
+	if (outer_ipv4) {
 		rte_memcpy(rte_pktmbuf_append(pkt, RTE_ETHER_HDR_LEN),
 				&dummy_ipv4_eth_hdr, RTE_ETHER_HDR_LEN);
 		pkt->l3_len = sizeof(struct rte_ipv4_hdr);
@@ -711,6 +725,7 @@ test_ipsec_with_reassembly(struct reassembly_vector *vector,
 	struct rte_security_ctx *ctx;
 	unsigned int i, nb_rx = 0, j;
 	uint32_t ol_flags;
+	bool outer_ipv4;
 	int ret = 0;
 
 	burst_sz = vector->burst ? ENCAP_DECAP_BURST_SZ : 1;
@@ -740,11 +755,15 @@ test_ipsec_with_reassembly(struct reassembly_vector *vector,
 	memset(tx_pkts_burst, 0, sizeof(tx_pkts_burst[0]) * nb_tx);
 	memset(rx_pkts_burst, 0, sizeof(rx_pkts_burst[0]) * nb_tx);
 
+	memcpy(&sa_data, vector->sa_data, sizeof(struct ipsec_test_data));
+	sa_data.ipsec_xform.direction =	RTE_SECURITY_IPSEC_SA_DIR_EGRESS;
+	outer_ipv4 = is_outer_ipv4(&sa_data);
+
 	for (i = 0; i < nb_tx; i += vector->nb_frags) {
 		for (j = 0; j < vector->nb_frags; j++) {
 			tx_pkts_burst[i+j] = init_packet(mbufpool,
 						vector->frags[j]->data,
-						vector->frags[j]->len);
+						vector->frags[j]->len, outer_ipv4);
 			if (tx_pkts_burst[i+j] == NULL) {
 				ret = -1;
 				printf("\n packed init failed\n");
@@ -963,6 +982,7 @@ test_ipsec_inline_proto_process(struct ipsec_test_data *td,
 	int nb_rx = 0, nb_sent;
 	uint32_t ol_flags;
 	int i, j = 0, ret;
+	bool outer_ipv4;
 
 	memset(rx_pkts_burst, 0, sizeof(rx_pkts_burst[0]) * nb_pkts);
 
@@ -994,9 +1014,11 @@ test_ipsec_inline_proto_process(struct ipsec_test_data *td,
 		if (ret)
 			goto out;
 	}
+	outer_ipv4 = is_outer_ipv4(td);
+
 	for (i = 0; i < nb_pkts; i++) {
 		tx_pkts_burst[i] = init_packet(mbufpool, td->input_text.data,
-						td->input_text.len);
+						td->input_text.len, outer_ipv4);
 		if (tx_pkts_burst[i] == NULL) {
 			while (i--)
 				rte_pktmbuf_free(tx_pkts_burst[i]);
@@ -1194,6 +1216,7 @@ test_ipsec_inline_proto_process_with_esn(struct ipsec_test_data td[],
 	struct rte_security_session *ses;
 	struct rte_security_ctx *ctx;
 	uint32_t ol_flags;
+	bool outer_ipv4;
 	int i, ret;
 
 	if (td[0].aead) {
@@ -1224,10 +1247,11 @@ test_ipsec_inline_proto_process_with_esn(struct ipsec_test_data td[],
 		if (ret)
 			goto out;
 	}
+	outer_ipv4 = is_outer_ipv4(td);
 
 	for (i = 0; i < nb_pkts; i++) {
 		tx_pkt = init_packet(mbufpool, td[i].input_text.data,
-					td[i].input_text.len);
+					td[i].input_text.len, outer_ipv4);
 		if (tx_pkt == NULL) {
 			ret = TEST_FAILED;
 			goto out;
-- 
2.8.4


  parent reply	other threads:[~2022-08-17 19:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07  7:29 [PATCH 1/4] mbuf: clarify meta data needed for Outbound Inline Nithin Dabilpuram
2022-07-07  7:29 ` [PATCH 2/4] security: clarify L2 header requirement for outbound inline Nithin Dabilpuram
2022-07-07  7:29 ` [PATCH 3/4] net/cnxk: remove l2 header update for outbound inline pkts Nithin Dabilpuram
2022-07-07  7:29 ` [PATCH 4/4] app/test: update l2 header based on tunnel ip version Nithin Dabilpuram
2022-08-17 19:11 ` [PATCH v2 1/5] mbuf: clarify meta data needed for Outbound Inline Nithin Dabilpuram
2022-08-17 19:11   ` [PATCH v2 2/5] security: clarify L2 header requirement for outbound inline Nithin Dabilpuram
2022-08-17 19:11   ` [PATCH v2 3/5] net/cnxk: remove L2 header update for outbound inline pkts Nithin Dabilpuram
2022-08-17 19:11   ` Nithin Dabilpuram [this message]
2022-08-18  9:04     ` [PATCH v2 4/5] app/test: update L2 header based on tunnel IP version Akhil Goyal
2022-08-17 19:11   ` [PATCH v2 5/5] examples/ipsec-secgw: update ether type using tunnel info Nithin Dabilpuram
2022-08-18  8:01     ` Ruifeng Wang
2022-08-18  8:26     ` Akhil Goyal
2022-08-22 14:38 ` [PATCH v3 1/5] mbuf: clarify meta data needed for Outbound Inline Nithin Dabilpuram
2022-08-22 14:38   ` [PATCH v3 2/5] security: clarify L2 header requirement for outbound inline Nithin Dabilpuram
2022-09-21 18:23     ` Akhil Goyal
2022-08-22 14:38   ` [PATCH v3 3/5] net/cnxk: remove L2 header update for outbound inline pkts Nithin Dabilpuram
2022-08-22 14:38   ` [PATCH v3 4/5] app/test: update L2 header based on tunnel IP version Nithin Dabilpuram
2022-08-22 14:38   ` [PATCH v3 5/5] examples/ipsec-secgw: update ether type using tunnel info Nithin Dabilpuram
2022-08-31  1:49   ` [PATCH v3 1/5] mbuf: clarify meta data needed for Outbound Inline Nithin Kumar Dabilpuram
2022-09-21 18:21     ` Akhil Goyal
2022-09-21 18:46       ` Thomas Monjalon
2022-09-22 15:48   ` Akhil Goyal

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=20220817191146.30085-4-ndabilpuram@marvell.com \
    --to=ndabilpuram@marvell.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=jerinj@marvell.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).