From: "Michał Krawczyk" <mk@semihalf.com>
To: Maciej Bielski <mba@semihalf.com>
Cc: dev@dpdk.org, Marcin Wojtas <mw@semihalf.com>,
Guy Tzalik <gtzalik@amazon.com>,
Evgeny Schemeilin <evgenys@amazon.com>,
Eduard Serra <eduser25@gmail.com>,
igorc.mail@gmail.com, stable@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] net/ena: fix L4 cksum flags condition for TX
Date: Thu, 1 Aug 2019 14:08:00 +0200 [thread overview]
Message-ID: <CAJMMOfN02+EeKGjz9OP+aoF368m38rMtdjzkHpg0M1eub86_cw@mail.gmail.com> (raw)
In-Reply-To: <20190801114536.318-1-mba@semihalf.com>
czw., 1 sie 2019 o 13:45 Maciej Bielski <mba@semihalf.com> napisał(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 <mba@semihalf.com>
> Reported-by: Eduard Serra <eduser25@gmail.com>
Acked-by: Michal Krawczyk <mk@semihalf.com>
> ---
> 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
>
next prev parent reply other threads:[~2019-08-01 12:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-01 11:45 Maciej Bielski
2019-08-01 12:08 ` Michał Krawczyk [this message]
2019-08-05 17:44 ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJMMOfN02+EeKGjz9OP+aoF368m38rMtdjzkHpg0M1eub86_cw@mail.gmail.com \
--to=mk@semihalf.com \
--cc=dev@dpdk.org \
--cc=eduser25@gmail.com \
--cc=evgenys@amazon.com \
--cc=gtzalik@amazon.com \
--cc=igorc.mail@gmail.com \
--cc=mba@semihalf.com \
--cc=mw@semihalf.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).