You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.1 KiB

From 2a463c04a75726e811161f435e2f6736d70a66bd Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
Date: Tue, 20 Jun 2017 09:35:23 -0700
Subject: isolate iscsistart socket use
---
usr/iscsid_req.c | 12 +++++++++++-
usr/iscsid_req.h | 3 +++
usr/iscsistart.c | 6 ++++++
usr/mgmt_ipc.c | 3 ++-
usr/mgmt_ipc.h | 1 -
5 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c
index 2950d748c644..69351c6c61ea 100644
--- a/usr/iscsid_req.c
+++ b/usr/iscsid_req.c
@@ -96,9 +96,19 @@ static int ipc_connect(int *fd, char *unix_sock_name, int start_iscsid)
return ISCSI_ERR_ISCSID_NOTCONN;
}
+char iscsid_namespace[64] = ISCSIADM_NAMESPACE;
+
+void iscsid_set_namespace(pid_t pid) {
+ if (pid) {
+ snprintf(iscsid_namespace, 64, ISCSIADM_NAMESPACE "-%d", pid);
+ } else {
+ snprintf(iscsid_namespace, 64, ISCSIADM_NAMESPACE);
+ }
+}
+
static int iscsid_connect(int *fd, int start_iscsid)
{
- return ipc_connect(fd, ISCSIADM_NAMESPACE, start_iscsid);
+ return ipc_connect(fd, iscsid_namespace, start_iscsid);
}
int iscsid_request(int *fd, iscsiadm_req_t *req, int start_iscsid)
diff --git a/usr/iscsid_req.h b/usr/iscsid_req.h
index 8cb4a922f46d..ba7b2357c729 100644
--- a/usr/iscsid_req.h
+++ b/usr/iscsid_req.h
@@ -25,6 +25,9 @@ struct iscsiadm_req;
struct iscsiadm_rsp;
struct node_rec;
+extern char iscsid_namespace[64];
+extern void iscsid_set_namespace(pid_t);
+
extern int iscsid_exec_req(struct iscsiadm_req *req, struct iscsiadm_rsp *rsp,
int iscsid_start);
extern int iscsid_req_wait(int cmd, int fd);
diff --git a/usr/iscsistart.c b/usr/iscsistart.c
index ecb256b3c2f6..538dd2f9d780 100644
--- a/usr/iscsistart.c
+++ b/usr/iscsistart.c
@@ -458,6 +458,10 @@ int main(int argc, char *argv[])
} else if (pid) {
int status, rc, rc2;
+ /* make a special socket path for only this iscsistart instance */
+ iscsid_set_namespace(pid);
+ sleep(1);
+
rc = setup_session();
rc2 = stop_event_loop();
/*
@@ -475,6 +478,9 @@ int main(int argc, char *argv[])
exit(0);
}
+ pid = getpid();
+ iscsid_set_namespace(pid);
+
mgmt_ipc_fd = mgmt_ipc_listen();
if (mgmt_ipc_fd < 0) {
log_error("Could not setup mgmt ipc");
diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c
index c16bce962232..140d358ec5da 100644
--- a/usr/mgmt_ipc.c
+++ b/usr/mgmt_ipc.c
@@ -37,6 +37,7 @@
#include "iscsi_ipc.h"
#include "iscsi_err.h"
#include "iscsi_util.h"
+#include "iscsid_req.h"
#define PEERUSER_MAX 64
#define EXTMSG_MAX (64 * 1024)
@@ -60,7 +61,7 @@ mgmt_ipc_listen(void)
return fd;
}
- addr_len = setup_abstract_addr(&addr, ISCSIADM_NAMESPACE);
+ addr_len = setup_abstract_addr(&addr, iscsid_namespace);
if ((err = bind(fd, (struct sockaddr *) &addr, addr_len)) < 0 ) {
log_error("Can not bind IPC socket");
diff --git a/usr/mgmt_ipc.h b/usr/mgmt_ipc.h
index 55972ed793a1..b6b836fc07c1 100644
--- a/usr/mgmt_ipc.h
+++ b/usr/mgmt_ipc.h
@@ -115,5 +115,4 @@ int mgmt_ipc_listen(void);
int mgmt_ipc_systemd(void);
void mgmt_ipc_close(int fd);
void mgmt_ipc_handle(int accept_fd);
-
#endif /* MGMT_IPC_H */
--
2.9.4