From patchwork Fri Apr 9 13:14:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 418176 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1562672jai; Fri, 9 Apr 2021 06:16:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5yodsldkH5hGei3WBznkcEGpaHumX+AWv0qs8de/Aq6p6OxeklHc11RzRv7LnB2IEkPz9 X-Received: by 2002:a17:906:cc49:: with SMTP id mm9mr15833254ejb.339.1617974196216; Fri, 09 Apr 2021 06:16:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617974196; cv=none; d=google.com; s=arc-20160816; b=QkOk7gibOhHmyHdbZhMAl+FZjenGrnWyzffQ3EFIEB8vO7vqazfDrWqdbWra99xeM8 Lzt7OiF/IaUMQLuy24G3qTA7WbgD46jUxVpyDs9PpHr0bNIeIzleriqXiPuUQI2gVMLk ADpWmrx3dCAbF7e37xrNpVvHQ/K8cIgCK8NxtdnuWJdmA2EY6H1sGJh261G+AQQYsQPr C5OnEGOmx3lbRRN/ayX/framXOQZr4McoCVDiOWnFXRHdqAWHMqDOeB7iasPwu+hdVqc CsOImUjGz1qZXbBHXDz1/cw4N9gLqQT2AiPuQUNP6CGfGTnm4L3OpPVnuenIXIZqchH3 JEyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=tuFGSp0HrfoDJ5tnD9qYdH6IoKFmWGJQWEy+nAC/IOA=; b=XCv1+PH6xAy8oMfG+B0ntrJbCUsQrpLK9IfYRHu+Vo8GKDpI0QlUG3P8cEV9NyN57/ PeOf0Oz9nFwJw0msGKBobYVm7UcHE3slyi6t3hmKBemptRomdONy1WaMrdCF0AuxSVLz t/eXuSSMVKIC9bdu9dW1n3iowSf+61WZhTCTVY1FBUJKgzcJ96zGEEX5LWOBbqe1mM9X QLxnH09eU1qgxipl3mtvmyiyaLGvbDqZ9Aj15NjTIlLsgDT2EtGhCHeLV+4lDQ/STswT Es6h0dh2Aju+M+BWNQ7rxg/wkOl++c67SnddotJHJlYBi1qy1cXoBBN3AkiPyC1W7c8M bMzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id f5si1970803ejx.128.2021.04.09.06.16.35; Fri, 09 Apr 2021 06:16:36 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED8AB140FA5; Fri, 9 Apr 2021 15:16:34 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by mails.dpdk.org (Postfix) with ESMTP id C654D4014D; Fri, 9 Apr 2021 15:16:33 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 8E4022045F3; Fri, 9 Apr 2021 15:16:33 +0200 (CEST) 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 99ADE200591; Fri, 9 Apr 2021 15:16:31 +0200 (CEST) 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 BA8E8402C9; Fri, 9 Apr 2021 15:16:28 +0200 (CEST) From: Hemant Agrawal To: dev@dpdk.org, gakhil@marvell.com Cc: stable@dpdk.org, Rohit Raj Date: Fri, 9 Apr 2021 18:44:59 +0530 Message-Id: <20210409131459.14049-1-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210223061244.22627-1-hemant.agrawal@nxp.com> References: <20210223061244.22627-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2] l2fwd-crypto: fix packet length while decryption 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. Fixes: e2cdfbd07c8a ("examples/l2fwd-crypto: fix port id type") Cc: stable@dpdk.org Signed-off-by: Rohit Raj --- examples/l2fwd-crypto/main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.17.1 Acked-by: Akhil Goyal diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index 1016ceb841..23a398043e 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); }