Blame SOURCES/0076-RHBZ-1056686-add-hw_str_match.patch

4ae388
---
4ae388
 libmultipath/config.c      |   10 ++++++++--
4ae388
 libmultipath/config.h      |    1 +
4ae388
 libmultipath/dict.c        |   28 ++++++++++++++++++++++++++++
4ae388
 multipath/multipath.conf.5 |   11 +++++++++++
4ae388
 4 files changed, 48 insertions(+), 2 deletions(-)
4ae388
4ae388
Index: multipath-tools-130222/libmultipath/config.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/config.c
4ae388
+++ multipath-tools-130222/libmultipath/config.c
4ae388
@@ -431,11 +431,16 @@ restart:
4ae388
 			break;
4ae388
 		j = n;
4ae388
 		vector_foreach_slot_after(hw, hwe2, j) {
4ae388
-			if (hwe_regmatch(hwe1, hwe2))
4ae388
+			if (conf->hw_strmatch) {
4ae388
+				if (hwe_strmatch(hwe2, hwe1))
4ae388
+					continue;
4ae388
+			}
4ae388
+			else if (hwe_regmatch(hwe1, hwe2))
4ae388
 				continue;
4ae388
 			/* dup */
4ae388
 			merge_hwe(hwe2, hwe1);
4ae388
-			if (hwe_strmatch(hwe2, hwe1) == 0) {
4ae388
+			if (conf->hw_strmatch ||
4ae388
+			    hwe_strmatch(hwe2, hwe1) == 0) {
4ae388
 				vector_del_slot(hw, i);
4ae388
 				free_hwe(hwe1);
4ae388
 				n -= 1;
4ae388
@@ -550,6 +555,7 @@ load_config (char * file, struct udev *u
4ae388
 	conf->fast_io_fail = DEFAULT_FAST_IO_FAIL;
4ae388
 	conf->retain_hwhandler = DEFAULT_RETAIN_HWHANDLER;
4ae388
 	conf->detect_prio = DEFAULT_DETECT_PRIO;
4ae388
+	conf->hw_strmatch = 0;
4ae388
 
4ae388
 	/*
4ae388
 	 * preload default hwtable
4ae388
Index: multipath-tools-130222/libmultipath/config.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/config.h
4ae388
+++ multipath-tools-130222/libmultipath/config.h
4ae388
@@ -107,6 +107,7 @@ struct config {
4ae388
 	int log_checker_err;
4ae388
 	int allow_queueing;
4ae388
 	int find_multipaths;
4ae388
+	int hw_strmatch;
4ae388
 	uid_t uid;
4ae388
 	gid_t gid;
4ae388
 	mode_t mode;
4ae388
Index: multipath-tools-130222/libmultipath/dict.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/dict.c
4ae388
+++ multipath-tools-130222/libmultipath/dict.c
4ae388
@@ -693,6 +693,25 @@ def_detect_prio_handler(vector strvec)
4ae388
 	return 0;
4ae388
 }
4ae388
 
4ae388
+static int
4ae388
+def_hw_strmatch_handler(vector strvec)
4ae388
+{
4ae388
+	char *buff;
4ae388
+
4ae388
+	buff = set_value(strvec);
4ae388
+	if (!buff)
4ae388
+		return 1;
4ae388
+
4ae388
+	if (!strncmp(buff, "on", 2) || !strncmp(buff, "yes", 3) ||
4ae388
+	    !strncmp(buff, "1", 1))
4ae388
+		conf->hw_strmatch = 1;
4ae388
+	else
4ae388
+		conf->hw_strmatch = 0;
4ae388
+
4ae388
+	FREE(buff);
4ae388
+	return 0;
4ae388
+}
4ae388
+
4ae388
 /*
4ae388
  * blacklist block handlers
4ae388
  */
4ae388
@@ -2795,6 +2814,14 @@ snprint_def_detect_prio(char * buff, int
4ae388
 }
4ae388
 
4ae388
 static int
4ae388
+snprint_def_hw_strmatch(char * buff, int len, void * data)
4ae388
+{
4ae388
+	if (conf->hw_strmatch)
4ae388
+		return snprintf(buff, len, "yes");
4ae388
+	return snprintf(buff, len, "no");
4ae388
+}
4ae388
+
4ae388
+static int
4ae388
 snprint_ble_simple (char * buff, int len, void * data)
4ae388
 {
4ae388
 	struct blentry * ble = (struct blentry *)data;
4ae388
@@ -2861,6 +2888,7 @@ init_keywords(void)
4ae388
 	install_keyword("find_multipaths", &def_find_multipaths_handler, &snprint_def_find_multipaths);
4ae388
 	install_keyword("retain_attached_hw_handler", &def_retain_hwhandler_handler, &snprint_def_retain_hwhandler_handler);
4ae388
 	install_keyword("detect_prio", &def_detect_prio_handler, &snprint_def_detect_prio);
4ae388
+	install_keyword("hw_str_match", &def_hw_strmatch_handler, &snprint_def_hw_strmatch);
4ae388
 	__deprecated install_keyword("default_selector", &def_selector_handler, NULL);
4ae388
 	__deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
4ae388
 	__deprecated install_keyword("default_uid_attribute", &def_uid_attribute_handler, NULL);
4ae388
Index: multipath-tools-130222/multipath/multipath.conf.5
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipath/multipath.conf.5
4ae388
+++ multipath-tools-130222/multipath/multipath.conf.5
4ae388
@@ -400,6 +400,17 @@ will automatically use the
4ae388
 .I alua
4ae388
 prioritizer. If not, the prioritizer will be selected as usual. Default is
4ae388
 .I no
4ae388
+.TP
4ae388
+.B hw_str_match
4ae388
+If set to
4ae388
+.I yes
4ae388
+, the vendor, product, and revision parameters of user device configs will be
4ae388
+string matched against the built-in device configs to determine if they should
4ae388
+modify an existing config, or create a new one. If set to
4ae388
+.I no
4ae388
+, the user device configs will be regular expression matched against the
4ae388
+built-in configs instead. Default is
4ae388
+.I no
4ae388
 .
4ae388
 .SH "blacklist section"
4ae388
 The