DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: dev <dev@dpdk.org>, Stephen Hemminger <sthemmin@microsoft.com>
Subject: Re: [dpdk-dev] [PATCH v3] examples/multi_process - fix crash in mp_client with sparse ports
Date: Tue, 18 Jun 2019 18:52:53 +0200	[thread overview]
Message-ID: <CAJFAV8y0GNYFoa_Yc2WzsiV4cp2qrkL=WG=_19CRubnMOhUg7g@mail.gmail.com> (raw)
In-Reply-To: <20190618164012.15233-1-stephen@networkplumber.org>

On Tue, Jun 18, 2019 at 6:41 PM Stephen Hemminger <
stephen@networkplumber.org> wrote:

> From: Stephen Hemminger <sthemmin@microsoft.com>
>
> The mp_client crashes if run on Azure or any system where ethdev
> ports are owned. This is because the flush loop is confusing the
> index into the array of ports[] with the port id.
>
> For example if the server has Ports 3 and 5. Then calling
> rte_eth_tx_buffer_flush on any other buffer will dereference null
> because the tx buffer for that port was not allocated.
>
> v2
>    - fix typo
>    - the flush code is common enough that it should not be marked unlikely
>    - combine conditions to reduce indentation
>
> v3
>    - avoid unnecessary if() if sent is zero.
>

Annotations should be after the ---.



> Fixes: e2366e74e029 ("examples: use buffered Tx")
>

Cc: stable@dpdk.org


Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
> ---
>  .../client_server_mp/mp_client/client.c        | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/examples/multi_process/client_server_mp/mp_client/client.c
> b/examples/multi_process/client_server_mp/mp_client/client.c
> index c23dd3f378f7..361d90b54b2d 100644
> --- a/examples/multi_process/client_server_mp/mp_client/client.c
> +++ b/examples/multi_process/client_server_mp/mp_client/client.c
> @@ -246,19 +246,19 @@ main(int argc, char *argv[])
>
>         for (;;) {
>                 uint16_t i, rx_pkts;
> -               uint16_t port;
>
>                 rx_pkts = rte_ring_dequeue_burst(rx_ring, pkts,
>                                 PKT_READ_SIZE, NULL);
>
> -               if (unlikely(rx_pkts == 0)){
> -                       if (need_flush)
> -                               for (port = 0; port < ports->num_ports;
> port++) {
> -                                       sent =
> rte_eth_tx_buffer_flush(ports->id[port], client_id,
> -                                                       tx_buffer[port]);
> -                                       if (unlikely(sent))
> -                                               tx_stats->tx[port] += sent;
> -                               }
> +               if (rx_pkts == 0 && need_flush) {
> +                       for (i = 0; i < ports->num_ports; i++) {
> +                               uint16_t port = ports->id[i];
> +
> +                               sent = rte_eth_tx_buffer_flush(port,
> +                                                              client_id,
> +
> tx_buffer[port]);
> +                               tx_stats->tx[port] += sent;
> +                       }
>                         need_flush = 0;
>                         continue;
>                 }
>
>
Woh, had to concentrate to see that the pb was when accessing tx_buffer[]
and tx_stats->tx[] arrays, good catch :-)

Reviewed-by: David Marchand <david.marchand@redhat.com>

-- 
David Marchand

      reply	other threads:[~2019-06-18 16:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04  0:04 [dpdk-dev] [PATCH] " Stephen Hemminger
2019-06-04  1:15 ` [dpdk-dev] Meson build failing in ../drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c Stephen Hemminger
2019-06-14  7:53 ` [dpdk-dev] [PATCH] examples/multi_process - fix crash in mp_client with sparse ports David Marchand
2019-06-18 16:35 ` [dpdk-dev] [PATCH v2] " Stephen Hemminger
2019-06-18 16:40 ` [dpdk-dev] [PATCH v3] " Stephen Hemminger
2019-06-18 16:52   ` David Marchand [this message]

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='CAJFAV8y0GNYFoa_Yc2WzsiV4cp2qrkL=WG=_19CRubnMOhUg7g@mail.gmail.com' \
    --to=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    --cc=sthemmin@microsoft.com \
    /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).