From patchwork Tue Feb 23 06:12:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 88092 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9E1AFA034F; Tue, 23 Feb 2021 07:24:49 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 150F64067A; Tue, 23 Feb 2021 07:24:49 +0100 (CET) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by mails.dpdk.org (Postfix) with ESMTP id A4B7740041 for ; Tue, 23 Feb 2021 07:24:47 +0100 (CET) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 6717A20050F; Tue, 23 Feb 2021 07:24:47 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 4F7322004FA; Tue, 23 Feb 2021 07:24:45 +0100 (CET) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id AB683402B7; Tue, 23 Feb 2021 07:24:42 +0100 (CET) From: Hemant Agrawal To: dev@dpdk.org, declan.doherty@intel.com Cc: Rohit Raj Date: Tue, 23 Feb 2021 11:42:44 +0530 Message-Id: <20210223061244.22627-1-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH] l2fwd-crypto: remove padding after decrypting X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Rohit Raj There were some padding left when a packet gets decrypted. This patch removes those padding. This patch also removes the padding left after verifying auth of the packet. Signed-off-by: Rohit Raj Signed-off-by: Rohit Raj --- examples/l2fwd-crypto/main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index a96cb94cc..e7a1eea30 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -616,12 +616,26 @@ l2fwd_simple_forward(struct rte_mbuf *m, uint16_t portid, struct l2fwd_crypto_options *options) { uint16_t dst_port; + uint32_t pad_len; + struct rte_ipv4_hdr *ip_hdr; + uint32_t ipdata_offset = sizeof(struct rte_ether_hdr); + ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) + + ipdata_offset); dst_port = l2fwd_dst_ports[portid]; if (options->mac_updating) l2fwd_mac_updating(m, dst_port); + if (options->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) + rte_pktmbuf_trim(m, options->auth_xform.auth.digest_length); + + if (options->cipher_xform.cipher.op == RTE_CRYPTO_CIPHER_OP_DECRYPT) { + pad_len = m->pkt_len - rte_be_to_cpu_16(ip_hdr->total_length) - + ipdata_offset; + rte_pktmbuf_trim(m, pad_len); + } + l2fwd_send_packet(m, dst_port); }