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 32EB1430D1; Tue, 22 Aug 2023 17:44:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3996A406B7; Tue, 22 Aug 2023 17:44:58 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 9334440041 for ; Tue, 22 Aug 2023 17:44:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692719096; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZQx0psPPqbStTL+d++jdOiasFgByGQdXiWPSZhjeVck=; b=gaOBB29yiXHseyWC92MqfbZYJcQEYPgW1GULX1zeMGU49uaDNaHqRNfs0RjN8JFhm62CKQ 65wR0LHpptb1sL7seA2VKD5KUdxyUjJO2IO23rFwwBpHxqRKjZDAGjeaF6PZuhrCO0fy9c xpz6OYDrqGqVa+jc/MjC/prBhII896g= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-455-qDKSFYPJOw-LcrFXW3Z_ww-1; Tue, 22 Aug 2023 11:44:52 -0400 X-MC-Unique: qDKSFYPJOw-LcrFXW3Z_ww-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-50084bf5da1so2280157e87.0 for ; Tue, 22 Aug 2023 08:44:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692719091; x=1693323891; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZQx0psPPqbStTL+d++jdOiasFgByGQdXiWPSZhjeVck=; b=lymRvIeUWsip3psjsxB8uIS/7UqfbN1gtaSxmDUa5d7AYvq75at6zc9TJhAnhxj+bV Wpno2ddhtrCNzSjiiMnldRAOgF/fMztI/pyMXjwiFVZk3JiP7cNGBVgobTdHWsMr6Uq5 PGun3mUPaiki32W9IN30kwsBSmrHAtSE6zajqNjFjvAe5AK7EwCqh5bwGg5XI2bENahE M0BO9Fwcclyc7OUGdtvn3iBln9BahAoTAqCWbG+cbycPoTzwRWliMQXqeN7co85cOwG+ nzaE9LXK75hp8MIfxaDqqBq7KLl3WJeOfrLu2B5jOJkHKKBYo3+tYBdjyf5M1x/qsdoY qigQ== X-Gm-Message-State: AOJu0YzafWd3V7UjF5lwkNmn/vngOiY35vb1h09JsC9YIYqkez/dz8EK cSQICe2FTyqDhOtYMtaJt9dJdsZyWRZvbSfc84UppwUYtLv1ghOpjKf0/XCYs9NKW2CQ+2W2wE1 rgbQP06kkrL1thfJk0iE= X-Received: by 2002:a05:6512:3196:b0:4f8:5d2f:902a with SMTP id i22-20020a056512319600b004f85d2f902amr9012568lfe.60.1692719091090; Tue, 22 Aug 2023 08:44:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHcF6TEW8GiJYHhEzqLS9v64husmqjWspQ4wdFG3JWZQozWklUOmtDIDPGgfmDlnIVhdImW1t4VA+yc7dwzzWY= X-Received: by 2002:a05:6512:3196:b0:4f8:5d2f:902a with SMTP id i22-20020a056512319600b004f85d2f902amr9012542lfe.60.1692719090679; Tue, 22 Aug 2023 08:44:50 -0700 (PDT) MIME-Version: 1.0 References: <20230822073244.3751885-1-david.marchand@redhat.com> In-Reply-To: From: David Marchand Date: Tue, 22 Aug 2023 17:44:23 +0200 Message-ID: Subject: Re: [PATCH] net/tap: fix L4 checksum To: Olivier Matz Cc: dev@dpdk.org, stable@dpdk.org, Ales Musil , Thomas Monjalon , Ophir Munk , Keith Wiles , Raslan Darawsheh X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Tue, Aug 22, 2023 at 10:55=E2=80=AFAM Olivier Matz wrote: > > Hi David, > > On Tue, Aug 22, 2023 at 09:32:44AM +0200, David Marchand wrote: > > The L4 checksum offloading API does not require l4_len to be set. > > Make the driver discover the L4 headers size by itself. > > > > Fixes: 6546e76056e3 ("net/tap: calculate checksums of multi segs packet= s") > > Cc: stable@dpdk.org > > > > Signed-off-by: David Marchand > > Tested-by: Ales Musil > > --- > > .mailmap | 1 + > > drivers/net/tap/rte_eth_tap.c | 13 +++++++++++-- > > 2 files changed, 12 insertions(+), 2 deletions(-) > > > > diff --git a/.mailmap b/.mailmap > > index 864d33ee46..b6a21b35cb 100644 > > --- a/.mailmap > > +++ b/.mailmap > > @@ -40,6 +40,7 @@ Aleksandr Loktionov > > Aleksandr Miloshenko > > Aleksey Baulin > > Aleksey Katargin > > +Ales Musil > > Alexander Bechikov > > Alexander Belyakov > > Alexander Chernavin > > diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_ta= p.c > > index bf98f75559..0ab214847a 100644 > > --- a/drivers/net/tap/rte_eth_tap.c > > +++ b/drivers/net/tap/rte_eth_tap.c > > @@ -645,13 +645,22 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t nu= m_mbufs, > > ((mbuf->ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF= _F_TX_IPV4) || > > (mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) =3D=3D RTE= _MBUF_F_TX_UDP_CKSUM || > > (mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) =3D=3D RTE= _MBUF_F_TX_TCP_CKSUM))) { > > While looking at the patch, I noticed this line: > > mbuf->ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4) > > I think only RTE_MBUF_F_TX_IP_CKSUM should be checked. And tap_tx_l3_cksum is wrong too: if (ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4)) { This is a separate issue, I'll send another patch. > > > + unsigned int l4_len =3D 0; > > + > > is_cksum =3D 1; > > > > + if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) =3D= =3D > > + RTE_MBUF_F_TX_UDP_CKSUM) > > + l4_len =3D sizeof(struct rte_udp_hdr); > > + else if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK)= =3D=3D > > + RTE_MBUF_F_TX_TCP_CKSUM) > > + l4_len =3D sizeof(struct rte_tcp_hdr); > > + > > /* Support only packets with at least layer 4 > > * header included in the first segment > > */ > > seg_len =3D rte_pktmbuf_data_len(mbuf); > > - l234_hlen =3D mbuf->l2_len + mbuf->l3_len + mbuf-= >l4_len; > > + l234_hlen =3D mbuf->l2_len + mbuf->l3_len + l4_le= n; > > if (seg_len < l234_hlen) > > return -1; > > > > @@ -661,7 +670,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_= mbufs, > > rte_memcpy(m_copy, rte_pktmbuf_mtod(mbuf, void *)= , > > l234_hlen); > > tap_tx_l3_cksum(m_copy, mbuf->ol_flags, > > - mbuf->l2_len, mbuf->l3_len, mbuf->= l4_len, > > + mbuf->l2_len, mbuf->l3_len, l4_len= , > > &l4_cksum, &l4_phdr_cksum, > > &l4_raw_cksum); > > iovecs[k].iov_base =3D m_copy; > > -- > > 2.41.0 > > > > Using rte_ipv4_udptcp_cksum() in this code would probably simplify it, an= d may > solve other issues (for instance the 0 checksum for UDP which has a speci= al > meaning). I agree such a rework would make the code easier to read, and may solve other issues. But I prefer to keep my original fix as is, and do what you propose as a followup patch. --=20 David Marchand