From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 50440A0471 for ; Tue, 18 Jun 2019 18:53:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D6BCE1C24B; Tue, 18 Jun 2019 18:53:05 +0200 (CEST) Received: from mail-ua1-f67.google.com (mail-ua1-f67.google.com [209.85.222.67]) by dpdk.org (Postfix) with ESMTP id 7B0A51C249 for ; Tue, 18 Jun 2019 18:53:04 +0200 (CEST) Received: by mail-ua1-f67.google.com with SMTP id s4so6717943uad.7 for ; Tue, 18 Jun 2019 09:53:04 -0700 (PDT) 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; bh=va/GLGInWqycF/2Vda4u8pyYVXk6IBBLfPVaT317bCQ=; b=rXIckZi5jM1qgTW0eivnn+51W0IkVftWtpa7Z/T2LxAIfVxHXqXjRQUWNX8H9INq+A aEuplZmofLylHFtsK7BSS76jq2QNf22yWFFCNfIv8ClivzX4npzT7ea50e27cZYn2gbW wLCJXtY8FjFOKHRKGj9btVHSflIOSBf7XR9j6pGvAnQhOJ7JTVjYBFxGgI2LCkiHxLOe 2ChUa9w3XWsIIhaLYVEU1KvI7x9pSfyeo6TvT95XvHvf22HzcLvyD1+zrEOW8EZ23+Q6 6VXzB01qkFar7Y94unGmGPWd2DVqdg0LKpNSKTE99XcFdnjL0caXF9qfN5eOIsnNFFKM 2xgA== X-Gm-Message-State: APjAAAVzo7KVma93ME31cZ984jXf8y0t9YOBe2htwkxsWfG2iCKrg2UP 8AO9IVyD+8EO6Hog7T3vBadSwDkkK0+MfMqwomr7Ow== X-Google-Smtp-Source: APXvYqwn5KLPdSART/MCl8u8yA43NwkZQZ6k5EOwxdeb1a/fOSvR5sGgZ17S47NN4fNa3g55xkbJmzrBCH/saJ7Ys20= X-Received: by 2002:ab0:6198:: with SMTP id h24mr3941145uan.41.1560876783901; Tue, 18 Jun 2019 09:53:03 -0700 (PDT) MIME-Version: 1.0 References: <20190604000431.28763-1-stephen@networkplumber.org> <20190618164012.15233-1-stephen@networkplumber.org> In-Reply-To: <20190618164012.15233-1-stephen@networkplumber.org> From: David Marchand Date: Tue, 18 Jun 2019 18:52:53 +0200 Message-ID: To: Stephen Hemminger Cc: dev , Stephen Hemminger Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v3] examples/multi_process - fix crash in mp_client with sparse ports 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" On Tue, Jun 18, 2019 at 6:41 PM Stephen Hemminger < stephen@networkplumber.org> wrote: > From: Stephen Hemminger > > 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 > --- > .../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