From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4A23C31E5B for ; Tue, 18 Jun 2019 16:53:07 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 4CD4C206E0 for ; Tue, 18 Jun 2019 16:53:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4CD4C206E0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org 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