From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 24313A10DA for ; Thu, 1 Aug 2019 14:08:15 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A5B281C1DB; Thu, 1 Aug 2019 14:08:13 +0200 (CEST) Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by dpdk.org (Postfix) with ESMTP id 8735B1C1D4 for ; Thu, 1 Aug 2019 14:08:12 +0200 (CEST) Received: by mail-ed1-f66.google.com with SMTP id i11so5438475edq.0 for ; Thu, 01 Aug 2019 05:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ub8i+NG7wx0KJ+nzIgAqQfjrQjJSdsMT/HRrXtWwNpM=; b=K81B58DRaDMPG0JABI+WBVdpsOosRJpaWNT4FDcLDQiDlqQjeM0FEXIFzY8zgJUYsf C56oVl2M+TMXZDC9t/wh6DrjIMOLt/+pkRy/H1oacqucMdV3IlBvXfZ0ZnCh4EI5flqv vYaQu2XTZ5VXvSxWHxaGkGi1WSpDZQRdHtXmm/pnaZ+fLfI9Fb+Dcsz/q0VN0U63Oxb4 Es76X/YwBo4SNx3LiSdS4lvGc186Tu29wcX1L8eqm8T/YRu7zhBny4/U0rTM6kYSHh/P Usb6XSaEfaBeuUm0aYNnkbi4lS/MEfowqmLY4IXLfyqR0DKnuvLkk+rkaWMnlwjuyqoy 49Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ub8i+NG7wx0KJ+nzIgAqQfjrQjJSdsMT/HRrXtWwNpM=; b=IXdEhgqsK1CdbkF1LUkRCRxjXFETGB3q2lt8uPavUfONaPqDnSeFmrHzx2ygbrmf2e 0jiPzHwYG4hs8nILSRRCsaG4Kklt/ehXCpcIFagrogLWOhevELAO/sSgCc0FC6s4hNFz 8JDtUOevLu665/O2uIf/Y4dWa6G8LmZHJxP1zrOrhcUjbIRJkhw6ZZBJtg+Y0E9zZVwS HJZ1HwWWf6A98PLVp+EDVA3QaEYSx6XKlGLJunZVeJWHwbxV7VdPsrGjGStyZQVHuruj zyPLPIB6MGfcq44riYmkMGXYPO6y5Dkudn97WFHNDnItYb/H9m341GwP1hUoWg5x2TtI hUBQ== X-Gm-Message-State: APjAAAVU2HSBDhq5116uVj77hwipgxlvfg18GLopyU4zI701I7U89g3V cxFZ6BgsGONIj2yAYcHXJMbqOaQXa0XwJvsjcGo= X-Google-Smtp-Source: APXvYqwR2FhcTBvfQ3I2LyPdUEvSojkUBZREGwtRCT76Ys8jJ3tmn/ZFybtXIn45ERG+BMsggHPzh98Tdtb2CBz2kVQ= X-Received: by 2002:a17:906:5814:: with SMTP id m20mr71743279ejq.280.1564661292086; Thu, 01 Aug 2019 05:08:12 -0700 (PDT) MIME-Version: 1.0 References: <20190801114536.318-1-mba@semihalf.com> In-Reply-To: <20190801114536.318-1-mba@semihalf.com> From: =?UTF-8?Q?Micha=C5=82_Krawczyk?= Date: Thu, 1 Aug 2019 14:08:00 +0200 Message-ID: To: Maciej Bielski Cc: dev@dpdk.org, Marcin Wojtas , Guy Tzalik , Evgeny Schemeilin , Eduard Serra , igorc.mail@gmail.com, stable@dpdk.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH] net/ena: fix L4 cksum flags condition for TX X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" czw., 1 sie 2019 o 13:45 Maciej Bielski napisa=C5=82(a): > > During an if-condition evaluation, a 2-bit flag evaluates to 'true' for > '0x1', '0x2' and '0x3'. Thus, from this perspective these flags are > indistinguishable. To make them distinct, respective bits must be > extracted with a mask and then checked for strict equality. > > Specifically here, even if `PKT_TX_UDP_CKSUM` (value '0x3') was set, the > expression `mbuf->ol_flags & PKT_TX_TCP` (the second flag of value > '0x1') is evaluated first and the result is 'true'. In consequence, for > UDP packets the execution flow enters an incorrect branch. > > Fixes: 56b8b9b7e5d2 (net/ena: convert to new Tx offloads API) > Cc: stable@dpdk.org > > Signed-off-by: Maciej Bielski > Reported-by: Eduard Serra Acked-by: Michal Krawczyk > --- > drivers/net/ena/ena_ethdev.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c > index f58334080..eb9d643f0 100644 > --- a/drivers/net/ena/ena_ethdev.c > +++ b/drivers/net/ena/ena_ethdev.c > @@ -330,12 +330,13 @@ static inline void ena_tx_mbuf_prepare(struct rte_m= buf *mbuf, > } > > /* check if L4 checksum is needed */ > - if ((mbuf->ol_flags & PKT_TX_TCP_CKSUM) && > + if (((mbuf->ol_flags & PKT_TX_L4_MASK) =3D=3D PKT_TX_TCP_= CKSUM) && > (queue_offloads & DEV_TX_OFFLOAD_TCP_CKSUM)) { > ena_tx_ctx->l4_proto =3D ENA_ETH_IO_L4_PROTO_TCP; > ena_tx_ctx->l4_csum_enable =3D true; > - } else if ((mbuf->ol_flags & PKT_TX_UDP_CKSUM) && > - (queue_offloads & DEV_TX_OFFLOAD_UDP_CKSUM)) { > + } else if (((mbuf->ol_flags & PKT_TX_L4_MASK) =3D=3D > + PKT_TX_UDP_CKSUM) && > + (queue_offloads & DEV_TX_OFFLOAD_UDP_CKSU= M)) { > ena_tx_ctx->l4_proto =3D ENA_ETH_IO_L4_PROTO_UDP; > ena_tx_ctx->l4_csum_enable =3D true; > } else { > -- > 2.20.1 >