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 B827CA0A0F for ; Wed, 30 Jun 2021 15:52:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2E6F241274; Wed, 30 Jun 2021 15:52:33 +0200 (CEST) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mails.dpdk.org (Postfix) with ESMTP id 0DCC24126F for ; Wed, 30 Jun 2021 15:52:29 +0200 (CEST) Received: by mail-wr1-f45.google.com with SMTP id v5so3773474wrt.3 for ; Wed, 30 Jun 2021 06:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o4SckZWNiSvzj3qHRROP/H8Lco3apigtHUeYza48pXg=; b=TEBQzUD36jvvVkmXs4QCkNvfiBAJSJ5zElTyMXCmWglVfuKjCuwntkK4u71qhxtVE9 Q9qJQqQPK/ZguyJ0azBhqUC4TsZbkg5jrEA6xlXfwIZYxTDVC8FHHQTwUOrGkUAQ76qi II2fDF62YfaouP7AMYxjv8Vf474jefl4y/Ro0W3J3Rt4mEL9PdhB5GqUeNVO/TLuJUtj R47/tL/qOh04Qyk4hYDQeZzIM0ete3thjcglVRE97lDhz8uuGH7nmt9P7pBhgB0/Wg04 W+N8QhFqAJRVd2kyoon5q5TpZPqVAlTSlNmkT3XqINHStgmt8RVWBtfzpLvl50YviG+U 2x+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o4SckZWNiSvzj3qHRROP/H8Lco3apigtHUeYza48pXg=; b=QrNzY6f3UsNN5pzxSJ1Is9tjyZOnZzCwG29y5heXkViG84jYnkFbryFM0W658+Ui33 QDAAKJ6iAfu/5wBzFXv6SP/+3L3l+WlGh0YKTDr8BDah4lrWhFhxG5ibKcjXQ3o41C0Z L0xaQxtNsn3cEWRocuIcBxlXsHEheMegtfOOVyhroMILnmWjIsXOlKR/yc44fRUliWxi Zp+0qXjwdP0W2GReodXR7aVykcYz4FGSRTnR/DxDlGcerNi4xRKCDFw2zTevJnsR+Xv3 Idp5aC9naFqe/AF5f8zhDohTy7bnFBRpzu1QIX0n44V4CPIV3wZDLIP9Ib2B4XuO9lgt gTBQ== X-Gm-Message-State: AOAM5300sdMGUcjPKBuMZoThQRY/m3XFw+5ZarH7rZ81elTMH4bA0XpC 10TiWuy2Xcjms0tNGxKx41xgiA== X-Google-Smtp-Source: ABdhPJwvO0ceaT1Gwcfx1CktkNozvZ6zMAlUDokAskoESFBWJEYOu7M5ofJecmRKPvhAMnh6ogTJ1A== X-Received: by 2002:a5d:534d:: with SMTP id t13mr19746490wrv.171.1625061148887; Wed, 30 Jun 2021 06:52:28 -0700 (PDT) Received: from gojira.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id g15sm193026wrs.50.2021.06.30.06.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 06:52:28 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: guohongzhi1@huawei.com, keith.wiles@intel.com, mb@smartsharesystems.com, thomas@monjalon.net, ferruh.yigit@intel.com, andrew.rybchenko@oktetlabs.ru, stable@dpdk.org Date: Wed, 30 Jun 2021 15:51:56 +0200 Message-Id: <20210630135158.8108-3-olivier.matz@6wind.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210630135158.8108-1-olivier.matz@6wind.com> References: <20210427135755.927-1-olivier.matz@6wind.com> <20210630135158.8108-1-olivier.matz@6wind.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v2 2/4] net/tap: fix Rx cksum flags on TCP packets 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 Sender: "stable" Since commit d5df2ae0428a ("net: fix unneeded replacement of TCP checksum 0"), the functions rte_ipv4_udptcp_cksum() or rte_ipv6_udptcp_cksum() can return either 0x0000 or 0xffff when used to verify a packet containing a valid checksum. This new behavior broke the checksum verification in tap driver for TCP packets: these packets are marked with PKT_RX_L4_CKSUM_BAD. Fix this by checking the 2 possible values. A next commit will introduce a checksum verification helper to simplify this a bit. Fixes: d5df2ae0428a ("net: fix unneeded replacement of TCP checksum 0") Cc: stable@dpdk.org Signed-off-by: Olivier Matz Acked-by: Andrew Rybchenko --- drivers/net/tap/rte_eth_tap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 5513cfd2d7..5429f611c1 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -350,6 +350,8 @@ tap_verify_csum(struct rte_mbuf *mbuf) return; } if (l4 == RTE_PTYPE_L4_UDP || l4 == RTE_PTYPE_L4_TCP) { + int cksum_ok; + l4_hdr = rte_pktmbuf_mtod_offset(mbuf, void *, l2_len + l3_len); /* Don't verify checksum for multi-segment packets. */ if (mbuf->nb_segs > 1) @@ -367,13 +369,13 @@ tap_verify_csum(struct rte_mbuf *mbuf) return; } } - cksum = ~rte_ipv4_udptcp_cksum(l3_hdr, l4_hdr); + cksum = rte_ipv4_udptcp_cksum(l3_hdr, l4_hdr); } else { /* l3 == RTE_PTYPE_L3_IPV6, checked above */ - cksum = ~rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr); + cksum = rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr); } - mbuf->ol_flags |= cksum ? - PKT_RX_L4_CKSUM_BAD : - PKT_RX_L4_CKSUM_GOOD; + cksum_ok = (cksum == 0) || (cksum == 0xffff); + mbuf->ol_flags |= cksum_ok ? + PKT_RX_L4_CKSUM_GOOD : PKT_RX_L4_CKSUM_BAD; } } -- 2.29.2