[dpdk-stable] patch 'ethdev: add lock to port allocation check' has been queued to stable release 18.02.2
luca.boccassi at gmail.com
luca.boccassi at gmail.com
Tue May 15 15:47:17 CEST 2018
Hi,
FYI, your patch has been queued to stable release 18.02.2
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/16/18. So please
shout if anyone has objections.
Thanks.
Luca Boccassi
---
>From e765733c1aa7a1da7ecc46c0223323965e8e437f Mon Sep 17 00:00:00 2001
From: Matan Azrad <matan at mellanox.com>
Date: Fri, 11 May 2018 01:58:32 +0200
Subject: [PATCH] ethdev: add lock to port allocation check
[ upstream commit ac7d3b6ddf87e1e0435de6d40cfe2749dc0ff9a4 ]
When comparing the port name, there can be a race condition with
a thread allocating a new port and writing the name at the same time.
It can lead to match with a partial name by error.
The check of the port is now considered as a critical section
protected with locks.
This fix will be even more required for multi-process when the
port availability will rely only on the name, in a following patch.
Fixes: 84934303a17c ("ethdev: synchronize port allocation")
Signed-off-by: Matan Azrad <matan at mellanox.com>
Acked-by: Thomas Monjalon <thomas at monjalon.net>
Reviewed-by: Andrew Rybchenko <arybchenko at solarflare.com>
Reviewed-by: Stephen Hemminger <stephen at networkplumber.org>
---
lib/librte_ether/rte_ethdev.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 30a0ba7da..e7f2b809c 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -222,8 +222,8 @@ rte_eth_dev_shared_data_prepare(void)
rte_spinlock_unlock(&rte_eth_shared_data_lock);
}
-struct rte_eth_dev *
-rte_eth_dev_allocated(const char *name)
+static struct rte_eth_dev *
+_rte_eth_dev_allocated(const char *name)
{
unsigned i;
@@ -235,6 +235,22 @@ rte_eth_dev_allocated(const char *name)
return NULL;
}
+struct rte_eth_dev *
+rte_eth_dev_allocated(const char *name)
+{
+ struct rte_eth_dev *ethdev;
+
+ rte_eth_dev_shared_data_prepare();
+
+ rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
+
+ ethdev = _rte_eth_dev_allocated(name);
+
+ rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
+
+ return ethdev;
+}
+
static uint16_t
rte_eth_dev_find_free_port(void)
{
@@ -281,7 +297,7 @@ rte_eth_dev_allocate(const char *name)
goto unlock;
}
- if (rte_eth_dev_allocated(name) != NULL) {
+ if (_rte_eth_dev_allocated(name) != NULL) {
RTE_LOG(ERR, EAL, "Ethernet Device with name %s already allocated!\n",
name);
goto unlock;
--
2.14.2
More information about the stable
mailing list