Blame SOURCES/0046-multipath-return-failure-on-an-invalid-remove-comman.patch

ca7c20
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
ca7c20
From: Benjamin Marzinski <bmarzins@redhat.com>
ca7c20
Date: Wed, 30 Mar 2022 15:14:56 -0500
ca7c20
Subject: [PATCH] multipath: return failure on an invalid remove command
ca7c20
ca7c20
When "multipath -f" is run on a device that doesn't exist or isn't a
ca7c20
multipath device, the command will not remove any device, but it will
ca7c20
still return success.  Multiple functions rely on _dm_flush_map()
ca7c20
returning success when called with name that doesn't match any
ca7c20
multipath device. So before calling _dm_flush_map(), call dm_is_mpath(),
ca7c20
to check if the device exists and is a multipath device, and return
ca7c20
failure if it's not.
ca7c20
ca7c20
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
ca7c20
Reviewed-by: Martin Wilck 
ca7c20
---
ca7c20
 multipath/main.c | 5 +++++
ca7c20
 1 file changed, 5 insertions(+)
ca7c20
ca7c20
diff --git a/multipath/main.c b/multipath/main.c
ca7c20
index 80fa68e5..41d01c7e 100644
ca7c20
--- a/multipath/main.c
ca7c20
+++ b/multipath/main.c
ca7c20
@@ -1111,6 +1111,11 @@ main (int argc, char *argv[])
ca7c20
 	if (retries < 0)
ca7c20
 		retries = conf->remove_retries;
ca7c20
 	if (cmd == CMD_FLUSH_ONE) {
ca7c20
+		if (dm_is_mpath(dev) != 1) {
ca7c20
+			condlog(0, "%s is not a multipath device", dev);
ca7c20
+			r = RTVL_FAIL;
ca7c20
+			goto out;
ca7c20
+		}
ca7c20
 		r = dm_suspend_and_flush_map(dev, retries) ?
ca7c20
 		    RTVL_FAIL : RTVL_OK;
ca7c20
 		goto out;