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: 386246 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp1904570jap; Mon, 22 Feb 2021 22:24:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBt5WBuGVCSF7g/Uaz4Fpx6httOvMSSrkCpVCSiW7XuKBt/35inm2Duldb00lDCnHV12Nb X-Received: by 2002:aa7:d295:: with SMTP id w21mr11784629edq.159.1614061490308; Mon, 22 Feb 2021 22:24:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614061490; cv=none; d=google.com; s=arc-20160816; b=F9/07jx3lKQpFZj2DwGDx9gzcxHj7sHTY3NUxZ3LlTDtO1QrX0C4n8zZHBPruBcPfm VR8TQ7oJwNsGPVeojEXuZJaD1vohvizmJ0C1YWXtFQlCF+5i/eQl7ls3RZpejlOE9Qpe /SkN2QPEKhD3sfvAeafZaU4DH55nNN+wCX5RodVL0IieTftId9C4XlbgPeFnjSt+UN/R e1YeYxrvI4GH8NsPX+j1QwZYm3U5T/B27SLt6MUcmNsn+QEv4yTsrDKu8WwMZCx723c6 TDawjnPws65+zvg57D/WTkWNKuZxWfcLDWxTGefhhklQxlnqruPSfP+Ar6J4K/hLHcok eD8Q== 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:message-id:date:cc:to :from; bh=8dSSnMlHJM4v7uh6xXHpJemN1uzwzoJn01WegzYMIno=; b=zvupuWMhE5uscTLwoo4MxyKDFkI29l4LmYrvPt1Z8qeABCiCDvfOsavGaSD9fiO+6W cIKbUvIJkHQeULF4w4Q7+PIcX5htXjF++uNaV4+z8bj/Ta1sIH1T1zVpNSi7orUufwcx 6zCSUKqL+xw0FgzA6FUxyPzT2PHbwZFis1K4oaDlO583FPeWl1nAIqqZdkVrHMLOPxNI 5GbPSXsGk/5BNPzRQnF/6JyzOTJBBPQbmi/bo819NxmuIysmLnG9nK1RwXj3A/qywAB/ IgtJAi/bu9Yr57t4KrEqcCR3ZT+HZkz5sesjSEiIdN7Mefld8m6fF9TAs0uEmuaoKF5x VKvQ== 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 a22si4552357edx.443.2021.02.22.22.24.49; Mon, 22 Feb 2021 22:24:50 -0800 (PST) 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 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 --- examples/l2fwd-crypto/main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.17.1 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); }