multipathd: accept more multipath device names
Benjamin Marzinski
maintainercover multipathd: accept more multipath device names
The multipathd commands with a $map argument will only accept dm-<number> and aliases for $map. Make them accept WWIDs as well. Also, change find_mp_by_str() to not skip devices with aliases of the form dm-<something_that_starts_with_a_number>, which are horrible names, but still valid.
Benjamin Marzinski (2):
libmultipath: accept poorly chosen aliases in find_mp_by_str
libmultipath: accept wwids in find_mp_by_str
libmultipath/structs.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
Signature · 1 line
2.45.0
Benjamin Marzinski
maintainerPATCH 1/2 libmultipath: accept poorly chosen aliases in find_mp_by_str
A multipath device alias of dm-1 is valid, albeit a really bad idea. Make sure that find_mp_by_str() is only checking for multipath devices by minor number for strings that really are of the form dm-<number>, and if the minor-number check fails, check if the string is an alias, just to be safe.
--- libmultipath/structs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
libmultipath/structs.c +4 -3
@@ -480,11 +480,12 @@ struct multipath * find_mp_by_str (const struct _vector *mpvec, const char * str) { int minor; -struct multipath *mpp; +char dummy; +struct multipath *mpp =NULL ; -if (sscanf (str,"dm-%d" , &minor) ==1 ) +if (sscanf (str,"dm-%d%c" , &minor, &dummy) ==1 ) mpp =find_mp_by_minor (mpvec, minor); -else +if (!mpp) mpp =find_mp_by_alias (mpvec, str);if (!mpp)
Signature · 1 line
2.45.0
Benjamin Marzinski
maintainerPATCH 2/2 libmultipath: accept wwids in find_mp_by_str
In reply to Benjamin MarzinskiIf the device string is not an alias, check if it's a wwid. This allows multipathd commands to use WWIDs for $map arguments. In find_mp_by_wwid, only check strings that are small enough to be WWIDs.
--- libmultipath/structs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
libmultipath/structs.c +3 -1
@@ -443,7 +443,7 @@ find_mp_by_wwid (const struct _vector *mpvec, const char * wwid)int i;struct multipath * mpp; -if (!mpvec) +if (!mpvec ||strlen (wwid) >=WWID_SIZE )return NULL ;vector_foreach_slot (mpvec, mpp, i)
@@ -487,6 +487,8 @@ find_mp_by_str (const struct _vector *mpvec, const char * str) mpp =find_mp_by_minor (mpvec, minor);if (!mpp) mpp =find_mp_by_alias (mpvec, str); +if (!mpp) + mpp =find_mp_by_wwid (mpvec, str);if (!mpp)condlog (2 ,"%s: invalid map name." , str);
Signature · 1 line
2.45.0
Quoted 8 lines · Benjamin Marzinski
The multipathd commands with a $map argument will only accept dm-<number> and aliases for $map. Make them accept WWIDs as well. Also,
changefind_mp_by_str()to not skip devices with aliases of the form dm-<something_that_starts_with_a_number>, which are horrible names, but
still valid.
Quoted 7 lines
Benjamin Marzinski (2):
libmultipath: accept poorly chosen aliases infind_mp_by_str
libmultipath: accept wwids infind_mp_by_strlibmultipath/structs.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
For the set: