From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A8F5B42FD1 for ; Fri, 4 Aug 2023 11:07:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9BF7A43245; Fri, 4 Aug 2023 11:07:47 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 77FE840E2D; Fri, 4 Aug 2023 11:07:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691140064; x=1722676064; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=YkNZl2/OItXHweL2wSzGRPSn8HhTz0dk0Wc1ADlcFTc=; b=mvIOQpbQR/5pFZhWXhn8ASRXso2CnT1et65kxf2RaCPR8I9by/BD4yLc CkN2HXPw07EsCH2iKBgqNv+FuMA7feGQRR6Ab/YVTcTsoF9xipMkaPq5v BHyXYlLVAKAfsAmMlkwXwZwyj/eG/rhesFiRMv4yRjXQHOs+W4YbJEoDy eaby4WL+/e2GSUJhQYOPb0T5E5szCgMfTcvi0KdYlZNaqUB9fKL/e4C3+ D+cFENMXPhOZqP84ZeySndAn5DtNltgee4c2jAU0I3n4bMLW5xkNNq788 GHkY68QcZ3eSADxcBzoR0cCZS42CbJ8e7ZTsbMb7romBi/b/8pwK1ACh/ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10791"; a="373760229" X-IronPort-AV: E=Sophos;i="6.01,254,1684825200"; d="scan'208";a="373760229" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2023 02:07:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10791"; a="903829614" X-IronPort-AV: E=Sophos;i="6.01,254,1684825200"; d="scan'208";a="903829614" Received: from shwdenpg561.ccr.corp.intel.com (HELO dpdk..) ([10.239.252.3]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2023 02:07:40 -0700 From: Kaiwen Deng To: dev@dpdk.org Cc: stable@dpdk.org, qiming.yang@intel.com, yidingx.zhou@intel.com, Kaiwen Deng , Aman Singh , Yuying Zhang , Olivier Matz , Pablo de Lara Subject: [PATCH] app/test-pmd: fix L4 checksum with padding data Date: Fri, 4 Aug 2023 16:28:48 +0800 Message-Id: <20230804082849.533059-1-kaiwenx.deng@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org IEEE 802 packets may have a minimum size limit. The data fields should be padded when necessary. In some cases, the padding data is not zero. Testpmd does not trim these IP packets to the true length of the frame, so errors will occur when calculating TCP or UDP checksum. This commit fixes this issue by triming IP packets to the true length of the frame in testpmd. Fixes: 03d17e4d0179 ("app/testpmd: do not change IP addrs in checksum engine") Cc: stable@dpdk.org Signed-off-by: Kaiwen Deng --- app/test-pmd/csumonly.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 7af635e3f7..58b72b714a 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -853,12 +853,14 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) uint16_t nb_rx; uint16_t nb_prep; uint16_t i; + uint16_t pad_len; uint64_t rx_ol_flags, tx_ol_flags; uint64_t tx_offloads; uint32_t rx_bad_ip_csum; uint32_t rx_bad_l4_csum; uint32_t rx_bad_outer_l4_csum; uint32_t rx_bad_outer_ip_csum; + uint32_t l3_off; struct testpmd_offload_info info; /* receive a burst of packet */ @@ -980,6 +982,36 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) l3_hdr = (char *)l3_hdr + info.outer_l3_len + info.l2_len; } + if (info.is_tunnel) { + l3_off = info.outer_l2_len + + info.outer_l3_len + + info.l2_len; + } else { + l3_off = info.l2_len; + } + switch (info.ethertype) { + case _htons(RTE_ETHER_TYPE_IPV4): + pad_len = rte_pktmbuf_data_len(m) - + (l3_off + + rte_be_to_cpu_16( + ((struct rte_ipv4_hdr *)l3_hdr)->total_length)); + break; + case _htons(RTE_ETHER_TYPE_IPV6): + pad_len = rte_pktmbuf_data_len(m) - + (l3_off + + rte_be_to_cpu_16( + ((struct rte_ipv6_hdr *)l3_hdr)->payload_len)); + break; + default: + pad_len = 0; + break; + } + + if (pad_len) { + rte_pktmbuf_data_len(m) = rte_pktmbuf_data_len(m) - pad_len; + rte_pktmbuf_pkt_len(m) = rte_pktmbuf_data_len(m); + } + /* step 2: depending on user command line configuration, * recompute checksum either in software or flag the * mbuf to offload the calculation to the NIC. If TSO -- 2.34.1