[dpdk-stable] patch 'examples/multi_process: check server port validity' has been queued to LTS release 18.11.6

Kevin Traynor ktraynor at redhat.com
Wed Dec 11 22:26:40 CET 2019


Hi,

FYI, your patch has been queued to LTS release 18.11.6

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/17/19. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable-queue/commit/573bdb4f37ca0a1659e5b2ba8e611832a4c0c9f6

Thanks.

Kevin.

---
>From 573bdb4f37ca0a1659e5b2ba8e611832a4c0c9f6 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <sthemmin at microsoft.com>
Date: Mon, 5 Aug 2019 09:38:16 -0700
Subject: [PATCH] examples/multi_process: check server port validity

[ upstream commit 1f41d98c207aee8982ced709864c96c463d4503a ]

The mp_server incorrectly allows a port mask that included hidden
ports and which later caused either lost packets or failed initialization.

This fixes explicitly checking that each bit in portmask is a
valid port before using it.

Fixes: 5b7ba31148a8 ("ethdev: add port ownership")

Signed-off-by: Stephen Hemminger <sthemmin at microsoft.com>
Acked-by: Matan Azrad <matan at mellanox.com>
---
 .../client_server_mp/mp_server/args.c         | 40 ++++++++++---------
 .../client_server_mp/mp_server/args.h         |  2 +-
 .../client_server_mp/mp_server/init.c         |  7 +---
 3 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/examples/multi_process/client_server_mp/mp_server/args.c b/examples/multi_process/client_server_mp/mp_server/args.c
index b0d8d7665..3c2ca266b 100644
--- a/examples/multi_process/client_server_mp/mp_server/args.c
+++ b/examples/multi_process/client_server_mp/mp_server/args.c
@@ -11,4 +11,5 @@
 
 #include <rte_memory.h>
+#include <rte_ethdev.h>
 #include <rte_string_fns.h>
 
@@ -42,9 +43,9 @@ usage(void)
  */
 static int
-parse_portmask(uint8_t max_ports, const char *portmask)
+parse_portmask(const char *portmask)
 {
 	char *end = NULL;
-	unsigned long pm;
-	uint16_t count = 0;
+	unsigned long long pm;
+	uint16_t id;
 
 	if (portmask == NULL || *portmask == '\0')
@@ -52,19 +53,22 @@ parse_portmask(uint8_t max_ports, const char *portmask)
 
 	/* convert parameter to a number and verify */
-	pm = strtoul(portmask, &end, 16);
-	if (end == NULL || *end != '\0' || pm == 0)
+	errno = 0;
+	pm = strtoull(portmask, &end, 16);
+	if (errno != 0 || end == NULL || *end != '\0')
 		return -1;
 
-	/* loop through bits of the mask and mark ports */
-	while (pm != 0){
-		if (pm & 0x01){ /* bit is set in mask, use port */
-			if (count >= max_ports)
-				printf("WARNING: requested port %u not present"
-				" - ignoring\n", (unsigned)count);
-			else
-			    ports->id[ports->num_ports++] = count;
-		}
-		pm = (pm >> 1);
-		count++;
+	RTE_ETH_FOREACH_DEV(id) {
+		unsigned long msk = 1u << id;
+
+		if ((pm & msk) == 0)
+			continue;
+
+		pm &= ~msk;
+		ports->id[ports->num_ports++] = id;
+	}
+
+	if (pm != 0) {
+		printf("WARNING: leftover ports in mask %#llx - ignoring\n",
+		       pm);
 	}
 
@@ -100,5 +104,5 @@ parse_num_clients(const char *clients)
  */
 int
-parse_app_args(uint16_t max_ports, int argc, char *argv[])
+parse_app_args(int argc, char *argv[])
 {
 	int option_index, opt;
@@ -113,5 +117,5 @@ parse_app_args(uint16_t max_ports, int argc, char *argv[])
 		switch (opt){
 			case 'p':
-				if (parse_portmask(max_ports, optarg) != 0){
+				if (parse_portmask(optarg) != 0) {
 					usage();
 					return -1;
diff --git a/examples/multi_process/client_server_mp/mp_server/args.h b/examples/multi_process/client_server_mp/mp_server/args.h
index 79c190a33..52c8cc86e 100644
--- a/examples/multi_process/client_server_mp/mp_server/args.h
+++ b/examples/multi_process/client_server_mp/mp_server/args.h
@@ -6,5 +6,5 @@
 #define _ARGS_H_
 
-int parse_app_args(uint16_t max_ports, int argc, char *argv[]);
+int parse_app_args(int argc, char *argv[]);
 
 #endif /* ifndef _ARGS_H_ */
diff --git a/examples/multi_process/client_server_mp/mp_server/init.c b/examples/multi_process/client_server_mp/mp_server/init.c
index 3af5dc699..1b0569937 100644
--- a/examples/multi_process/client_server_mp/mp_server/init.c
+++ b/examples/multi_process/client_server_mp/mp_server/init.c
@@ -239,5 +239,5 @@ init(int argc, char *argv[])
 	int retval;
 	const struct rte_memzone *mz;
-	uint16_t i, total_ports;
+	uint16_t i;
 
 	/* init EAL, parsing EAL args */
@@ -248,7 +248,4 @@ init(int argc, char *argv[])
 	argv += retval;
 
-	/* get total number of ports */
-	total_ports = rte_eth_dev_count_total();
-
 	/* set up array for port data */
 	mz = rte_memzone_reserve(MZ_PORT_INFO, sizeof(*ports),
@@ -260,5 +257,5 @@ init(int argc, char *argv[])
 
 	/* parse additional, application arguments */
-	retval = parse_app_args(total_ports, argc, argv);
+	retval = parse_app_args(argc, argv);
 	if (retval != 0)
 		return -1;
-- 
2.21.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-12-11 21:24:16.514527152 +0000
+++ 0048-examples-multi_process-check-server-port-validity.patch	2019-12-11 21:24:12.707650391 +0000
@@ -1 +1 @@
-From 1f41d98c207aee8982ced709864c96c463d4503a Mon Sep 17 00:00:00 2001
+From 573bdb4f37ca0a1659e5b2ba8e611832a4c0c9f6 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 1f41d98c207aee8982ced709864c96c463d4503a ]
+
@@ -13 +14,0 @@
-Cc: stable at dpdk.org
@@ -108 +109 @@
-index 3d4a9cdfa..ad9f46f0a 100644
+index 3af5dc699..1b0569937 100644
@@ -111 +112 @@
-@@ -249,5 +249,5 @@ init(int argc, char *argv[])
+@@ -239,5 +239,5 @@ init(int argc, char *argv[])
@@ -118 +119 @@
-@@ -258,7 +258,4 @@ init(int argc, char *argv[])
+@@ -248,7 +248,4 @@ init(int argc, char *argv[])
@@ -126 +127 @@
-@@ -270,5 +267,5 @@ init(int argc, char *argv[])
+@@ -260,5 +257,5 @@ init(int argc, char *argv[])



More information about the stable mailing list