device-mapper-multipath/0025-libmpathcmd-try-both-abstract-and-pathname-sockets.patch
Benjamin Marzinski 5b86fc9dcf device-mapper-multipath-0.9.9-7
Add 0018-multipath-tools-move-DEFAULT_SOCKET-definition-into-.patch
Add 0019-multipath-tools-add-helper-mpath_fill_sockaddr__.patch
Add 0020-libmpathutil-add-support-for-Unix-pathname-sockets.patch
Add 0021-libmpathutil-move-systemd_listen_fds-support-into-mu.patch
Add 0022-multipathd-make-uxsock_listen-take-a-pointer-to-fd.patch
Add 0023-multipathd-allow-receiving-two-socket-fds-from-syste.patch
Add 0024-multipathd-listen-on-pathname-and-abstract-socket-by.patch
Add 0025-libmpathcmd-try-both-abstract-and-pathname-sockets.patch
Add 0026-libmpathcmd-honor-MULTIPATH_SOCKET_NAME-environment-.patch
Add 0027-multipathd-honor-MULTIPATH_SOCKET_NAME-environment-v.patch
Add 0028-multipath-clean-up-find_multipaths-documentation.patch
Add 0029-multipathd-Add-multipathd-man-page-section-about-soc.patch
  * Fixes RHEL-82180 ("RFE: Enable multipathd to communicate with a
    process in another network namespace")
Resolves: RHEL-82180
2025-03-11 16:40:30 -04:00

53 lines
1.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Wed, 12 Feb 2025 20:45:11 +0100
Subject: [PATCH] libmpathcmd: try both abstract and pathname sockets
When connecting to the multipathd socket, try the pathname socket
first, then the abstract socket. Fail only if both connection attempts
fail.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmpathcmd/mpath_cmd.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/libmpathcmd/mpath_cmd.c b/libmpathcmd/mpath_cmd.c
index 54143fb1..267e3dd7 100644
--- a/libmpathcmd/mpath_cmd.c
+++ b/libmpathcmd/mpath_cmd.c
@@ -102,7 +102,10 @@ int __mpath_connect(int nonblocking)
size_t len;
struct sockaddr_un addr;
int flags = 0;
+ const char *const names[2] = {PATHNAME_SOCKET, ABSTRACT_SOCKET};
+ int name_idx = 0;
+retry:
fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (fd == -1)
return -1;
@@ -113,13 +116,17 @@ int __mpath_connect(int nonblocking)
(void)fcntl(fd, F_SETFL, flags|O_NONBLOCK);
}
- len = mpath_fill_sockaddr__(&addr, ABSTRACT_SOCKET);
+ len = mpath_fill_sockaddr__(&addr, names[name_idx]);
if (connect(fd, (struct sockaddr *)&addr, len) == -1) {
int err = errno;
close(fd);
- errno = err;
- return -1;
+ if (++name_idx == 1)
+ goto retry;
+ else {
+ errno = err;
+ return -1;
+ }
}
if (nonblocking && flags != -1)