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 A74E9A10DA for ; Thu, 1 Aug 2019 13:45:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 757761C1CF; Thu, 1 Aug 2019 13:45:40 +0200 (CEST) Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by dpdk.org (Postfix) with ESMTP id 816DA1C1CF for ; Thu, 1 Aug 2019 13:45:39 +0200 (CEST) Received: by mail-lf1-f66.google.com with SMTP id c19so50005650lfm.10 for ; Thu, 01 Aug 2019 04:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Rc/0KSOXFNkR3bl0JvEh+xVPaOaosXtXBSKKr/sVxfQ=; b=MzbLJrhkDPwhloNRImC62PzEuY9Ai4WljmeLpf8ogS0TUn1bfZcQawfegQl2RC0IPb /+LBRTV7EB2l4g6+JLBzq6T73mDZge9GQy+WGEKeQDT2ad7KZn/FR9bq34yOJ9BIPcFE wK1Is9twOzVPj/NyLGMjGrTS1UM9qgxDsqEcSIk0v+KjMD++Y1cRmioB/bUk6rC5Q0Fk ZcCaEyVi/+sHHHREtwrUGKmTgfU9z/3aPR3sXiYXg59J7HBUMMmmVFyWOcaYOfhg2XHg yLsWkuZ1cFvdqv/W8exw2pTY5Vl9rtU4UVlizpDvqUAtDDY/NFWsRqkyGzb+FqGUroOr MN8A== 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:mime-version :content-transfer-encoding; bh=Rc/0KSOXFNkR3bl0JvEh+xVPaOaosXtXBSKKr/sVxfQ=; b=o9kkSubmu846mqEEUZvOF1VdC6ZKAMWZtEp5pAUPouIpRjzxUtnwoV/SCw++fh79ri FfEYldRxXQ8L8ua9H3rpSd64C0MGq/jHfKdMdoYzCcdGoFbauJa4q4gOzEo48tUbYG/7 LNA2PJMJJUN8lnf/1ZsG1ogMDuxRy5WYEyb6KmVEDY22OsXKEGKX6BWzM0syXXCBJTRm cm131YnjHXw/V9uA2CTwFOBsYNC68yasFSE0dOTD7vxM9UW/k/nOrJ9AfdyUQn087P2q qSB27TjYKa9OdSZAmLPetKuiFuWFY5GoP8Q70B+tT0p+2dgFFXc0Bd9Rvt2+qV+A40a9 oaBw== X-Gm-Message-State: APjAAAW2yjNWDxBT1BGzFSU1i+2nFsthwT49+J500pXvtuxZQMvI+M5X Q8v6XkBlg4dcY4S88tg6kUw= X-Google-Smtp-Source: APXvYqyDPShCvRfNSVyY2WLSwRN7VwgApWlAAa3zK11xU6Qo7QOvHIxV90IG8NCVI1X0ZSup6aOaeQ== X-Received: by 2002:a19:48c5:: with SMTP id v188mr59850436lfa.69.1564659939014; Thu, 01 Aug 2019 04:45:39 -0700 (PDT) Received: from mba.sh (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.googlemail.com with ESMTPSA id p28sm12270438lfh.55.2019.08.01.04.45.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 04:45:38 -0700 (PDT) From: Maciej Bielski To: dev@dpdk.org Cc: Maciej Bielski , Michal Krawczyk , Marcin Wojtas , Guy Tzalik , Evgeny Schemeilin , Eduard Serra , igorc.mail@gmail.com, stable@dpdk.org Date: Thu, 1 Aug 2019 13:45:36 +0200 Message-Id: <20190801114536.318-1-mba@semihalf.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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" 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 --- 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_mbuf *mbuf, } /* check if L4 checksum is needed */ - if ((mbuf->ol_flags & PKT_TX_TCP_CKSUM) && + if (((mbuf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM) && (queue_offloads & DEV_TX_OFFLOAD_TCP_CKSUM)) { ena_tx_ctx->l4_proto = ENA_ETH_IO_L4_PROTO_TCP; ena_tx_ctx->l4_csum_enable = 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) == + PKT_TX_UDP_CKSUM) && + (queue_offloads & DEV_TX_OFFLOAD_UDP_CKSUM)) { ena_tx_ctx->l4_proto = ENA_ETH_IO_L4_PROTO_UDP; ena_tx_ctx->l4_csum_enable = true; } else { -- 2.20.1