libmultipath: don't merge by regex in setup_default_blist()
authorMartin Wilck <mwilck@suse.com>
Fri, 8 Jun 2018 10:20:30 +0000 (12:20 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Thu, 21 Jun 2018 07:49:44 +0000 (09:49 +0200)
The merging of blacklist entries by regular expression leads
to similar problems as the merging of hwentries. Only merge
blacklist entries if they're exactly equal.

Signed-off-by: Martin Wilck <mwilck@suse.com>
libmultipath/blacklist.c
tests/hwtable.c

index 34a7e71..91ed7dd 100644 (file)
@@ -163,6 +163,25 @@ _blacklist_device (const struct _vector *blist, const char * vendor,
        return 0;
 }
 
+static int
+find_blacklist_device (const struct _vector *blist, const char * vendor,
+                      const char * product)
+{
+       int i;
+       struct blentry_device * ble;
+
+       vector_foreach_slot (blist, ble, i) {
+               if (((!vendor && !ble->vendor) ||
+                    (vendor && ble->vendor &&
+                     !strcmp(vendor, ble->vendor))) &&
+                   ((!product && !ble->product) ||
+                    (product && ble->product &&
+                     !strcmp(product, ble->product))))
+                       return 1;
+       }
+       return 0;
+}
+
 int
 setup_default_blist (struct config * conf)
 {
@@ -191,8 +210,8 @@ setup_default_blist (struct config * conf)
 
        vector_foreach_slot (conf->hwtable, hwe, i) {
                if (hwe->bl_product) {
-                       if (_blacklist_device(conf->blist_device, hwe->vendor,
-                                             hwe->bl_product))
+                       if (find_blacklist_device(conf->blist_device,
+                                                 hwe->vendor, hwe->bl_product))
                                continue;
                        if (alloc_ble_device(conf->blist_device))
                                return 1;
index 15f364e..8521594 100644 (file)
@@ -1399,13 +1399,7 @@ static int setup_product_blacklist(void **state)
 static void test_product_blacklist_matching(const struct hwt_state *hwt)
 {
        mock_path_flags(vnd_foo.value, prd_bar.value, BL_BY_DEVICE);
-#if BROKEN == 1
-       condlog(1, "%s: WARNING: broken blacklist test on line %d",
-               __func__, __LINE__ + 1);
-       mock_path(vnd_foo.value, prd_baz.value);
-#else
-       mock_path_blacklisted(vnd_foo.value, prd_baz.value);
-#endif
+       mock_path_flags(vnd_foo.value, prd_baz.value, BL_BY_DEVICE);
        mock_path(vnd_foo.value, prd_bam.value);
 }