fixup "libmultipath: merge hwentries inside a conf file"
[multipath-tools/.git] / libmultipath / config.c
1 /*
2  * Copyright (c) 2004, 2005 Christophe Varoqui
3  * Copyright (c) 2005 Benjamin Marzinski, Redhat
4  * Copyright (c) 2005 Edward Goggin, EMC
5  */
6 #include <stdio.h>
7 #include <string.h>
8 #include <libudev.h>
9 #include <dirent.h>
10 #include <limits.h>
11 #include <errno.h>
12
13 #include "checkers.h"
14 #include "memory.h"
15 #include "util.h"
16 #include "debug.h"
17 #include "parser.h"
18 #include "dict.h"
19 #include "hwtable.h"
20 #include "vector.h"
21 #include "structs.h"
22 #include "config.h"
23 #include "blacklist.h"
24 #include "defaults.h"
25 #include "prio.h"
26 #include "devmapper.h"
27 #include "mpath_cmd.h"
28 #include "propsel.h"
29
30 static int
31 hwe_strmatch (const struct hwentry *hwe1, const struct hwentry *hwe2)
32 {
33         if ((hwe2->vendor && !hwe1->vendor) ||
34             (hwe1->vendor && (!hwe2->vendor ||
35                               strcmp(hwe1->vendor, hwe2->vendor))))
36                 return 1;
37
38         if ((hwe2->product && !hwe1->product) ||
39             (hwe1->product && (!hwe2->product ||
40                               strcmp(hwe1->product, hwe2->product))))
41                 return 1;
42
43         if ((hwe2->revision && !hwe1->revision) ||
44             (hwe1->revision && (!hwe2->revision ||
45                               strcmp(hwe1->revision, hwe2->revision))))
46                 return 1;
47
48         return 0;
49 }
50
51 static struct hwentry *
52 find_hwe_strmatch (const struct _vector *hwtable, const struct hwentry *hwe)
53 {
54         int i;
55         struct hwentry *tmp, *ret = NULL;
56
57         vector_foreach_slot (hwtable, tmp, i) {
58                 if (hwe_strmatch(tmp, hwe))
59                         continue;
60                 ret = tmp;
61                 break;
62         }
63         return ret;
64 }
65
66 static int
67 hwe_regmatch (const struct hwentry *hwe1, const char *vendor,
68               const char *product, const char *revision)
69 {
70         regex_t vre, pre, rre;
71         int retval = 1;
72
73         if (hwe1->vendor &&
74             regcomp(&vre, hwe1->vendor, REG_EXTENDED|REG_NOSUB))
75                 goto out;
76
77         if (hwe1->product &&
78             regcomp(&pre, hwe1->product, REG_EXTENDED|REG_NOSUB))
79                 goto out_vre;
80
81         if (hwe1->revision &&
82             regcomp(&rre, hwe1->revision, REG_EXTENDED|REG_NOSUB))
83                 goto out_pre;
84
85         if ((vendor || product || revision) &&
86             (!hwe1->vendor || !vendor ||
87              !regexec(&vre, vendor, 0, NULL, 0)) &&
88             (!hwe1->product || !product ||
89              !regexec(&pre, product, 0, NULL, 0)) &&
90             (!hwe1->revision || !revision ||
91              !regexec(&rre, revision, 0, NULL, 0)))
92                 retval = 0;
93
94         if (hwe1->revision)
95                 regfree(&rre);
96 out_pre:
97         if (hwe1->product)
98                 regfree(&pre);
99 out_vre:
100         if (hwe1->vendor)
101                 regfree(&vre);
102 out:
103         return retval;
104 }
105
106 static void _log_match(const char *fn, const struct hwentry *h,
107                        const char *vendor, const char *product,
108                        const char *revision)
109 {
110         condlog(4, "%s: found match /%s:%s:%s/ for '%s:%s:%s'", fn,
111                 h->vendor, h->product, h->revision,
112                 vendor, product, revision);
113 }
114 #define log_match(h, v, p, r) _log_match(__func__, (h), (v), (p), (r))
115
116 int
117 find_hwe (const struct _vector *hwtable,
118           const char * vendor, const char * product, const char * revision,
119           vector result)
120 {
121         int i, n = 0;
122         struct hwentry *tmp;
123
124         /*
125          * Search backwards here, and add forward.
126          * User modified entries are attached at the end of
127          * the list, so we have to check them first before
128          * continuing to the generic entries
129          */
130         vector_reset(result);
131         vector_foreach_slot_backwards (hwtable, tmp, i) {
132                 if (hwe_regmatch(tmp, vendor, product, revision))
133                         continue;
134                 if (vector_alloc_slot(result) != NULL) {
135                         vector_set_slot(result, tmp);
136                         n++;
137                 }
138                 log_match(tmp, vendor, product, revision);
139         }
140         condlog(n > 1 ? 3 : 4, "%s: found %d hwtable matches for %s:%s:%s",
141                 __func__, n, vendor, product, revision);
142         return n;
143 }
144
145 struct mpentry *find_mpe(vector mptable, char *wwid)
146 {
147         int i;
148         struct mpentry * mpe;
149
150         if (!wwid)
151                 return NULL;
152
153         vector_foreach_slot (mptable, mpe, i)
154                 if (mpe->wwid && !strcmp(mpe->wwid, wwid))
155                         return mpe;
156
157         return NULL;
158 }
159
160 char *get_mpe_wwid(vector mptable, char *alias)
161 {
162         int i;
163         struct mpentry * mpe;
164
165         if (!alias)
166                 return NULL;
167
168         vector_foreach_slot (mptable, mpe, i)
169                 if (mpe->alias && strcmp(mpe->alias, alias) == 0)
170                         return mpe->wwid;
171
172         return NULL;
173 }
174
175 void
176 free_hwe (struct hwentry * hwe)
177 {
178         if (!hwe)
179                 return;
180
181         if (hwe->vendor)
182                 FREE(hwe->vendor);
183
184         if (hwe->product)
185                 FREE(hwe->product);
186
187         if (hwe->revision)
188                 FREE(hwe->revision);
189
190         if (hwe->getuid)
191                 FREE(hwe->getuid);
192
193         if (hwe->uid_attribute)
194                 FREE(hwe->uid_attribute);
195
196         if (hwe->features)
197                 FREE(hwe->features);
198
199         if (hwe->hwhandler)
200                 FREE(hwe->hwhandler);
201
202         if (hwe->selector)
203                 FREE(hwe->selector);
204
205         if (hwe->checker_name)
206                 FREE(hwe->checker_name);
207
208         if (hwe->prio_name)
209                 FREE(hwe->prio_name);
210
211         if (hwe->prio_args)
212                 FREE(hwe->prio_args);
213
214         if (hwe->alias_prefix)
215                 FREE(hwe->alias_prefix);
216
217         if (hwe->bl_product)
218                 FREE(hwe->bl_product);
219
220         FREE(hwe);
221 }
222
223 void
224 free_hwtable (vector hwtable)
225 {
226         int i;
227         struct hwentry * hwe;
228
229         if (!hwtable)
230                 return;
231
232         vector_foreach_slot (hwtable, hwe, i)
233                 free_hwe(hwe);
234
235         vector_free(hwtable);
236 }
237
238 void
239 free_mpe (struct mpentry * mpe)
240 {
241         if (!mpe)
242                 return;
243
244         if (mpe->wwid)
245                 FREE(mpe->wwid);
246
247         if (mpe->selector)
248                 FREE(mpe->selector);
249
250         if (mpe->getuid)
251                 FREE(mpe->getuid);
252
253         if (mpe->uid_attribute)
254                 FREE(mpe->uid_attribute);
255
256         if (mpe->alias)
257                 FREE(mpe->alias);
258
259         if (mpe->prio_name)
260                 FREE(mpe->prio_name);
261
262         if (mpe->prio_args)
263                 FREE(mpe->prio_args);
264
265         FREE(mpe);
266 }
267
268 void
269 free_mptable (vector mptable)
270 {
271         int i;
272         struct mpentry * mpe;
273
274         if (!mptable)
275                 return;
276
277         vector_foreach_slot (mptable, mpe, i)
278                 free_mpe(mpe);
279
280         vector_free(mptable);
281 }
282
283 struct mpentry *
284 alloc_mpe (void)
285 {
286         struct mpentry * mpe = (struct mpentry *)
287                                 MALLOC(sizeof(struct mpentry));
288
289         return mpe;
290 }
291
292 struct hwentry *
293 alloc_hwe (void)
294 {
295         struct hwentry * hwe = (struct hwentry *)
296                                 MALLOC(sizeof(struct hwentry));
297
298         return hwe;
299 }
300
301 static char *
302 set_param_str(const char * str)
303 {
304         char * dst;
305         int len;
306
307         if (!str)
308                 return NULL;
309
310         len = strlen(str);
311
312         if (!len)
313                 return NULL;
314
315         dst = (char *)MALLOC(len + 1);
316
317         if (!dst)
318                 return NULL;
319
320         strcpy(dst, str);
321         return dst;
322 }
323
324 #define merge_str(s) \
325         if (!dst->s && src->s) { \
326                 if (!(dst->s = set_param_str(src->s))) \
327                         return 1; \
328         }
329
330 #define merge_num(s) \
331         if (!dst->s && src->s) \
332                 dst->s = src->s
333
334
335 static int
336 merge_hwe (struct hwentry * dst, struct hwentry * src)
337 {
338         char id[SCSI_VENDOR_SIZE+PATH_PRODUCT_SIZE];
339         merge_str(vendor);
340         merge_str(product);
341         merge_str(revision);
342         merge_str(getuid);
343         merge_str(uid_attribute);
344         merge_str(features);
345         merge_str(hwhandler);
346         merge_str(selector);
347         merge_str(checker_name);
348         merge_str(prio_name);
349         merge_str(prio_args);
350         merge_str(alias_prefix);
351         merge_str(bl_product);
352         merge_num(pgpolicy);
353         merge_num(pgfailback);
354         merge_num(rr_weight);
355         merge_num(no_path_retry);
356         merge_num(minio);
357         merge_num(minio_rq);
358         merge_num(flush_on_last_del);
359         merge_num(fast_io_fail);
360         merge_num(dev_loss);
361         merge_num(user_friendly_names);
362         merge_num(retain_hwhandler);
363         merge_num(detect_prio);
364         merge_num(detect_checker);
365         merge_num(deferred_remove);
366         merge_num(delay_watch_checks);
367         merge_num(delay_wait_checks);
368         merge_num(skip_kpartx);
369         merge_num(max_sectors_kb);
370         merge_num(ghost_delay);
371         merge_num(all_tg_pt);
372
373         snprintf(id, sizeof(id), "%s/%s", dst->vendor, dst->product);
374         reconcile_features_with_options(id, &dst->features,
375                                         &dst->no_path_retry,
376                                         &dst->retain_hwhandler);
377         return 0;
378 }
379
380 static int
381 merge_mpe(struct mpentry *dst, struct mpentry *src)
382 {
383         if (!dst || !src)
384                 return 1;
385
386         merge_str(alias);
387         merge_str(uid_attribute);
388         merge_str(getuid);
389         merge_str(selector);
390         merge_str(features);
391         merge_str(prio_name);
392         merge_str(prio_args);
393
394         if (dst->prkey_source == PRKEY_SOURCE_NONE &&
395             src->prkey_source != PRKEY_SOURCE_NONE) {
396                 dst->prkey_source = src->prkey_source;
397                 memcpy(&dst->reservation_key, &src->reservation_key,
398                        sizeof(dst->reservation_key));
399         }
400
401         merge_num(pgpolicy);
402         merge_num(pgfailback);
403         merge_num(rr_weight);
404         merge_num(no_path_retry);
405         merge_num(minio);
406         merge_num(minio_rq);
407         merge_num(flush_on_last_del);
408         merge_num(attribute_flags);
409         merge_num(user_friendly_names);
410         merge_num(deferred_remove);
411         merge_num(delay_watch_checks);
412         merge_num(delay_wait_checks);
413         merge_num(marginal_path_err_sample_time);
414         merge_num(marginal_path_err_rate_threshold);
415         merge_num(marginal_path_err_recheck_gap_time);
416         merge_num(marginal_path_double_failed_time);
417         merge_num(skip_kpartx);
418         merge_num(max_sectors_kb);
419         merge_num(ghost_delay);
420         merge_num(uid);
421         merge_num(gid);
422         merge_num(mode);
423
424         return 0;
425 }
426
427 void merge_mptable(vector mptable)
428 {
429         struct mpentry *mp1, *mp2;
430         int i, j;
431
432         vector_foreach_slot(mptable, mp1, i) {
433                 j = i + 1;
434                 vector_foreach_slot_after(mptable, mp2, j) {
435                         if (strcmp(mp1->wwid, mp2->wwid))
436                                 continue;
437                         condlog(1, "%s: duplicate multipath config section for %s",
438                                 __func__, mp1->wwid);
439                         merge_mpe(mp2, mp1);
440                         free_mpe(mp1);
441                         vector_del_slot(mptable, i);
442                         i--;
443                         break;
444                 }
445         }
446 }
447
448 int
449 store_hwe (vector hwtable, struct hwentry * dhwe)
450 {
451         struct hwentry * hwe;
452
453         if (find_hwe_strmatch(hwtable, dhwe))
454                 return 0;
455
456         if (!(hwe = alloc_hwe()))
457                 return 1;
458
459         if (!dhwe->vendor || !(hwe->vendor = set_param_str(dhwe->vendor)))
460                 goto out;
461
462         if (!dhwe->product || !(hwe->product = set_param_str(dhwe->product)))
463                 goto out;
464
465         if (dhwe->revision && !(hwe->revision = set_param_str(dhwe->revision)))
466                 goto out;
467
468         if (dhwe->uid_attribute && !(hwe->uid_attribute = set_param_str(dhwe->uid_attribute)))
469                 goto out;
470
471         if (dhwe->getuid && !(hwe->getuid = set_param_str(dhwe->getuid)))
472                 goto out;
473
474         if (dhwe->features && !(hwe->features = set_param_str(dhwe->features)))
475                 goto out;
476
477         if (dhwe->hwhandler && !(hwe->hwhandler = set_param_str(dhwe->hwhandler)))
478                 goto out;
479
480         if (dhwe->selector && !(hwe->selector = set_param_str(dhwe->selector)))
481                 goto out;
482
483         if (dhwe->checker_name && !(hwe->checker_name = set_param_str(dhwe->checker_name)))
484                 goto out;
485
486         if (dhwe->prio_name && !(hwe->prio_name = set_param_str(dhwe->prio_name)))
487                 goto out;
488
489         if (dhwe->prio_args && !(hwe->prio_args = set_param_str(dhwe->prio_args)))
490                 goto out;
491
492         if (dhwe->alias_prefix && !(hwe->alias_prefix = set_param_str(dhwe->alias_prefix)))
493                 goto out;
494
495         hwe->pgpolicy = dhwe->pgpolicy;
496         hwe->pgfailback = dhwe->pgfailback;
497         hwe->rr_weight = dhwe->rr_weight;
498         hwe->no_path_retry = dhwe->no_path_retry;
499         hwe->minio = dhwe->minio;
500         hwe->minio_rq = dhwe->minio_rq;
501         hwe->flush_on_last_del = dhwe->flush_on_last_del;
502         hwe->fast_io_fail = dhwe->fast_io_fail;
503         hwe->dev_loss = dhwe->dev_loss;
504         hwe->user_friendly_names = dhwe->user_friendly_names;
505         hwe->retain_hwhandler = dhwe->retain_hwhandler;
506         hwe->detect_prio = dhwe->detect_prio;
507         hwe->detect_checker = dhwe->detect_checker;
508         hwe->ghost_delay = dhwe->ghost_delay;
509
510         if (dhwe->bl_product && !(hwe->bl_product = set_param_str(dhwe->bl_product)))
511                 goto out;
512
513         if (!vector_alloc_slot(hwtable))
514                 goto out;
515
516         vector_set_slot(hwtable, hwe);
517         return 0;
518 out:
519         free_hwe(hwe);
520         return 1;
521 }
522
523 static void
524 factorize_hwtable (vector hw, int n, const char *table_desc)
525 {
526         struct hwentry *hwe1, *hwe2;
527         int i, j;
528
529 restart:
530         vector_foreach_slot(hw, hwe1, i) {
531                 /* drop invalid device configs */
532                 if (i >= n && (!hwe1->vendor || !hwe1->product)) {
533                         condlog(0, "device config in %s missing vendor or product parameter",
534                                 table_desc);
535                         vector_del_slot(hw, i--);
536                         free_hwe(hwe1);
537                         continue;
538                 }
539                 j = n > i + 1 ? n : i + 1;
540                 vector_foreach_slot_after(hw, hwe2, j) {
541                         if (hwe_strmatch(hwe2, hwe1) == 0) {
542                                 condlog(i >= n ? 1 : 3,
543                                         "%s: duplicate device section for %s:%s:%s in %s",
544                                         __func__, hwe1->vendor, hwe1->product,
545                                         hwe1->revision, table_desc);
546                                 vector_del_slot(hw, i);
547                                 merge_hwe(hwe2, hwe1);
548                                 free_hwe(hwe1);
549                                 if (i < n)
550                                         n -= 1;
551                                 /*
552                                  * Play safe here; we have modified
553                                  * the original vector so the outer
554                                  * vector_foreach_slot() might
555                                  * become confused.
556                                  */
557                                 goto restart;
558                         }
559                 }
560         }
561         return;
562 }
563
564 struct config *
565 alloc_config (void)
566 {
567         return (struct config *)MALLOC(sizeof(struct config));
568 }
569
570 void
571 free_config (struct config * conf)
572 {
573         if (!conf)
574                 return;
575
576         if (conf->multipath_dir)
577                 FREE(conf->multipath_dir);
578
579         if (conf->selector)
580                 FREE(conf->selector);
581
582         if (conf->uid_attribute)
583                 FREE(conf->uid_attribute);
584
585         if (conf->uid_attrs)
586                 FREE(conf->uid_attrs);
587
588         if (conf->getuid)
589                 FREE(conf->getuid);
590
591         if (conf->features)
592                 FREE(conf->features);
593
594         if (conf->hwhandler)
595                 FREE(conf->hwhandler);
596
597         if (conf->bindings_file)
598                 FREE(conf->bindings_file);
599
600         if (conf->wwids_file)
601                 FREE(conf->wwids_file);
602
603         if (conf->prkeys_file)
604                 FREE(conf->prkeys_file);
605
606         if (conf->prio_name)
607                 FREE(conf->prio_name);
608
609         if (conf->alias_prefix)
610                 FREE(conf->alias_prefix);
611         if (conf->partition_delim)
612                 FREE(conf->partition_delim);
613
614         if (conf->prio_args)
615                 FREE(conf->prio_args);
616
617         if (conf->checker_name)
618                 FREE(conf->checker_name);
619
620         if (conf->config_dir)
621                 FREE(conf->config_dir);
622
623         free_blacklist(conf->blist_devnode);
624         free_blacklist(conf->blist_wwid);
625         free_blacklist(conf->blist_property);
626         free_blacklist_device(conf->blist_device);
627
628         free_blacklist(conf->elist_devnode);
629         free_blacklist(conf->elist_wwid);
630         free_blacklist(conf->elist_property);
631         free_blacklist_device(conf->elist_device);
632
633         free_mptable(conf->mptable);
634         free_hwtable(conf->hwtable);
635         free_hwe(conf->overrides);
636         free_keywords(conf->keywords);
637         FREE(conf);
638 }
639
640 static void free_namelist(void *nl)
641 {
642         free(nl);
643 }
644
645 /* if multipath fails to process the config directory, it should continue,
646  * with just a warning message */
647 static void
648 process_config_dir(struct config *conf, vector keywords, char *dir)
649 {
650         struct dirent **namelist;
651         int i, n;
652         char path[LINE_MAX];
653         int old_hwtable_size;
654
655         if (dir[0] != '/') {
656                 condlog(1, "config_dir '%s' must be a fully qualified path",
657                         dir);
658                 return;
659         }
660         n = scandir(dir, &namelist, NULL, alphasort);
661         if (n < 0) {
662                 if (errno == ENOENT)
663                         condlog(3, "No configuration dir '%s'", dir);
664                 else
665                         condlog(0, "couldn't open configuration dir '%s': %s",
666                                 dir, strerror(errno));
667                 return;
668         } else if (n == 0)
669                 return;
670         pthread_cleanup_push(free_namelist, namelist);
671         for (i = 0; i < n; i++) {
672                 if (!strstr(namelist[i]->d_name, ".conf"))
673                         continue;
674                 old_hwtable_size = VECTOR_SIZE(conf->hwtable);
675                 snprintf(path, LINE_MAX, "%s/%s", dir, namelist[i]->d_name);
676                 path[LINE_MAX-1] = '\0';
677                 process_file(conf, path);
678                 factorize_hwtable(conf->hwtable, old_hwtable_size,
679                                   namelist[i]->d_name);
680         }
681         pthread_cleanup_pop(1);
682 }
683
684 struct config *
685 load_config (char * file)
686 {
687         struct config *conf = alloc_config();
688
689         if (!conf)
690                 return NULL;
691
692         /*
693          * internal defaults
694          */
695         conf->verbosity = DEFAULT_VERBOSITY;
696
697         get_sys_max_fds(&conf->max_fds);
698         conf->bindings_file = set_default(DEFAULT_BINDINGS_FILE);
699         conf->wwids_file = set_default(DEFAULT_WWIDS_FILE);
700         conf->prkeys_file = set_default(DEFAULT_PRKEYS_FILE);
701         conf->multipath_dir = set_default(DEFAULT_MULTIPATHDIR);
702         conf->attribute_flags = 0;
703         conf->reassign_maps = DEFAULT_REASSIGN_MAPS;
704         conf->checkint = DEFAULT_CHECKINT;
705         conf->max_checkint = 0;
706         conf->force_sync = DEFAULT_FORCE_SYNC;
707         conf->partition_delim = DEFAULT_PARTITION_DELIM;
708         conf->processed_main_config = 0;
709         conf->find_multipaths = DEFAULT_FIND_MULTIPATHS;
710         conf->uxsock_timeout = DEFAULT_REPLY_TIMEOUT;
711         conf->retrigger_tries = DEFAULT_RETRIGGER_TRIES;
712         conf->retrigger_delay = DEFAULT_RETRIGGER_DELAY;
713         conf->uev_wait_timeout = DEFAULT_UEV_WAIT_TIMEOUT;
714         conf->disable_changed_wwids = DEFAULT_DISABLE_CHANGED_WWIDS;
715         conf->remove_retries = 0;
716         conf->ghost_delay = DEFAULT_GHOST_DELAY;
717         conf->all_tg_pt = DEFAULT_ALL_TG_PT;
718
719         /*
720          * preload default hwtable
721          */
722         conf->hwtable = vector_alloc();
723         if (!conf->hwtable)
724                         goto out;
725         if (setup_default_hwtable(conf->hwtable))
726                 goto out;
727
728 #ifdef CHECK_BUILTIN_HWTABLE
729         factorize_hwtable(conf->hwtable, 0, "builtin");
730 #endif
731         /*
732          * read the config file
733          */
734         conf->keywords = vector_alloc();
735         init_keywords(conf->keywords);
736         if (filepresent(file)) {
737                 int builtin_hwtable_size;
738
739                 builtin_hwtable_size = VECTOR_SIZE(conf->hwtable);
740                 if (process_file(conf, file)) {
741                         condlog(0, "error parsing config file");
742                         goto out;
743                 }
744                 factorize_hwtable(conf->hwtable, builtin_hwtable_size, file);
745         }
746
747         conf->processed_main_config = 1;
748         if (conf->config_dir == NULL)
749                 conf->config_dir = set_default(DEFAULT_CONFIG_DIR);
750         if (conf->config_dir && conf->config_dir[0] != '\0')
751                 process_config_dir(conf, conf->keywords, conf->config_dir);
752
753         /*
754          * fill the voids left in the config file
755          */
756         if (conf->max_checkint == 0)
757                 conf->max_checkint = MAX_CHECKINT(conf->checkint);
758         if (conf->blist_devnode == NULL) {
759                 conf->blist_devnode = vector_alloc();
760
761                 if (!conf->blist_devnode)
762                         goto out;
763         }
764         if (conf->blist_wwid == NULL) {
765                 conf->blist_wwid = vector_alloc();
766
767                 if (!conf->blist_wwid)
768                         goto out;
769         }
770         if (conf->blist_device == NULL) {
771                 conf->blist_device = vector_alloc();
772
773                 if (!conf->blist_device)
774                         goto out;
775         }
776         if (conf->blist_property == NULL) {
777                 conf->blist_property = vector_alloc();
778
779                 if (!conf->blist_property)
780                         goto out;
781         }
782
783         if (conf->elist_devnode == NULL) {
784                 conf->elist_devnode = vector_alloc();
785
786                 if (!conf->elist_devnode)
787                         goto out;
788         }
789         if (conf->elist_wwid == NULL) {
790                 conf->elist_wwid = vector_alloc();
791
792                 if (!conf->elist_wwid)
793                         goto out;
794         }
795
796         if (conf->elist_device == NULL) {
797                 conf->elist_device = vector_alloc();
798
799                 if (!conf->elist_device)
800                         goto out;
801         }
802
803         if (conf->elist_property == NULL) {
804                 conf->elist_property = vector_alloc();
805
806                 if (!conf->elist_property)
807                         goto out;
808         }
809         if (setup_default_blist(conf))
810                 goto out;
811
812         if (conf->mptable == NULL) {
813                 conf->mptable = vector_alloc();
814                 if (!conf->mptable)
815                         goto out;
816         }
817
818         merge_mptable(conf->mptable);
819         merge_blacklist(conf->blist_devnode);
820         merge_blacklist(conf->blist_property);
821         merge_blacklist(conf->blist_wwid);
822         merge_blacklist_device(conf->blist_device);
823         merge_blacklist(conf->elist_devnode);
824         merge_blacklist(conf->elist_property);
825         merge_blacklist(conf->elist_wwid);
826         merge_blacklist_device(conf->elist_device);
827
828         if (conf->bindings_file == NULL)
829                 conf->bindings_file = set_default(DEFAULT_BINDINGS_FILE);
830
831         if (!conf->multipath_dir || !conf->bindings_file ||
832             !conf->wwids_file || !conf->prkeys_file)
833                 goto out;
834
835         return conf;
836 out:
837         free_config(conf);
838         return NULL;
839 }