From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomasz Kulasek Subject: [PATCH] eal: fix whitelists for hot plug devices Date: Fri, 31 Aug 2018 20:42:59 +0200 Message-ID: <20180831184259.14804-1-tomaszx.kulasek@intel.com> Cc: daniel.verkamp@intel.com, james.r.harris@intel.com, shuhei.matsumoto.xt@hitachi.com, dariuszx.stojaczyk@intel.com, jblunck@infradead.org To: dev@dpdk.org Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 15E2A5F17 for ; Fri, 31 Aug 2018 20:43:57 +0200 (CEST) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- lib/librte_eal/common/eal_common_dev.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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; -- 2.7.4