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 2763BA10DA for ; Thu, 1 Aug 2019 13:45:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9D5C81C1DA; Thu, 1 Aug 2019 13:45:40 +0200 (CEST) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by dpdk.org (Postfix) with ESMTP id AD51E1C1D6 for ; Thu, 1 Aug 2019 13:45:39 +0200 (CEST) Received: by mail-lf1-f68.google.com with SMTP id z15so45742114lfh.13 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=tkM10UkXUGDfDmyyuIfm+2UdUZ4Di1wJr4NU0A/Xc6n1ZrL4SVq72Eu0ZzbKPk4AK1 2JWGObBajMhpOk79cAp17vbBy9la0ZxnpdngNLUll8nOLnMy8t4And9eglSw6qxDBJ18 4iCCGTad6oN91luikvG8fzBJwvnN8Kaffz0pAApHAjJD+jzNi29hoUHqdMnJtHIIRNre bL3K01GLsI/c3+TEB4WHhcbqx7ZAWr3V3dJs+aQUrT+a4lOjflI4GRhU4Qq1Zkk4O/SY tmMxEa8LYwp1zXx5LSO59cqK2ofhLw4sPXqwi9Z8iiRJw5EyzF4AyGsOSsGA19VHeTq+ D/fw== X-Gm-Message-State: APjAAAWWPhB/Yyxtray429KCIEnCDKgf97FfJhzQADOz7Bufe3qmbOdw eMsDEp7uhCgk5HHdU/Y1+HqytPirvOg= 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-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" 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