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
This commit is contained in:
parent
743bc74362
commit
5b86fc9dcf
@ -0,0 +1,65 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Wilck <mwilck@suse.com>
|
||||
Date: Tue, 11 Feb 2025 16:51:59 +0100
|
||||
Subject: [PATCH] multipath-tools: move DEFAULT_SOCKET definition into
|
||||
Makefile.inc
|
||||
|
||||
This enables configuring the socket name. Follow up patches will
|
||||
add more flexibility for configuring the sockets.
|
||||
|
||||
Signed-off-by: Martin Wilck <mwilck@suse.com>
|
||||
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
---
|
||||
Makefile.inc | 5 ++++-
|
||||
libmpathcmd/mpath_cmd.h | 1 -
|
||||
libmultipath/defaults.h | 1 -
|
||||
3 files changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/Makefile.inc b/Makefile.inc
|
||||
index a3ed9f28..80de8ecb 100644
|
||||
--- a/Makefile.inc
|
||||
+++ b/Makefile.inc
|
||||
@@ -75,6 +75,8 @@ devmapper_incdir := $(or $(shell $(PKG_CONFIG) --variable=includedir devmapper),
|
||||
libudev_incdir := $(or $(shell $(PKG_CONFIG) --variable=includedir libudev),/usr/include)
|
||||
kernel_incdir := /usr/include
|
||||
|
||||
+abstract_socket := /org/kernel/linux/storage/multipathd
|
||||
+
|
||||
ifeq ($(V),)
|
||||
Q := @
|
||||
# make's "Entering directory" messages are confusing in parallel mode
|
||||
@@ -116,7 +118,8 @@ CPPFLAGS := $(CPPFLAGS) $(D_URCU_VERSION) \
|
||||
-DBIN_DIR=\"$(bindir)\" -DMULTIPATH_DIR=\"$(TGTDIR)$(plugindir)\" \
|
||||
-DRUNTIME_DIR=\"$(runtimedir)\" -DCONFIG_DIR=\"$(TGTDIR)$(configdir)\" \
|
||||
-DDEFAULT_CONFIGFILE=\"$(TGTDIR)$(configfile)\" -DSTATE_DIR=\"$(TGTDIR)$(statedir)\" \
|
||||
- -DEXTRAVERSION=\"$(EXTRAVERSION)\" -MMD -MP
|
||||
+ -DEXTRAVERSION=\"$(EXTRAVERSION)\" \
|
||||
+ -DDEFAULT_SOCKET=\"$(abstract_socket)\" -MMD -MP
|
||||
CFLAGS := -std=gnu99 $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe
|
||||
BIN_CFLAGS := -fPIE -DPIE
|
||||
LIB_CFLAGS := -fPIC
|
||||
diff --git a/libmpathcmd/mpath_cmd.h b/libmpathcmd/mpath_cmd.h
|
||||
index 0c293c71..5ab5a6e5 100644
|
||||
--- a/libmpathcmd/mpath_cmd.h
|
||||
+++ b/libmpathcmd/mpath_cmd.h
|
||||
@@ -30,7 +30,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
-#define DEFAULT_SOCKET "/org/kernel/linux/storage/multipathd"
|
||||
#define DEFAULT_REPLY_TIMEOUT 4000
|
||||
|
||||
|
||||
diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h
|
||||
index 4b033ff9..3602636c 100644
|
||||
--- a/libmultipath/defaults.h
|
||||
+++ b/libmultipath/defaults.h
|
||||
@@ -66,7 +66,6 @@
|
||||
#define DEV_LOSS_TMO_UNSET 0U
|
||||
#define MAX_DEV_LOSS_TMO UINT_MAX
|
||||
#define DEFAULT_PIDFILE RUNTIME_DIR "/multipathd.pid"
|
||||
-#define DEFAULT_SOCKET "/org/kernel/linux/storage/multipathd"
|
||||
#define DEFAULT_BINDINGS_FILE STATE_DIR "/bindings"
|
||||
#define DEFAULT_WWIDS_FILE STATE_DIR "/wwids"
|
||||
#define DEFAULT_PRKEYS_FILE STATE_DIR "/prkeys"
|
243
0019-multipath-tools-add-helper-mpath_fill_sockaddr__.patch
Normal file
243
0019-multipath-tools-add-helper-mpath_fill_sockaddr__.patch
Normal file
@ -0,0 +1,243 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Wilck <mwilck@suse.com>
|
||||
Date: Fri, 14 Feb 2025 21:57:02 +0100
|
||||
Subject: [PATCH] multipath-tools: add helper mpath_fill_sockaddr__()
|
||||
|
||||
Create a static new helper function which is used by both libmpathcmd
|
||||
and libmpathutil and fills in the socket address name from the compile-time
|
||||
default. The function is able to handle both abstract and pathname sockets,
|
||||
but more changes are needed to make the latter actually work.
|
||||
|
||||
Signed-off-by: Martin Wilck <mwilck@suse.com>
|
||||
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
---
|
||||
.gitignore | 1 +
|
||||
Makefile.inc | 8 +++--
|
||||
create-config.mk | 1 +
|
||||
libmpathcmd/mpath_cmd.c | 11 ++-----
|
||||
libmpathcmd/mpath_fill_sockaddr.c | 32 +++++++++++++++++++
|
||||
libmpathutil/uxsock.c | 15 ++++-----
|
||||
multipathd/Makefile | 4 +--
|
||||
...multipathd.socket => multipathd.socket.in} | 2 +-
|
||||
8 files changed, 51 insertions(+), 23 deletions(-)
|
||||
create mode 100644 libmpathcmd/mpath_fill_sockaddr.c
|
||||
rename multipathd/{multipathd.socket => multipathd.socket.in} (88%)
|
||||
|
||||
diff --git a/.gitignore b/.gitignore
|
||||
index 049ffe88..87446d9f 100644
|
||||
--- a/.gitignore
|
||||
+++ b/.gitignore
|
||||
@@ -22,6 +22,7 @@ multipathd/multipathd
|
||||
multipathd/multipathd.8
|
||||
multipathd/multipathc
|
||||
multipathd/multipathd.service
|
||||
+multipathd/multipathd.socket
|
||||
mpathpersist/mpathpersist
|
||||
mpathpersist/mpathpersist.8
|
||||
abi.tar.gz
|
||||
diff --git a/Makefile.inc b/Makefile.inc
|
||||
index 80de8ecb..1ef3f7f8 100644
|
||||
--- a/Makefile.inc
|
||||
+++ b/Makefile.inc
|
||||
@@ -75,7 +75,7 @@ devmapper_incdir := $(or $(shell $(PKG_CONFIG) --variable=includedir devmapper),
|
||||
libudev_incdir := $(or $(shell $(PKG_CONFIG) --variable=includedir libudev),/usr/include)
|
||||
kernel_incdir := /usr/include
|
||||
|
||||
-abstract_socket := /org/kernel/linux/storage/multipathd
|
||||
+abstract_socket := @/org/kernel/linux/storage/multipathd
|
||||
|
||||
ifeq ($(V),)
|
||||
Q := @
|
||||
@@ -119,7 +119,9 @@ CPPFLAGS := $(CPPFLAGS) $(D_URCU_VERSION) \
|
||||
-DRUNTIME_DIR=\"$(runtimedir)\" -DCONFIG_DIR=\"$(TGTDIR)$(configdir)\" \
|
||||
-DDEFAULT_CONFIGFILE=\"$(TGTDIR)$(configfile)\" -DSTATE_DIR=\"$(TGTDIR)$(statedir)\" \
|
||||
-DEXTRAVERSION=\"$(EXTRAVERSION)\" \
|
||||
- -DDEFAULT_SOCKET=\"$(abstract_socket)\" -MMD -MP
|
||||
+ -DDEFAULT_SOCKET=\"$(abstract_socket)\" \
|
||||
+ -DWSTRINGOP_TRUNCATION=$(if $(WSTRINGOP_TRUNCATION),1,0) \
|
||||
+ -MMD -MP
|
||||
CFLAGS := -std=gnu99 $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe
|
||||
BIN_CFLAGS := -fPIE -DPIE
|
||||
LIB_CFLAGS := -fPIC
|
||||
@@ -164,4 +166,4 @@ NV_VERSION_SCRIPT = $(DEVLIB:%.so=%-nv.version)
|
||||
|
||||
%: %.in
|
||||
@echo creating $@
|
||||
- $(Q)sed 's:@CONFIGFILE@:'$(TGTDIR)$(configfile)':g;s:@CONFIGDIR@:'$(TGTDIR)$(configdir)':g;s:@STATE_DIR@:'$(TGTDIR)$(statedir)':g;s:@RUNTIME_DIR@:'$(runtimedir)':g;s/@MODPROBE_UNIT@/'$(MODPROBE_UNIT)'/g;s:@BINDIR@:'$(bindir)':g' $< >$@
|
||||
+ $(Q)sed 's:@CONFIGFILE@:'$(TGTDIR)$(configfile)':g;s:@CONFIGDIR@:'$(TGTDIR)$(configdir)':g;s:@STATE_DIR@:'$(TGTDIR)$(statedir)':g;s:@RUNTIME_DIR@:'$(runtimedir)':g;s/@MODPROBE_UNIT@/'$(MODPROBE_UNIT)'/g;s:@BINDIR@:'$(bindir)':g;s,@MPATH_SOCKET@,'$(abstract_socket)',g' $< >$@
|
||||
diff --git a/create-config.mk b/create-config.mk
|
||||
index 4d318b96..5cdff69a 100644
|
||||
--- a/create-config.mk
|
||||
+++ b/create-config.mk
|
||||
@@ -179,6 +179,7 @@ $(TOPDIR)/config.mk: $(multipathdir)/autoconfig.h
|
||||
@echo "ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,)" >>$@
|
||||
@echo "WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered -Wno-error=clobbered,)" >>$@
|
||||
@echo "WFORMATOVERFLOW := $(call TEST_CC_OPTION,-Wformat-overflow=2,)" >>$@
|
||||
+ @echo "WSTRINGOP_TRUNCATION := $(call TEST_CC_OPTION,-Wstringop-truncation)" >>$@
|
||||
@echo "W_MISSING_INITIALIZERS := $(call TEST_MISSING_INITIALIZERS)" >>$@
|
||||
@echo "W_URCU_TYPE_LIMITS := $(call TEST_URCU_TYPE_LIMITS)" >>$@
|
||||
@echo "ENABLE_LIBDMMP := $(ENABLE_LIBDMMP)" >>$@
|
||||
diff --git a/libmpathcmd/mpath_cmd.c b/libmpathcmd/mpath_cmd.c
|
||||
index 60b2d965..146e790d 100644
|
||||
--- a/libmpathcmd/mpath_cmd.c
|
||||
+++ b/libmpathcmd/mpath_cmd.c
|
||||
@@ -24,11 +24,13 @@
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <poll.h>
|
||||
+#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "mpath_cmd.h"
|
||||
+#include "mpath_fill_sockaddr.c"
|
||||
|
||||
/*
|
||||
* keep reading until its all read
|
||||
@@ -101,14 +103,6 @@ int __mpath_connect(int nonblocking)
|
||||
struct sockaddr_un addr;
|
||||
int flags = 0;
|
||||
|
||||
- memset(&addr, 0, sizeof(addr));
|
||||
- addr.sun_family = AF_LOCAL;
|
||||
- addr.sun_path[0] = '\0';
|
||||
- strncpy(&addr.sun_path[1], DEFAULT_SOCKET, sizeof(addr.sun_path) - 1);
|
||||
- len = strlen(DEFAULT_SOCKET) + 1 + sizeof(sa_family_t);
|
||||
- if (len > sizeof(struct sockaddr_un))
|
||||
- len = sizeof(struct sockaddr_un);
|
||||
-
|
||||
fd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
@@ -119,6 +113,7 @@ int __mpath_connect(int nonblocking)
|
||||
(void)fcntl(fd, F_SETFL, flags|O_NONBLOCK);
|
||||
}
|
||||
|
||||
+ len = mpath_fill_sockaddr__(&addr, DEFAULT_SOCKET);
|
||||
if (connect(fd, (struct sockaddr *)&addr, len) == -1) {
|
||||
int err = errno;
|
||||
|
||||
diff --git a/libmpathcmd/mpath_fill_sockaddr.c b/libmpathcmd/mpath_fill_sockaddr.c
|
||||
new file mode 100644
|
||||
index 00000000..750ef3ee
|
||||
--- /dev/null
|
||||
+++ b/libmpathcmd/mpath_fill_sockaddr.c
|
||||
@@ -0,0 +1,32 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2025 SUSE LLC
|
||||
+ * SPDX-license-identifier: LGPL-2.1-or-newer
|
||||
+ */
|
||||
+
|
||||
+static size_t mpath_fill_sockaddr__(struct sockaddr_un *addr, const char *name)
|
||||
+{
|
||||
+ size_t len;
|
||||
+
|
||||
+ addr->sun_family = AF_LOCAL;
|
||||
+
|
||||
+ if (name[0] != '@') {
|
||||
+ /* Pathname socket. This should be NULL-terminated. */
|
||||
+ strncpy(&addr->sun_path[0], name, sizeof(addr->sun_path) - 1);
|
||||
+ addr->sun_path[sizeof(addr->sun_path) - 1] = '\0';
|
||||
+ len = offsetof(struct sockaddr_un, sun_path) + strlen(name) + 1;
|
||||
+ } else {
|
||||
+ addr->sun_path[0] = '\0';
|
||||
+ /*
|
||||
+ * The abstract socket's name doesn't need to be NULL terminated.
|
||||
+ * Actually, a trailing NULL would be considered part of the socket name.
|
||||
+ */
|
||||
+#pragma GCC diagnostic push
|
||||
+#if WSTRINGOP_TRUNCATION
|
||||
+#pragma GCC diagnostic ignored "-Wstringop-truncation"
|
||||
+#endif
|
||||
+ strncpy(&addr->sun_path[1], &name[1], sizeof(addr->sun_path) - 1);
|
||||
+#pragma GCC diagnostic pop
|
||||
+ len = offsetof(struct sockaddr_un, sun_path) + strlen(name);
|
||||
+ }
|
||||
+ return len > sizeof(*addr) ? sizeof(*addr) : len;
|
||||
+}
|
||||
diff --git a/libmpathutil/uxsock.c b/libmpathutil/uxsock.c
|
||||
index 2135476d..12c46084 100644
|
||||
--- a/libmpathutil/uxsock.c
|
||||
+++ b/libmpathutil/uxsock.c
|
||||
@@ -6,12 +6,15 @@
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
+#include <stddef.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
+#include <sys/stat.h>
|
||||
#include <sys/un.h>
|
||||
#include <poll.h>
|
||||
#include <signal.h>
|
||||
@@ -33,6 +36,8 @@
|
||||
static int _recv_packet(int fd, char **buf, unsigned int timeout,
|
||||
ssize_t limit);
|
||||
|
||||
+#include "../libmpathcmd/mpath_fill_sockaddr.c"
|
||||
+
|
||||
/*
|
||||
* create a unix domain socket and start listening on it
|
||||
* return a file descriptor open on the socket
|
||||
@@ -63,15 +68,7 @@ int ux_socket_listen(const char *name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
- memset(&addr, 0, sizeof(addr));
|
||||
- addr.sun_family = AF_LOCAL;
|
||||
- addr.sun_path[0] = '\0';
|
||||
- len = strlen(name) + 1;
|
||||
- if (len >= sizeof(addr.sun_path))
|
||||
- len = sizeof(addr.sun_path) - 1;
|
||||
- memcpy(&addr.sun_path[1], name, len);
|
||||
-
|
||||
- len += sizeof(sa_family_t);
|
||||
+ len = mpath_fill_sockaddr__(&addr, name);
|
||||
if (bind(fd, (struct sockaddr *)&addr, len) == -1) {
|
||||
condlog(3, "Couldn't bind to ux_socket, error %d", errno);
|
||||
close(fd);
|
||||
diff --git a/multipathd/Makefile b/multipathd/Makefile
|
||||
index 997b40cf..61cf1af6 100644
|
||||
--- a/multipathd/Makefile
|
||||
+++ b/multipathd/Makefile
|
||||
@@ -41,7 +41,7 @@ ifeq ($(FPIN_SUPPORT),1)
|
||||
OBJS += fpin_handlers.o
|
||||
endif
|
||||
|
||||
-all : $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service
|
||||
+all : $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service $(EXEC).socket
|
||||
|
||||
$(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so
|
||||
@echo building $@ because of $?
|
||||
@@ -78,7 +78,7 @@ uninstall:
|
||||
$(Q)$(RM) $(DESTDIR)$(unitdir)/$(EXEC).socket
|
||||
|
||||
clean: dep_clean
|
||||
- $(Q)$(RM) core *.o $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service
|
||||
+ $(Q)$(RM) core *.o $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service $(EXEC).socket
|
||||
|
||||
include $(wildcard $(OBJS:.o=.d) $(CLI_OBJS:.o=.d))
|
||||
|
||||
diff --git a/multipathd/multipathd.socket b/multipathd/multipathd.socket.in
|
||||
similarity index 88%
|
||||
rename from multipathd/multipathd.socket
|
||||
rename to multipathd/multipathd.socket.in
|
||||
index 263b6b0c..4ed9c1ff 100644
|
||||
--- a/multipathd/multipathd.socket
|
||||
+++ b/multipathd/multipathd.socket.in
|
||||
@@ -8,7 +8,7 @@ ConditionVirtualization=!container
|
||||
Before=sockets.target
|
||||
|
||||
[Socket]
|
||||
-ListenStream=@/org/kernel/linux/storage/multipathd
|
||||
+ListenStream=@MPATH_SOCKET@
|
||||
|
||||
[Install]
|
||||
# Socket activation for multipathd is disabled by default.
|
@ -0,0 +1,49 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Wilck <mwilck@suse.com>
|
||||
Date: Fri, 14 Feb 2025 22:00:24 +0100
|
||||
Subject: [PATCH] libmpathutil: add support for Unix pathname sockets
|
||||
|
||||
Pathname sockets need to be world read/writable in order to allow regular
|
||||
users to read information from multipathd. Our SO_PEERCRED permission check
|
||||
will make sure that they can't make configuration changes. Also, SO_REUSEADDR
|
||||
doesn't work for pathname sockets as it does for abstract Unix sockets. A
|
||||
possibly pre-existing socket file must be removed before trying to recreate it.
|
||||
|
||||
Signed-off-by: Martin Wilck <mwilck@suse.com>
|
||||
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
---
|
||||
libmpathutil/uxsock.c | 13 +++++++++++++
|
||||
1 file changed, 13 insertions(+)
|
||||
|
||||
diff --git a/libmpathutil/uxsock.c b/libmpathutil/uxsock.c
|
||||
index 12c46084..889d7a17 100644
|
||||
--- a/libmpathutil/uxsock.c
|
||||
+++ b/libmpathutil/uxsock.c
|
||||
@@ -62,6 +62,11 @@ int ux_socket_listen(const char *name)
|
||||
return fd;
|
||||
}
|
||||
#endif
|
||||
+
|
||||
+ /* This is after the PID check, so unlinking should be fine */
|
||||
+ if (name[0] != '@' && unlink(name) == -1 && errno != ENOENT)
|
||||
+ condlog(1, "Failed to unlink %s", name);
|
||||
+
|
||||
fd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
||||
if (fd == -1) {
|
||||
condlog(3, "Couldn't create ux_socket, error %d", errno);
|
||||
@@ -75,6 +80,14 @@ int ux_socket_listen(const char *name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ /*
|
||||
+ * Socket needs to have rw permissions for everone.
|
||||
+ * SO_PEERCRED makes sure that only root can modify things.
|
||||
+ */
|
||||
+ if (name[0] != '@' &&
|
||||
+ chmod(name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) == -1)
|
||||
+ condlog(3, "failed to set permissions on %s: %s", name, strerror(errno));
|
||||
+
|
||||
if (listen(fd, 10) == -1) {
|
||||
condlog(3, "Couldn't listen to ux_socket, error %d", errno);
|
||||
close(fd);
|
@ -0,0 +1,91 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Wilck <mwilck@suse.com>
|
||||
Date: Wed, 12 Feb 2025 19:12:35 +0100
|
||||
Subject: [PATCH] libmpathutil: move systemd_listen_fds() support into
|
||||
multipathd
|
||||
|
||||
This feature is only used by multipathd.
|
||||
|
||||
Signed-off-by: Martin Wilck <mwilck@suse.com>
|
||||
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
---
|
||||
libmpathutil/uxsock.c | 15 ---------------
|
||||
multipathd/main.c | 28 +++++++++++++++++++++++++++-
|
||||
2 files changed, 27 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/libmpathutil/uxsock.c b/libmpathutil/uxsock.c
|
||||
index 889d7a17..59c47170 100644
|
||||
--- a/libmpathutil/uxsock.c
|
||||
+++ b/libmpathutil/uxsock.c
|
||||
@@ -46,23 +46,8 @@ int ux_socket_listen(const char *name)
|
||||
{
|
||||
int fd;
|
||||
size_t len;
|
||||
-#ifdef USE_SYSTEMD
|
||||
- int num;
|
||||
-#endif
|
||||
struct sockaddr_un addr;
|
||||
|
||||
-#ifdef USE_SYSTEMD
|
||||
- num = sd_listen_fds(0);
|
||||
- if (num > 1) {
|
||||
- condlog(3, "sd_listen_fds returned %d fds", num);
|
||||
- return -1;
|
||||
- } else if (num == 1) {
|
||||
- fd = SD_LISTEN_FDS_START + 0;
|
||||
- condlog(3, "using fd %d from sd_listen_fds", fd);
|
||||
- return fd;
|
||||
- }
|
||||
-#endif
|
||||
-
|
||||
/* This is after the PID check, so unlinking should be fine */
|
||||
if (name[0] != '@' && unlink(name) == -1 && errno != ENOENT)
|
||||
condlog(1, "Failed to unlink %s", name);
|
||||
diff --git a/multipathd/main.c b/multipathd/main.c
|
||||
index 58afe14a..24048408 100644
|
||||
--- a/multipathd/main.c
|
||||
+++ b/multipathd/main.c
|
||||
@@ -1859,15 +1859,41 @@ uevqloop (void * ap)
|
||||
pthread_cleanup_pop(1);
|
||||
return NULL;
|
||||
}
|
||||
+
|
||||
+#ifdef USE_SYSTEMD
|
||||
+static int get_systemd_sockets(long *ux_sock)
|
||||
+{
|
||||
+ int num = sd_listen_fds(0);
|
||||
+
|
||||
+ if (num > 1) {
|
||||
+ condlog(3, "sd_listen_fds returned %d fds", num);
|
||||
+ return -1;
|
||||
+ } else if (num == 1) {
|
||||
+ ux_sock[0] = SD_LISTEN_FDS_START + 0;
|
||||
+ condlog(3, "using fd %ld from sd_listen_fds", ux_sock[0]);
|
||||
+ }
|
||||
+ return num;
|
||||
+}
|
||||
+#else
|
||||
+static int get_systemd_sockets(long *ux_sock __attribute__((unused)))
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
static void *
|
||||
uxlsnrloop (void * ap)
|
||||
{
|
||||
long ux_sock;
|
||||
+ int num;
|
||||
|
||||
pthread_cleanup_push(rcu_unregister, NULL);
|
||||
rcu_register_thread();
|
||||
|
||||
- ux_sock = ux_socket_listen(DEFAULT_SOCKET);
|
||||
+ num = get_systemd_sockets(&ux_sock);
|
||||
+ if (num < 1)
|
||||
+ ux_sock = ux_socket_listen(DEFAULT_SOCKET);
|
||||
if (ux_sock == -1) {
|
||||
condlog(1, "could not create uxsock: %d", errno);
|
||||
exit_daemon();
|
@ -0,0 +1,85 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Wilck <mwilck@suse.com>
|
||||
Date: Wed, 12 Feb 2025 20:08:28 +0100
|
||||
Subject: [PATCH] multipathd: make uxsock_listen() take a pointer to fd
|
||||
|
||||
This prepares being able to pass multiple socket fds.
|
||||
|
||||
Signed-off-by: Martin Wilck <mwilck@suse.com>
|
||||
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
---
|
||||
multipathd/main.c | 2 +-
|
||||
multipathd/uxlsnr.c | 11 ++++++++---
|
||||
multipathd/uxlsnr.h | 3 +--
|
||||
3 files changed, 10 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/multipathd/main.c b/multipathd/main.c
|
||||
index 24048408..9f15d2f7 100644
|
||||
--- a/multipathd/main.c
|
||||
+++ b/multipathd/main.c
|
||||
@@ -1920,7 +1920,7 @@ uxlsnrloop (void * ap)
|
||||
== DAEMON_CONFIGURE)
|
||||
handle_signals(false);
|
||||
|
||||
- uxsock_listen(ux_sock, ap);
|
||||
+ uxsock_listen(1, &ux_sock, ap);
|
||||
|
||||
out_sock:
|
||||
pthread_cleanup_pop(1); /* uxsock_cleanup */
|
||||
diff --git a/multipathd/uxlsnr.c b/multipathd/uxlsnr.c
|
||||
index 185e0a0a..51b5e51d 100644
|
||||
--- a/multipathd/uxlsnr.c
|
||||
+++ b/multipathd/uxlsnr.c
|
||||
@@ -614,7 +614,7 @@ static void handle_client(struct client *c, struct vectors *vecs, short revents)
|
||||
/*
|
||||
* entry point
|
||||
*/
|
||||
-void *uxsock_listen(long ux_sock, void *trigger_data)
|
||||
+void *uxsock_listen(int n_socks, long *ux_sock, void *trigger_data)
|
||||
{
|
||||
sigset_t mask;
|
||||
int max_pfds = MIN_POLLS + POLLFDS_BASE;
|
||||
@@ -623,6 +623,11 @@ void *uxsock_listen(long ux_sock, void *trigger_data)
|
||||
struct watch_descriptors wds = { .conf_wd = -1, .dir_wd = -1, .mp_wd = -1, };
|
||||
struct vectors *vecs = trigger_data;
|
||||
|
||||
+ if (n_socks != 1) {
|
||||
+ condlog(0, "uxsock: no socket fds");
|
||||
+ exit_daemon();
|
||||
+ return NULL;
|
||||
+ }
|
||||
condlog(3, "uxsock: startup listener");
|
||||
polls = calloc(1, max_pfds * sizeof(*polls));
|
||||
if (!polls) {
|
||||
@@ -673,7 +678,7 @@ void *uxsock_listen(long ux_sock, void *trigger_data)
|
||||
}
|
||||
}
|
||||
if (num_clients < MAX_CLIENTS) {
|
||||
- polls[POLLFD_UX].fd = ux_sock;
|
||||
+ polls[POLLFD_UX].fd = ux_sock[0];
|
||||
polls[POLLFD_UX].events = POLLIN;
|
||||
} else {
|
||||
/*
|
||||
@@ -767,7 +772,7 @@ void *uxsock_listen(long ux_sock, void *trigger_data)
|
||||
|
||||
/* see if we got a new client */
|
||||
if (polls[POLLFD_UX].revents & POLLIN) {
|
||||
- new_client(ux_sock);
|
||||
+ new_client(ux_sock[0]);
|
||||
}
|
||||
|
||||
/* handle inotify events on config files */
|
||||
diff --git a/multipathd/uxlsnr.h b/multipathd/uxlsnr.h
|
||||
index 3e45930b..f07b1f8b 100644
|
||||
--- a/multipathd/uxlsnr.h
|
||||
+++ b/multipathd/uxlsnr.h
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
bool waiting_clients(void);
|
||||
void uxsock_cleanup(void *arg);
|
||||
-void *uxsock_listen(long ux_sock,
|
||||
- void * trigger_data);
|
||||
+void *uxsock_listen(int n_socks, long *ux_sock, void *trigger_data);
|
||||
|
||||
#endif
|
194
0023-multipathd-allow-receiving-two-socket-fds-from-syste.patch
Normal file
194
0023-multipathd-allow-receiving-two-socket-fds-from-syste.patch
Normal file
@ -0,0 +1,194 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Wilck <mwilck@suse.com>
|
||||
Date: Wed, 12 Feb 2025 20:27:18 +0100
|
||||
Subject: [PATCH] multipathd: allow receiving two socket fds from systemd
|
||||
|
||||
Add another ListenStream directive in multipathd.socket for a Unix pathname
|
||||
socket. In multipathd, read both socket fds from systemd, and open both
|
||||
when they are defined.
|
||||
|
||||
Signed-off-by: Martin Wilck <mwilck@suse.com>
|
||||
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
---
|
||||
Makefile.inc | 3 ++-
|
||||
multipathd/main.c | 18 ++++++++++++------
|
||||
multipathd/multipathd.socket.in | 3 ++-
|
||||
multipathd/uxlsnr.c | 33 ++++++++++++++++++++++-----------
|
||||
4 files changed, 38 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/Makefile.inc b/Makefile.inc
|
||||
index 1ef3f7f8..07c0ae80 100644
|
||||
--- a/Makefile.inc
|
||||
+++ b/Makefile.inc
|
||||
@@ -76,6 +76,7 @@ libudev_incdir := $(or $(shell $(PKG_CONFIG) --variable=includedir libudev),/usr
|
||||
kernel_incdir := /usr/include
|
||||
|
||||
abstract_socket := @/org/kernel/linux/storage/multipathd
|
||||
+pathname_socket := /run/multipathd.socket
|
||||
|
||||
ifeq ($(V),)
|
||||
Q := @
|
||||
@@ -166,4 +167,4 @@ NV_VERSION_SCRIPT = $(DEVLIB:%.so=%-nv.version)
|
||||
|
||||
%: %.in
|
||||
@echo creating $@
|
||||
- $(Q)sed 's:@CONFIGFILE@:'$(TGTDIR)$(configfile)':g;s:@CONFIGDIR@:'$(TGTDIR)$(configdir)':g;s:@STATE_DIR@:'$(TGTDIR)$(statedir)':g;s:@RUNTIME_DIR@:'$(runtimedir)':g;s/@MODPROBE_UNIT@/'$(MODPROBE_UNIT)'/g;s:@BINDIR@:'$(bindir)':g;s,@MPATH_SOCKET@,'$(abstract_socket)',g' $< >$@
|
||||
+ $(Q)sed 's:@CONFIGFILE@:'$(TGTDIR)$(configfile)':g;s:@CONFIGDIR@:'$(TGTDIR)$(configdir)':g;s:@STATE_DIR@:'$(TGTDIR)$(statedir)':g;s:@RUNTIME_DIR@:'$(runtimedir)':g;s/@MODPROBE_UNIT@/'$(MODPROBE_UNIT)'/g;s:@BINDIR@:'$(bindir)':g;s,@ABSTRACT_SOCKET@,'$(abstract_socket)',g;s,@PATHNAME_SOCKET@,'$(pathname_socket)',g' $< >$@
|
||||
diff --git a/multipathd/main.c b/multipathd/main.c
|
||||
index 9f15d2f7..2fef0c64 100644
|
||||
--- a/multipathd/main.c
|
||||
+++ b/multipathd/main.c
|
||||
@@ -1865,9 +1865,13 @@ static int get_systemd_sockets(long *ux_sock)
|
||||
{
|
||||
int num = sd_listen_fds(0);
|
||||
|
||||
- if (num > 1) {
|
||||
+ if (num > 2) {
|
||||
condlog(3, "sd_listen_fds returned %d fds", num);
|
||||
return -1;
|
||||
+ } else if (num == 2) {
|
||||
+ ux_sock[0] = SD_LISTEN_FDS_START + 0;
|
||||
+ ux_sock[1] = SD_LISTEN_FDS_START + 1;
|
||||
+ condlog(3, "using fd %ld and %ld from sd_listen_fds", ux_sock[0], ux_sock[1]);
|
||||
} else if (num == 1) {
|
||||
ux_sock[0] = SD_LISTEN_FDS_START + 0;
|
||||
condlog(3, "using fd %ld from sd_listen_fds", ux_sock[0]);
|
||||
@@ -1885,16 +1889,18 @@ static int get_systemd_sockets(long *ux_sock __attribute__((unused)))
|
||||
static void *
|
||||
uxlsnrloop (void * ap)
|
||||
{
|
||||
- long ux_sock;
|
||||
+ long ux_sock[2] = {-1, -1};
|
||||
int num;
|
||||
|
||||
pthread_cleanup_push(rcu_unregister, NULL);
|
||||
rcu_register_thread();
|
||||
|
||||
num = get_systemd_sockets(&ux_sock);
|
||||
- if (num < 1)
|
||||
- ux_sock = ux_socket_listen(DEFAULT_SOCKET);
|
||||
- if (ux_sock == -1) {
|
||||
+ if (num < 1) {
|
||||
+ ux_sock[0] = ux_socket_listen(DEFAULT_SOCKET);
|
||||
+ num = 1;
|
||||
+ }
|
||||
+ if (ux_sock[0] == -1) {
|
||||
condlog(1, "could not create uxsock: %d", errno);
|
||||
exit_daemon();
|
||||
goto out;
|
||||
@@ -1920,7 +1926,7 @@ uxlsnrloop (void * ap)
|
||||
== DAEMON_CONFIGURE)
|
||||
handle_signals(false);
|
||||
|
||||
- uxsock_listen(1, &ux_sock, ap);
|
||||
+ uxsock_listen(num, ux_sock, ap);
|
||||
|
||||
out_sock:
|
||||
pthread_cleanup_pop(1); /* uxsock_cleanup */
|
||||
diff --git a/multipathd/multipathd.socket.in b/multipathd/multipathd.socket.in
|
||||
index 4ed9c1ff..5ed24757 100644
|
||||
--- a/multipathd/multipathd.socket.in
|
||||
+++ b/multipathd/multipathd.socket.in
|
||||
@@ -8,7 +8,8 @@ ConditionVirtualization=!container
|
||||
Before=sockets.target
|
||||
|
||||
[Socket]
|
||||
-ListenStream=@MPATH_SOCKET@
|
||||
+ListenStream=@ABSTRACT_SOCKET@
|
||||
+ListenStream=@PATHNAME_SOCKET@
|
||||
|
||||
[Install]
|
||||
# Socket activation for multipathd is disabled by default.
|
||||
diff --git a/multipathd/uxlsnr.c b/multipathd/uxlsnr.c
|
||||
index 51b5e51d..bbf891ba 100644
|
||||
--- a/multipathd/uxlsnr.c
|
||||
+++ b/multipathd/uxlsnr.c
|
||||
@@ -69,7 +69,8 @@ struct client {
|
||||
|
||||
/* Indices for array of poll fds */
|
||||
enum {
|
||||
- POLLFD_UX = 0,
|
||||
+ POLLFD_UX1 = 0,
|
||||
+ POLLFD_UX2,
|
||||
POLLFD_NOTIFY,
|
||||
POLLFD_IDLE,
|
||||
POLLFDS_BASE,
|
||||
@@ -164,9 +165,10 @@ void uxsock_cleanup(void *arg)
|
||||
{
|
||||
struct client *client_loop;
|
||||
struct client *client_tmp;
|
||||
- long ux_sock = (long)arg;
|
||||
+ long *ux_sock = (long *)arg;
|
||||
|
||||
- close(ux_sock);
|
||||
+ close(ux_sock[0]);
|
||||
+ close(ux_sock[1]);
|
||||
close(notify_fd);
|
||||
|
||||
list_for_each_entry_safe(client_loop, client_tmp, &clients, node) {
|
||||
@@ -614,20 +616,24 @@ static void handle_client(struct client *c, struct vectors *vecs, short revents)
|
||||
/*
|
||||
* entry point
|
||||
*/
|
||||
-void *uxsock_listen(int n_socks, long *ux_sock, void *trigger_data)
|
||||
+void *uxsock_listen(int n_socks, long *ux_sock_in, void *trigger_data)
|
||||
{
|
||||
sigset_t mask;
|
||||
int max_pfds = MIN_POLLS + POLLFDS_BASE;
|
||||
+ long ux_sock[2] = {-1, -1};
|
||||
/* conf->sequence_nr will be 1 when uxsock_listen is first called */
|
||||
unsigned int sequence_nr = 0;
|
||||
struct watch_descriptors wds = { .conf_wd = -1, .dir_wd = -1, .mp_wd = -1, };
|
||||
struct vectors *vecs = trigger_data;
|
||||
|
||||
- if (n_socks != 1) {
|
||||
- condlog(0, "uxsock: no socket fds");
|
||||
+ if (n_socks < 1 || n_socks > 2) {
|
||||
+ condlog(0, "uxsock: unsupported number of socket fds");
|
||||
exit_daemon();
|
||||
return NULL;
|
||||
- }
|
||||
+ } else if (n_socks == 2)
|
||||
+ ux_sock[1] = ux_sock_in[1];
|
||||
+ ux_sock[0] = ux_sock_in[0];
|
||||
+
|
||||
condlog(3, "uxsock: startup listener");
|
||||
polls = calloc(1, max_pfds * sizeof(*polls));
|
||||
if (!polls) {
|
||||
@@ -678,8 +684,10 @@ void *uxsock_listen(int n_socks, long *ux_sock, void *trigger_data)
|
||||
}
|
||||
}
|
||||
if (num_clients < MAX_CLIENTS) {
|
||||
- polls[POLLFD_UX].fd = ux_sock[0];
|
||||
- polls[POLLFD_UX].events = POLLIN;
|
||||
+ polls[POLLFD_UX1].fd = ux_sock[0];
|
||||
+ polls[POLLFD_UX1].events = POLLIN;
|
||||
+ polls[POLLFD_UX2].fd = ux_sock[1];
|
||||
+ polls[POLLFD_UX2].events = POLLIN;
|
||||
} else {
|
||||
/*
|
||||
* New clients can't connect, num_clients won't grow
|
||||
@@ -687,7 +695,7 @@ void *uxsock_listen(int n_socks, long *ux_sock, void *trigger_data)
|
||||
*/
|
||||
condlog(1, "%s: max client connections reached, pausing polling",
|
||||
__func__);
|
||||
- polls[POLLFD_UX].fd = -1;
|
||||
+ polls[POLLFD_UX1].fd = polls[POLLFD_UX2].fd = -1;
|
||||
}
|
||||
|
||||
reset_watch(notify_fd, &wds, &sequence_nr);
|
||||
@@ -771,9 +779,12 @@ void *uxsock_listen(int n_socks, long *ux_sock, void *trigger_data)
|
||||
handle_signals(true);
|
||||
|
||||
/* see if we got a new client */
|
||||
- if (polls[POLLFD_UX].revents & POLLIN) {
|
||||
+ if (polls[POLLFD_UX1].revents & POLLIN) {
|
||||
new_client(ux_sock[0]);
|
||||
}
|
||||
+ if (polls[POLLFD_UX2].revents & POLLIN) {
|
||||
+ new_client(ux_sock[1]);
|
||||
+ }
|
||||
|
||||
/* handle inotify events on config files */
|
||||
if (polls[POLLFD_NOTIFY].revents & POLLIN)
|
@ -0,0 +1,67 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Wilck <mwilck@suse.com>
|
||||
Date: Wed, 12 Feb 2025 20:35:36 +0100
|
||||
Subject: [PATCH] multipathd: listen on pathname and abstract socket by default
|
||||
|
||||
Pass both ABSTRACT_SOCKET and PATHNAME_SOCKET to the compiler at
|
||||
build time, and listen on both sockets by default.
|
||||
|
||||
Signed-off-by: Martin Wilck <mwilck@suse.com>
|
||||
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
---
|
||||
Makefile.inc | 2 +-
|
||||
libmpathcmd/mpath_cmd.c | 2 +-
|
||||
multipathd/main.c | 11 ++++++-----
|
||||
3 files changed, 8 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/Makefile.inc b/Makefile.inc
|
||||
index 07c0ae80..69a0d64c 100644
|
||||
--- a/Makefile.inc
|
||||
+++ b/Makefile.inc
|
||||
@@ -120,7 +120,7 @@ CPPFLAGS := $(CPPFLAGS) $(D_URCU_VERSION) \
|
||||
-DRUNTIME_DIR=\"$(runtimedir)\" -DCONFIG_DIR=\"$(TGTDIR)$(configdir)\" \
|
||||
-DDEFAULT_CONFIGFILE=\"$(TGTDIR)$(configfile)\" -DSTATE_DIR=\"$(TGTDIR)$(statedir)\" \
|
||||
-DEXTRAVERSION=\"$(EXTRAVERSION)\" \
|
||||
- -DDEFAULT_SOCKET=\"$(abstract_socket)\" \
|
||||
+ -DABSTRACT_SOCKET=\"$(abstract_socket)\" -DPATHNAME_SOCKET=\"$(pathname_socket)\" \
|
||||
-DWSTRINGOP_TRUNCATION=$(if $(WSTRINGOP_TRUNCATION),1,0) \
|
||||
-MMD -MP
|
||||
CFLAGS := -std=gnu99 $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe
|
||||
diff --git a/libmpathcmd/mpath_cmd.c b/libmpathcmd/mpath_cmd.c
|
||||
index 146e790d..54143fb1 100644
|
||||
--- a/libmpathcmd/mpath_cmd.c
|
||||
+++ b/libmpathcmd/mpath_cmd.c
|
||||
@@ -113,7 +113,7 @@ int __mpath_connect(int nonblocking)
|
||||
(void)fcntl(fd, F_SETFL, flags|O_NONBLOCK);
|
||||
}
|
||||
|
||||
- len = mpath_fill_sockaddr__(&addr, DEFAULT_SOCKET);
|
||||
+ len = mpath_fill_sockaddr__(&addr, ABSTRACT_SOCKET);
|
||||
if (connect(fd, (struct sockaddr *)&addr, len) == -1) {
|
||||
int err = errno;
|
||||
|
||||
diff --git a/multipathd/main.c b/multipathd/main.c
|
||||
index 2fef0c64..bdbcea49 100644
|
||||
--- a/multipathd/main.c
|
||||
+++ b/multipathd/main.c
|
||||
@@ -1895,13 +1895,14 @@ uxlsnrloop (void * ap)
|
||||
pthread_cleanup_push(rcu_unregister, NULL);
|
||||
rcu_register_thread();
|
||||
|
||||
- num = get_systemd_sockets(&ux_sock);
|
||||
+ num = get_systemd_sockets(ux_sock);
|
||||
if (num < 1) {
|
||||
- ux_sock[0] = ux_socket_listen(DEFAULT_SOCKET);
|
||||
- num = 1;
|
||||
+ ux_sock[0] = ux_socket_listen(ABSTRACT_SOCKET);
|
||||
+ ux_sock[1] = ux_socket_listen(PATHNAME_SOCKET);
|
||||
+ num = 2;
|
||||
}
|
||||
- if (ux_sock[0] == -1) {
|
||||
- condlog(1, "could not create uxsock: %d", errno);
|
||||
+ if (ux_sock[0] == -1 && ux_sock[1] == -1) {
|
||||
+ condlog(1, "could not create sockets: %d", errno);
|
||||
exit_daemon();
|
||||
goto out;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
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)
|
@ -0,0 +1,53 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Wilck <mwilck@suse.com>
|
||||
Date: Wed, 12 Feb 2025 21:17:41 +0100
|
||||
Subject: [PATCH] libmpathcmd: honor MULTIPATH_SOCKET_NAME environment variable
|
||||
|
||||
In systemd installments, users can already override the socket names
|
||||
that systemd listens on. With this patch, clients using libmpathcmd
|
||||
can be customized to use a non-standard socket by setting an environment
|
||||
variable.
|
||||
|
||||
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 | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libmpathcmd/mpath_cmd.c b/libmpathcmd/mpath_cmd.c
|
||||
index 267e3dd7..7f805abb 100644
|
||||
--- a/libmpathcmd/mpath_cmd.c
|
||||
+++ b/libmpathcmd/mpath_cmd.c
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
@@ -104,6 +105,7 @@ int __mpath_connect(int nonblocking)
|
||||
int flags = 0;
|
||||
const char *const names[2] = {PATHNAME_SOCKET, ABSTRACT_SOCKET};
|
||||
int name_idx = 0;
|
||||
+ const char *env_name = getenv("MULTIPATH_SOCKET_NAME"), *name;
|
||||
|
||||
retry:
|
||||
fd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
||||
@@ -116,12 +118,13 @@ retry:
|
||||
(void)fcntl(fd, F_SETFL, flags|O_NONBLOCK);
|
||||
}
|
||||
|
||||
- len = mpath_fill_sockaddr__(&addr, names[name_idx]);
|
||||
+ name = env_name ? env_name : names[name_idx];
|
||||
+ len = mpath_fill_sockaddr__(&addr, name);
|
||||
if (connect(fd, (struct sockaddr *)&addr, len) == -1) {
|
||||
int err = errno;
|
||||
|
||||
close(fd);
|
||||
- if (++name_idx == 1)
|
||||
+ if (name != env_name && ++name_idx == 1)
|
||||
goto retry;
|
||||
else {
|
||||
errno = err;
|
@ -0,0 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Wilck <mwilck@suse.com>
|
||||
Date: Fri, 14 Feb 2025 22:18:06 +0100
|
||||
Subject: [PATCH] multipathd: honor MULTIPATH_SOCKET_NAME environment variable
|
||||
|
||||
If multipathd is started via socket activation, it will obtain
|
||||
sockets from systemd. The names of these sockets, and whether
|
||||
the abstract and / or pathname socket is created, is configurable
|
||||
in the systemd unit file.
|
||||
|
||||
Add support for passing a socket name via the environment, so that
|
||||
it's possible to configure the socket name at runtime even without
|
||||
socket activation. In this case, only this single socket will be created.
|
||||
If creating the socket fails, multipathd startup will fail, too.
|
||||
|
||||
Signed-off-by: Martin Wilck <mwilck@suse.com>
|
||||
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
---
|
||||
multipathd/main.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/multipathd/main.c b/multipathd/main.c
|
||||
index bdbcea49..0fa4a404 100644
|
||||
--- a/multipathd/main.c
|
||||
+++ b/multipathd/main.c
|
||||
@@ -1891,11 +1891,16 @@ uxlsnrloop (void * ap)
|
||||
{
|
||||
long ux_sock[2] = {-1, -1};
|
||||
int num;
|
||||
+ const char *env_name = getenv("MULTIPATH_SOCKET_NAME");
|
||||
|
||||
pthread_cleanup_push(rcu_unregister, NULL);
|
||||
rcu_register_thread();
|
||||
|
||||
num = get_systemd_sockets(ux_sock);
|
||||
+ if (num < 1 && env_name != NULL) {
|
||||
+ ux_sock[0] = ux_socket_listen(env_name);
|
||||
+ num = 1;
|
||||
+ }
|
||||
if (num < 1) {
|
||||
ux_sock[0] = ux_socket_listen(ABSTRACT_SOCKET);
|
||||
ux_sock[1] = ux_socket_listen(PATHNAME_SOCKET);
|
25
0028-multipath-clean-up-find_multipaths-documentation.patch
Normal file
25
0028-multipath-clean-up-find_multipaths-documentation.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
Date: Thu, 6 Mar 2025 16:56:34 -0500
|
||||
Subject: [PATCH] multipath: clean up find_multipaths documentation
|
||||
|
||||
The preferred term is "on" instead of "yes".
|
||||
|
||||
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
---
|
||||
multipath/multipath.conf.5.in | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/multipath/multipath.conf.5.in b/multipath/multipath.conf.5.in
|
||||
index a7543939..31740a1f 100644
|
||||
--- a/multipath/multipath.conf.5.in
|
||||
+++ b/multipath/multipath.conf.5.in
|
||||
@@ -1213,7 +1213,7 @@ Both multipathd and multipath treat every non-blacklisted device as multipath
|
||||
device path.
|
||||
.TP
|
||||
.I smart
|
||||
-This differs from \fIfind_multipaths yes\fR only in
|
||||
+This differs from \fIfind_multipaths on\fR only in
|
||||
the way it treats new devices for which only one path has been
|
||||
detected yet. When such a device is first encountered in udev rules, it is
|
||||
treated as a multipath device. multipathd waits whether additional paths with
|
@ -0,0 +1,63 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
Date: Thu, 6 Mar 2025 18:52:02 -0500
|
||||
Subject: [PATCH] multipathd: Add multipathd man page section about sockets
|
||||
|
||||
Add a section with information about how to communicate with the
|
||||
multipathd daemon to the man page. Also mention that multipathd
|
||||
CLI commands can be run without the -k option.
|
||||
|
||||
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||||
---
|
||||
multipathd/multipathd.8.in | 31 +++++++++++++++++++++++++++++++
|
||||
1 file changed, 31 insertions(+)
|
||||
|
||||
diff --git a/multipathd/multipathd.8.in b/multipathd/multipathd.8.in
|
||||
index 315884eb..5b1aeb42 100644
|
||||
--- a/multipathd/multipathd.8.in
|
||||
+++ b/multipathd/multipathd.8.in
|
||||
@@ -83,6 +83,11 @@ multipathd executes the given command (see \fBCOMMANDS\fR below). If the
|
||||
command contains whitespace or shell special characters, it needs to be quoted
|
||||
like in \fImultipathd -k'show topology'\fR. No whitespace is allowed between
|
||||
the \fB-k\fR and the command string.
|
||||
+
|
||||
+Commands can also be issued without using \fB-k\fR. In this case, the command
|
||||
+string should not be quoted. Command arguments that contain whitespace or
|
||||
+special characters still need to be quoted, like in \fImultipathd show paths
|
||||
+format "%n %w"\fR
|
||||
.
|
||||
.TP
|
||||
.B \-k
|
||||
@@ -103,6 +108,32 @@ multipath devices on dmevents. Use this flag to force it to use the old event
|
||||
waiting method, based on creating a separate thread for each device.
|
||||
.
|
||||
.
|
||||
+.\" ----------------------------------------------------------------------------
|
||||
+.SH COMMUNICATING WITH MULTIPATHD
|
||||
+.\" ----------------------------------------------------------------------------
|
||||
+
|
||||
+In addition to the multipathd CLI, the \fBlibmpathcmd\fR library can be used to
|
||||
+send commands (see \fBCOMMANDS\fR below) to the multipathd daemon from other
|
||||
+programs. By default, multipathd listens on both the \fI@ABSTRACT_SOCKET@\fR
|
||||
+abstract namespace socket and the \fI@PATHNAME_SOCKET@\fR socket file.
|
||||
+libmpathcmd will use either of these sockets to connect to multipathd. The
|
||||
+socket file can be useful to communicate with multipathd from different
|
||||
+namespaces since it can be bind mounted in them, unlike the abstract namespace
|
||||
+socket. Multipathd will accept \fBlist|show\fR commands from any user. All
|
||||
+other commands must be issued by root.
|
||||
+
|
||||
+It is possible to change the sockets that multipathd listens on. If
|
||||
+\fImultipathd.socket\fR is running, multipathd will use the sockets it listens
|
||||
+on. A maximum of two sockets can be defined by \fImultipathd.socket\fR, and by
|
||||
+default it listens on \fI@ABSTRACT_SOCKET@\fR and \fI@PATHNAME_SOCKET@\fR. If
|
||||
+\fImultipathd.socket\fR is not running, a single socket can be configured for
|
||||
+listening on by setting the \fIMULTIPATH_SOCKET_NAME\fR environment variable
|
||||
+when starting multipathd. This environment variable must also be set to make
|
||||
+multipathd CLI commands (or any other program using libmpathcmd) connect to the
|
||||
+multipathd daemon using a non-default socket, regardless of whether that socket
|
||||
+was set for the daemon using \fImultipathd.socket\fR or the
|
||||
+\fIMULTIPATH_SOCKET_NAME\fR environment variable.
|
||||
+.
|
||||
.
|
||||
.\" ----------------------------------------------------------------------------
|
||||
.SH COMMANDS
|
@ -1,6 +1,6 @@
|
||||
Name: device-mapper-multipath
|
||||
Version: 0.9.9
|
||||
Release: 6%{?dist}
|
||||
Release: 7%{?dist}
|
||||
Summary: Tools to manage multipath devices using device-mapper
|
||||
License: GPLv2
|
||||
URL: http://christophe.varoqui.free.fr/
|
||||
@ -27,6 +27,18 @@ Patch0014: 0014-RH-Add-mpathcleanup.patch
|
||||
Patch0015: 0015-libmultipath-fix-ontap-prioritizer-snprintf-limits.patch
|
||||
Patch0016: 0016-multipathd-checker-port_state-before-setting-it.patch
|
||||
Patch0017: 0017-libmultipath-foreign-fix-memory-leak-in-nvme-foreign.patch
|
||||
Patch0018: 0018-multipath-tools-move-DEFAULT_SOCKET-definition-into-.patch
|
||||
Patch0019: 0019-multipath-tools-add-helper-mpath_fill_sockaddr__.patch
|
||||
Patch0020: 0020-libmpathutil-add-support-for-Unix-pathname-sockets.patch
|
||||
Patch0021: 0021-libmpathutil-move-systemd_listen_fds-support-into-mu.patch
|
||||
Patch0022: 0022-multipathd-make-uxsock_listen-take-a-pointer-to-fd.patch
|
||||
Patch0023: 0023-multipathd-allow-receiving-two-socket-fds-from-syste.patch
|
||||
Patch0024: 0024-multipathd-listen-on-pathname-and-abstract-socket-by.patch
|
||||
Patch0025: 0025-libmpathcmd-try-both-abstract-and-pathname-sockets.patch
|
||||
Patch0026: 0026-libmpathcmd-honor-MULTIPATH_SOCKET_NAME-environment-.patch
|
||||
Patch0027: 0027-multipathd-honor-MULTIPATH_SOCKET_NAME-environment-v.patch
|
||||
Patch0028: 0028-multipath-clean-up-find_multipaths-documentation.patch
|
||||
Patch0029: 0029-multipathd-Add-multipathd-man-page-section-about-soc.patch
|
||||
|
||||
# runtime
|
||||
Requires: %{name}-libs = %{version}-%{release}
|
||||
@ -236,6 +248,23 @@ fi
|
||||
%{_pkgconfdir}/libdmmp.pc
|
||||
|
||||
%changelog
|
||||
* Thu Mar 6 2025 Benjamin Marzinski <bmarzins@redhat.com> - 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
|
||||
|
||||
* Thu Jan 9 2025 Benjamin Marzinski <bmarzins@redhat.com> - 0.9.9-6
|
||||
- Add 0017-libmultipath-foreign-fix-memory-leak-in-nvme-foreign.patch
|
||||
- Resolves: RHEL-73410
|
||||
|
Loading…
Reference in New Issue
Block a user