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 B8113A10DA for ; Thu, 1 Aug 2019 14:08:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 799DE1C1D4; Thu, 1 Aug 2019 14:08:13 +0200 (CEST) Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) by dpdk.org (Postfix) with ESMTP id 8BFEA1C1D8 for ; Thu, 1 Aug 2019 14:08:12 +0200 (CEST) Received: by mail-ed1-f67.google.com with SMTP id x19so63005356eda.12 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=HGyS5RsTYRzFq3wT3Bc7OX76QbC16YKoosaqEm67V2beGQzFbK2l+sRTrHXdmSAdur Vt8NlwDq/LqwNkFy1uFrjQbJH0YPgZi15Oa51+Kprx8RCR4E1U9UTVs12gO/ab6DFRed VlH8PaXCjmD7xtrvFStdA18IqCV8DESQXFbExuCtt/h2Zl547EbgVbs5zrQnIPUYaq4J 2Jbh4I4Sf/S3X5yAejQXGX2axXHcqC6kTZMXBF5HGZTRkiHcP0xnV3QaMYJDsd/YnIFE e5RseQQvFV0WOQD9QnH+j9V1wlUKy0Qkul1ctKloVobTgZdoV1GoG9YPOtKcNfEQg6XP RijQ== X-Gm-Message-State: APjAAAWjYq01n2hUDnvhJLX3k8aCPROyzq82NkXmthbX/SNZXou+FJ4E PKD43vAZv88FrQ7G2WdQob2rMV3DbzBErkoJaLw= 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-stable] [PATCH] net/ena: fix L4 cksum flags condition for TX X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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" 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 >