[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dm-devel
Subject:    [PATCH 2/2] libmultipath: accept wwids in find_mp_by_str
From:       Benjamin Marzinski <bmarzins () redhat ! com>
Date:       2024-05-20 23:38:03
Message-ID: 20240520233803.190793-3-bmarzins () redhat ! com
[Download RAW message or body]

If 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.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/structs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libmultipath/structs.c b/libmultipath/structs.c
index d89f2187..be3125ed 100644
--- a/libmultipath/structs.c
+++ b/libmultipath/structs.c
@@ -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);
-- 
2.45.0


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic