patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Wenzhuo Lu <wenzhuo.lu@intel.com>, Jingjing Wu <jingjing.wu@intel.com>
Cc: dev@dpdk.org, stable@dpdk.org
Subject: [dpdk-stable] [PATCH 2/6] app/testpmd: fix forward ports update
Date: Thu,  3 May 2018 10:31:44 +0000	[thread overview]
Message-ID: <1525343508-29487-3-git-send-email-matan@mellanox.com> (raw)
In-Reply-To: <1525343508-29487-1-git-send-email-matan@mellanox.com>

When the forward ports are changed either by new portlist\portmask
configurations or by a port detachment, all the old forward streams
are freed and new streams are allocated to be aligned with the new
forward ports.

If the number of the forward ports drops to 0, there is an attempt
to wrongly allocate 0 memory for the streams.

Skip the streams memory allocation if no forward ports are configured.

Fixes: ce8d561418d4 ("app/testpmd: add port configuration settings")
Cc: stable@dpdk.org

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 app/test-pmd/testpmd.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index db23f23..8ac2070 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -882,18 +882,23 @@ static void eth_dev_event_callback(char *device_name,
 
 	/* init new */
 	nb_fwd_streams = nb_fwd_streams_new;
-	fwd_streams = rte_zmalloc("testpmd: fwd_streams",
-		sizeof(struct fwd_stream *) * nb_fwd_streams, RTE_CACHE_LINE_SIZE);
-	if (fwd_streams == NULL)
-		rte_exit(EXIT_FAILURE, "rte_zmalloc(%d (struct fwd_stream *)) "
-						"failed\n", nb_fwd_streams);
-
-	for (sm_id = 0; sm_id < nb_fwd_streams; sm_id++) {
-		fwd_streams[sm_id] = rte_zmalloc("testpmd: struct fwd_stream",
-				sizeof(struct fwd_stream), RTE_CACHE_LINE_SIZE);
-		if (fwd_streams[sm_id] == NULL)
-			rte_exit(EXIT_FAILURE, "rte_zmalloc(struct fwd_stream)"
-								" failed\n");
+	if (nb_fwd_streams) {
+		fwd_streams = rte_zmalloc("testpmd: fwd_streams",
+			sizeof(struct fwd_stream *) * nb_fwd_streams,
+			RTE_CACHE_LINE_SIZE);
+		if (fwd_streams == NULL)
+			rte_exit(EXIT_FAILURE, "rte_zmalloc(%d"
+				 " (struct fwd_stream *)) failed\n",
+				 nb_fwd_streams);
+
+		for (sm_id = 0; sm_id < nb_fwd_streams; sm_id++) {
+			fwd_streams[sm_id] = rte_zmalloc("testpmd:"
+				" struct fwd_stream", sizeof(struct fwd_stream),
+				RTE_CACHE_LINE_SIZE);
+			if (fwd_streams[sm_id] == NULL)
+				rte_exit(EXIT_FAILURE, "rte_zmalloc"
+					 "(struct fwd_stream) failed\n");
+		}
 	}
 
 	return 0;
-- 
1.9.5

  parent reply	other threads:[~2018-05-03 10:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1525343508-29487-1-git-send-email-matan@mellanox.com>
2018-05-03 10:31 ` [dpdk-stable] [PATCH 1/6] app/testpmd: fix valid ports prints Matan Azrad
2018-05-03 10:31 ` Matan Azrad [this message]
2018-05-03 10:31 ` [dpdk-stable] [PATCH 3/6] app/testpmd: fix forward ports Rx flush Matan Azrad
2018-05-03 10:31 ` [dpdk-stable] [PATCH 4/6] app/testpmd: fix synchronic port hotplug Matan Azrad
2018-05-03 10:31 ` [dpdk-stable] [PATCH 5/6] app/testpmd: fix removed device link status asking Matan Azrad
2018-05-03 10:31 ` [dpdk-stable] [PATCH 6/6] app/testpmd: fix asynchronic port removal Matan Azrad

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=1525343508-29487-3-git-send-email-matan@mellanox.com \
    --to=matan@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=stable@dpdk.org \
    --cc=wenzhuo.lu@intel.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).