add the ability to have blacklist exceptions for specific vendor:product
Benjamin Marzinski
maintainerPATCH 1/1 add the ability to have blacklist exceptions for specific vendor:product
This patch adds the ability to have blacklist exceptions for vendor:product devices. Also, the wwid and devnode exceptions weren't getting freed properly in free_config, so that is fixed as well.
-Ben
Benjamin E. Marzinski
[email protected]
libmultipath/blacklist.c +21 -2
@@ -174,11 +174,30 @@ blacklist (vector blist, vector elist, c }int -blacklist_device (vector blist,char * vendor,char * product) +blacklist_exceptions_device (vector elist,char * vendor,char * product) {int i;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 )) { +condlog (3 ,"%s:%s: exception-listed" , vendor, product); +return 1 ; + } + } +return 0 ; +} + +int +blacklist_device (vector blist,vector elist,char * vendor,char * product) +{ +int i; +struct blentry_device * ble; + +if (blacklist_exceptions_device (elist, vendor, product)) +return 0 ; + vector_foreach_slot (blist, ble, i) {if (!regexec (&ble->vendor_reg, vendor,0 ,NULL ,0 ) && !regexec (&ble->product_reg, product,0 ,NULL ,0 )) {
@@ -199,7 +218,7 @@ blacklist_path (struct config * conf, streturn 1 ;if (pp->vendor_id && pp->product_id && -blacklist_device (conf->blist_device, pp->vendor_id, pp->product_id)) +blacklist_device (conf->blist_device, conf->elist_device, pp->vendor_id, pp->product_id))return 1 ;return 0 ;
libmultipath/blacklist.h +1 -1
@@ -20,7 +20,7 @@ struct blentry_device {int setup_default_blist (struct config *);int alloc_ble_device (vector );int blacklist (vector ,vector ,char *); -int blacklist_device (vector ,char *,char *); +int blacklist_device (vector ,vector ,char *,char *);int blacklist_path (struct config *,struct path *);int store_ble (vector ,char *,int );int set_ble_device (vector ,char *,char *,int );
libmultipath/config.c +10 -4
@@ -334,10 +334,9 @@ free_config (struct config * conf)free_blacklist (conf->blist_wwid);free_blacklist_device (conf->blist_device); -if (conf->elist_devnode) -FREE (conf->elist_devnode); -if (conf->elist_wwid) -FREE (conf->elist_wwid); +free_blacklist (conf->elist_devnode); +free_blacklist (conf->elist_wwid); +free_blacklist_device (conf->elist_device);free_mptable (conf->mptable);free_hwtable (conf->hwtable);
@@ -422,6 +421,13 @@ load_config (char * file) goto out; } +if (conf->elist_device ==NULL ) { + conf->elist_device =vector_alloc (); + +if (!conf->elist_device) + goto out; + } +if (conf->mptable ==NULL ) { conf->mptable =vector_alloc ();
libmultipath/config.h +1 -0
@@ -80,6 +80,7 @@ struct config {vector blist_device;vector elist_devnode;vector elist_wwid; +vector elist_device; };struct config * conf;
libmultipath/dict.c +40 -1
72 lines not on this page · raw message
libmultipath/print.c +33 -0
@@ -946,6 +946,12 @@ snprint_blacklist_report (char * buff, iif (snprint_blacklist_devgroup (buff, len, &fwd, &conf->blist_device) ==0 )return len; +if ((len - fwd - threshold) <=0 ) +return len; + fwd +=snprintf (buff + fwd, len - fwd,"- exceptions:\n" ); +if (snprint_blacklist_devgroup (buff, len, &fwd, &conf->elist_device) ==0 ) +return len; +if (fwd > len)return len;return fwd;
@@ -1024,6 +1030,7 @@ snprint_blacklist_except (char * buff, i {int i;struct blentry * ele; +struct blentry_device * eled;int fwd =0 ;struct keyword *rootkw;struct keyword *kw;
@@ -1054,6 +1061,32 @@ snprint_blacklist_except (char * buff, iif (fwd > len)return len; } + rootkw =find_keyword (rootkw->sub,"device" ); +if (!rootkw) +return 0 ; + + vector_foreach_slot (conf->elist_device, eled, i) { + fwd +=snprintf (buff + fwd, len - fwd,"\tdevice {\n" ); +if (fwd > len) +return len; + kw =find_keyword (rootkw->sub,"vendor" ); +if (!kw) +return 0 ; + fwd +=snprint_keyword (buff + fwd, len - fwd,"\t\t%k %v\n" , + kw, eled); +if (fwd > len) +return len; + kw =find_keyword (rootkw->sub,"product" ); +if (!kw) +return 0 ; + fwd +=snprint_keyword (buff + fwd, len - fwd,"\t\t%k %v\n" , + kw, eled); +if (fwd > len) +return len; + fwd +=snprintf (buff + fwd, len - fwd,"\t}\n" ); +if (fwd > len) +return len; + } fwd +=snprintf (buff + fwd, len - fwd,"}\n" );if (fwd > len)return len;
Quoted 4 lines · Benjamin Marzinski
This patch adds the ability to have blacklist exceptions for vendor:product devices. Also, the wwid and devnode exceptions weren't getting freed properly in
free_config, so that is fixed as well.
Thanks for the prompt review, and enhancement.
Applied.