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 E1317A0A0F; Wed, 30 Jun 2021 15:52:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 511BA41282; Wed, 30 Jun 2021 15:52:33 +0200 (CEST) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mails.dpdk.org (Postfix) with ESMTP id 0B88C41221 for ; Wed, 30 Jun 2021 15:52:29 +0200 (CEST) Received: by mail-wr1-f46.google.com with SMTP id v5so3773475wrt.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=ejZdXyaAioDTGA35g2Dt91I9ZXB1/toYI1znhSbuagQpB2lBd4QcaKB4agmrghT5gF WdY4f/KATSQ36900TaXhnjkwzS+QzOZFk7wAXKf5173jvrducGbv3Vnss6i+CHOhNKRo F+4GtZPNmUNzaMCo5p+EQjFCfYpHdo2iIvFgh5prTDc1YvKwJAhpzS/5/HOsyUfYGGoq M+vlkJnfnkqIwos08EiGjEmh5ps7CK1uHWq3CBzyyZ7yDxp0cXoYN9mndykU1h9HoBvb oQHjn8v9r74zbTV5yMT/tPwEHB1VcTHNiiXodboFP5THmZq7ffFkjdOIYFwFjH7yOKnW QmFg== X-Gm-Message-State: AOAM531/ltwywfxjfGBxh0WGLL3rIG9TiPTGEH+2csUFbpo1QfEhR3r+ pl0e9Y6FWzHo4P2u7ij1QWxmajTDO3AfWg== 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-dev] [PATCH v2 2/4] net/tap: fix Rx cksum flags on TCP packets 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" 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