From patchwork Sun Mar 8 03:31:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 5961091 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 680CC9F66C for ; Sun, 8 Mar 2015 04:39:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7AA0820251 for ; Sun, 8 Mar 2015 04:39:36 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 556E9203AF for ; Sun, 8 Mar 2015 04:39:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t284afHn022388; Sat, 7 Mar 2015 23:36:41 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t284ZZne009392 for ; Sat, 7 Mar 2015 23:35:35 -0500 Received: from redhat.com (ask-08.lab.msp.redhat.com [10.15.85.8]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t284ZX9e015863; Sat, 7 Mar 2015 23:35:33 -0500 Received: by redhat.com (sSMTP sendmail emulation); Sat, 07 Mar 2015 21:32:00 -0600 From: "Benjamin Marzinski" To: device-mapper development Date: Sat, 7 Mar 2015 21:31:39 -0600 Message-Id: <1425785506-20419-9-git-send-email-bmarzins@redhat.com> In-Reply-To: <1425785506-20419-1-git-send-email-bmarzins@redhat.com> References: <1425785506-20419-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: dm-devel@redhat.com Cc: Christophe Varoqui Subject: [dm-devel] [PATCH 08/15] libmutipath: allow blanks in device blacklist X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As Brian De Wolf noticed, multipath crashes if you don't have both vendor and product specified in a device blacklist entry. This patch makes device blacklists work when either the vendor or the product is blank. If both are missing, the entry is ignored. Signed-off-by: Benjamin Marzinski --- libmultipath/blacklist.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libmultipath/blacklist.c b/libmultipath/blacklist.c index 3f9e80b..05f1697 100644 --- a/libmultipath/blacklist.c +++ b/libmultipath/blacklist.c @@ -135,8 +135,12 @@ _blacklist_exceptions_device(vector elist, char * vendor, char * product) struct blentry_device * ble; vector_foreach_slot (elist, ble, i) { - if (!regexec(&ble->vendor_reg, vendor, 0, NULL, 0) && - !regexec(&ble->product_reg, product, 0, NULL, 0)) + if (!ble->vendor && !ble->product) + continue; + if ((!ble->vendor || + !regexec(&ble->vendor_reg, vendor, 0, NULL, 0)) && + (!ble->product || + !regexec(&ble->product_reg, product, 0, NULL, 0))) return 1; } return 0; @@ -149,8 +153,12 @@ _blacklist_device (vector blist, char * vendor, char * product) struct blentry_device * ble; vector_foreach_slot (blist, ble, i) { - if (!regexec(&ble->vendor_reg, vendor, 0, NULL, 0) && - !regexec(&ble->product_reg, product, 0, NULL, 0)) + if (!ble->vendor && !ble->product) + continue; + if ((!ble->vendor || + !regexec(&ble->vendor_reg, vendor, 0, NULL, 0)) && + (!ble->product || + !regexec(&ble->product_reg, product, 0, NULL, 0))) return 1; } return 0;