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 00A75430D1 for ; Tue, 22 Aug 2023 17:44:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0FD93406B7; Tue, 22 Aug 2023 17:44:56 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 6F8D740041 for ; Tue, 22 Aug 2023 17:44:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692719093; 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=XOVzxcq/fTtOZZy7p7241co9NHX2dpxagxAlXQPu0QQunPHqmaTMRwf6fQAUR+Dn+IjxD4 r9Vpeavp/kuvV9AGzo4HgPhEK03C3FR60I/ma6/OcPPnzc9w5NdGd3uduylo9Muo1Y2rS+ B/OG1Uf7Mvb5qs24AQ/AVf/8Sm4Isu8= 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-628-Y7ZGuI9cOJWt4oJs7iFkUg-1; Tue, 22 Aug 2023 11:44:52 -0400 X-MC-Unique: Y7ZGuI9cOJWt4oJs7iFkUg-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-4fe369ab20fso4851267e87.2 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=FvpuPgc9vng4OwqzuKyMk/7hkAkCalC/kCMVdGbUUxFfIzTYS1D8Unxff+98/B1cSV FxrkeWYaYnJOa2HZyWZ4/NHfNLQDTtfheXffoLGyo6xoZgPqhTsBvDgL9ERELBS/P4Qn oFM1DcJQmuxKEleM/g4QZMzxVsIUOUjUNwy+ppb4mdHkd+afUqv8Vh08D1+Qga74R7BX VFcnUjU2RKhB9ag0XEq2qu/Pj6HLTFBWDnABRZw0HA98GSOfSdkgdmlKpapwqTSkJirN 8B4TmKd/NCdCWN7fvhlp2e611+ZKLAnCviRoIhvjKVgjNhWReH3fQdUrAAKE8otfQI9N stPw== X-Gm-Message-State: AOJu0YwYUUGcfD60w0iN08vsAZ7Wm9gq1qtM2yHtYlHufL2S5VmVXkrE qNLa4lZSoJiNtKFTHnJXrhLnQc/ardTcFIIDeFH4ETuF9Uy5d0UFNtPDkOv3ocIRCFaVAR81o7l 9maw4n9/DosRjHXNHTCOli04= X-Received: by 2002:a05:6512:3196:b0:4f8:5d2f:902a with SMTP id i22-20020a056512319600b004f85d2f902amr9012565lfe.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: 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 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