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 B0E4BA0471 for ; Tue, 18 Jun 2019 18:40:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9D5DF1C23F; Tue, 18 Jun 2019 18:40:22 +0200 (CEST) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id AD4A71C22A for ; Tue, 18 Jun 2019 18:40:20 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id j2so7976296pfe.6 for ; Tue, 18 Jun 2019 09:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vwlht0CXrFlAqBQFnpJnyupYPVnWH0h/VgxxqOlbNnk=; b=ZpGSrK1Uj8HdQPpVQewuMC4voIIcQffLS752PgrblCDRnzR3QRQ+pzvLemGcTmzg6y W/G32vFXL2cyaLPeqqNXYTwCHyNub34YB5E74G6gTJNrZy6rzNa9knqVp6p2onvdLtMQ uEqGnI18aiGsJhlZHJXx0saiZxHCoCvvaf1qdBWNnIEypoyq7fQ82vUvFUfxhzbQM0fm KEfIh9B9RdPZK8zk4ToouLk1dBvq4WbDHtPPX7TPppYR3eBs47EncbylyzDeq6kuC7vq mCood8Gsb0qrw0G5KVB0ECwmVQiv7pkb5dA34eF0HmKywagB3TRVkm6iejWYztLiN1Gw loNg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vwlht0CXrFlAqBQFnpJnyupYPVnWH0h/VgxxqOlbNnk=; b=U0bvGyyV1IDv1LfBfQMiIj7pwa5rjniXDOm5d72MM+OP7cCrFDSWHAJ9/nquzh9buO YcQrppwOvucG7k/hggzox19Puz7Dr9XgSA1McIFPsOzH7g+8KF1Cly781RKZDithgZFs a4Zn+lgemBA5T3SUhi83btrX2HrAgXlZJbPyrT7PyRJ/2NQ4+4ZZX+m5OlZcIDZqp8oI dbxkbHXzaIecX09HnrUc/EgbHEXgmcswuhEbwf6W+lWiC1CqneUxd5JksHhWFTs/GjTJ yqjUgxdifiOw7UViNO8bFZXv7NSpBPjBDHML0sr3nJqmpFLkLweuoVG2+Qz6+4OYyPd/ Ya3A== X-Gm-Message-State: APjAAAW1m4Jg0QMjINGmLAIZe3NE3RDoMMThQPDr9qAcyDAGQBMrzGIt SP0Bd/ome8gu5nD8RyZ2ax2Vr8fwx8k= X-Google-Smtp-Source: APXvYqxOsYln5h5v+Gu/7loPT8zgrULIanRPRIPNjuhqPQ5sN2UgAHs1X96J38B4SxZTfrmHMJEn0A== X-Received: by 2002:a63:5902:: with SMTP id n2mr3400736pgb.291.1560876019551; Tue, 18 Jun 2019 09:40:19 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id n26sm21501535pfa.83.2019.06.18.09.40.18 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 09:40:19 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 18 Jun 2019 09:40:12 -0700 Message-Id: <20190618164012.15233-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190604000431.28763-1-stephen@networkplumber.org> References: <20190604000431.28763-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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" 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. Fixes: e2366e74e029 ("examples: use buffered Tx") 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; } -- 2.20.1