iscsistart forks two processes and acts as both iscsiadm and iscsid, sending commands to itself over a unix socket. If multiple iscsistart processes are running, or iscsistart and iscsid are both running, the front-end portions can end up communicating to the wrong back-end.
Adjust the unix socket name to include the PID for iscsistart, to isolate instances and not conflict with the normal iscsid use. --- usr/iscsid_req.c | 12 +++++++++++- usr/iscsid_req.h | 3 +++ usr/iscsistart.c | 7 +++++++ usr/mgmt_ipc.c | 3 ++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c index a2e6d6e39ceb..d18b14d5f54f 100644 --- a/usr/iscsid_req.c +++ b/usr/iscsid_req.c @@ -98,9 +98,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 67e509e4607f..d580ed2d5360 100644 --- a/usr/iscsid_req.h +++ b/usr/iscsid_req.h @@ -27,6 +27,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, int tmo); extern int iscsid_req_wait(iscsiadm_cmd_e cmd, int fd); diff --git a/usr/iscsistart.c b/usr/iscsistart.c index 1e77e40cf4e5..d3616eaa663b 100644 --- a/usr/iscsistart.c +++ b/usr/iscsistart.c @@ -471,6 +471,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(); /* @@ -488,6 +492,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 879acea80632..1ffcda9e0c43 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"); -- 2.14.4 -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscr...@googlegroups.com. To post to this group, send email to open-iscsi@googlegroups.com. Visit this group at https://groups.google.com/group/open-iscsi. For more options, visit https://groups.google.com/d/optout.