diff mbox series

eal: fix whitelists for hot plug devices

Message ID 20180831184259.14804-1-tomaszx.kulasek@intel.com (mailing list archive)
State Rejected, archived
Delegated to: Thomas Monjalon
Headers show
Series eal: fix whitelists for hot plug devices | expand

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Tomasz Kulasek Aug. 31, 2018, 6:42 p.m. UTC
Currently white/blacklists doesn't work for hotplugged devices.

This patch checks if device is on the blacklist before attempting
to attach it.

Fixes: a3ee360f4440 ("eal: add hotplug add/remove device")
Cc: jblunck@infradead.org

Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
---
 lib/librte_eal/common/eal_common_dev.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Gaëtan Rivet Aug. 31, 2018, 9:26 p.m. UTC | #1
Hi Tomasz,

On Fri, Aug 31, 2018 at 08:42:59PM +0200, Tomasz Kulasek wrote:
> Currently white/blacklists doesn't work for hotplugged devices.
> 

Current behavior is the intended behavior.
A blacklisted device, then hotplugged, should be probed.

The current devargs management was designed to allow this in
Commit: 55744d83d525 ("devargs: introduce insert function")

If you think this behavior should change, there should be a discussion
about it. If the community agrees with you, then the proper way to
change this would be by rewriting the above.
diff mbox series

Patch

diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 678dbca..5f4b600 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -147,6 +147,30 @@  int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn
 		return -ENOTSUP;
 	}
 
+	/* Check if device is blacklisted */
+	if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST)
+		ret = -EINVAL;
+	else
+		ret = 0;
+
+	da = NULL;
+	do {
+		da = rte_devargs_next(busname, da);
+		if (da != NULL && strcmp(da->name, devname) == 0) {
+			if (da->policy == RTE_DEV_BLACKLISTED)
+				ret = -EINVAL;
+			else
+				ret = 0;
+			break;
+		}
+	} while (da != NULL);
+
+	if (ret) {
+		RTE_LOG(INFO, EAL, "  Device is blacklisted (%s)\n",
+				devname);
+		return ret;
+	}
+
 	da = calloc(1, sizeof(*da));
 	if (da == NULL)
 		return -ENOMEM;