DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Subject: [dpdk-dev] [PATCH v4 2/4] examples/multi_process/client_server_mp - fix crash in mp_client with sparse ports
Date: Fri, 26 Jul 2019 09:50:52 -0700	[thread overview]
Message-ID: <20190726165054.24078-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20190726165054.24078-1-stephen@networkplumber.org>

From: Stephen Hemminger <sthemmin@microsoft.com>

The mp_client crashes if run on Azure or any system where ethdev
ports are owned. In that case, the tx_buffer and tx_stats for the
real port were initialized correctly, but the wrong port was used.

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.

Also:
   - the flush code is common enough that it should not be marked
     unlikely
   - combine conditions to reduce indentation
   - avoid unnecessary if() if sent is zero.

Fixes: e2366e74e029 ("examples: use buffered Tx")
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;
 		}
-- 
2.20.1


  parent reply	other threads:[~2019-07-26 16:51 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-09 15:09 [dpdk-dev] [PATCH v3 0/2] examples/client_server_mp: fix port issues Stephen Hemminger
2019-07-09 15:09 ` [dpdk-dev] [PATCH v3 1/2] examples/multi_process/client_server_mp: check port validity Stephen Hemminger
2019-07-09 15:09 ` [dpdk-dev] [PATCH v3 2/2] examples/multi_process - fix crash in mp_client with sparse ports Stephen Hemminger
2019-07-26 16:50 ` [dpdk-dev] [PATCH v4 0/4] examples/client_server_mp: fix port issues Stephen Hemminger
2019-07-26 16:50   ` [dpdk-dev] [PATCH v4 1/4] examples/multi_process/client_server_mp: check port validity Stephen Hemminger
2019-07-30  9:21     ` Matan Azrad
2019-07-30 15:56       ` Stephen Hemminger
2019-07-30 16:39         ` Matan Azrad
2019-07-30 16:50           ` Stephen Hemminger
2019-07-26 16:50   ` Stephen Hemminger [this message]
2019-07-26 16:50   ` [dpdk-dev] [PATCH v4 3/4] examples/multi_process/client_server_mp/mp_server: fix style Stephen Hemminger
2019-07-26 16:50   ` [dpdk-dev] [PATCH v4 4/4] examples/multi_process/client_server_mp/mp_server: use ether format address Stephen Hemminger
2019-08-02  2:58   ` [dpdk-dev] [PATCH v5 0/4] examples/client_server_mp: port id fixes Stephen Hemminger
2019-08-02  2:58     ` [dpdk-dev] [PATCH v5 1/4] examples/multi_process/client_server_mp: check port validity Stephen Hemminger
2019-08-02  5:33       ` Matan Azrad
2019-08-02 15:53         ` Stephen Hemminger
2019-08-04  8:31           ` Matan Azrad
2019-08-05 16:00             ` Stephen Hemminger
2019-08-06  8:19               ` Matan Azrad
2019-08-06 15:39                 ` Stephen Hemminger
2019-08-06 20:03                   ` Matan Azrad
2019-08-06 23:09                     ` Stephen Hemminger
2019-08-07  5:38                       ` Matan Azrad
2019-08-07  5:53                         ` Stephen Hemminger
2019-08-07  7:02                           ` Matan Azrad
2019-08-07 15:15                             ` Stephen Hemminger
2019-08-02  2:58     ` [dpdk-dev] [PATCH v5 2/4] examples/multi_process/client_server_mp - fix crash in mp_client with sparse ports Stephen Hemminger
2019-08-02  2:58     ` [dpdk-dev] [PATCH v5 3/4] examples/multi_process/client_server_mp/mp_server: fix style Stephen Hemminger
2019-08-02 11:09       ` David Marchand
2019-08-02  2:58     ` [dpdk-dev] [PATCH v5 4/4] examples/multi_process/client_server_mp/mp_server: use ether format address Stephen Hemminger
2019-08-02 23:52   ` [dpdk-dev] [PATCH v6 0/2] examples/client_server_mp: port id (fixes only) Stephen Hemminger
2019-08-02 23:52     ` [dpdk-dev] [PATCH v6 1/2] examples/multi_process/client_server_mp: check port validity Stephen Hemminger
2019-08-02 23:52     ` [dpdk-dev] [PATCH v6 2/2] examples/multi_process/client_server_mp - fix crash in mp_client with sparse ports Stephen Hemminger
2019-08-05 16:38   ` [dpdk-dev] [PATCH v7 0/2] examples/client_server_mp: port id (fixes only) Stephen Hemminger
2019-08-05 16:38     ` [dpdk-dev] [PATCH v7 1/2] examples/multi_process/client_server_mp: check port validity Stephen Hemminger
2019-08-06 12:07       ` Matan Azrad
2019-11-13 18:53         ` Stephen Hemminger
2019-08-05 16:38     ` [dpdk-dev] [PATCH v7 2/2] examples/multi_process/client_server_mp - fix crash in mp_client with sparse ports Stephen Hemminger
2019-08-07  5:40     ` [dpdk-dev] [PATCH v7 0/2] examples/client_server_mp: port id (fixes only) Matan Azrad
2019-11-25 22:51       ` 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=20190726165054.24078-3-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.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).