c2d5d21
From fef4db2784fac34fa99468de09c386114b228b36 Mon Sep 17 00:00:00 2001
c2d5d21
From: Jan Vesely <jvesely@redhat.com>
c2d5d21
Date: Wed, 26 Jun 2013 15:55:12 +0200
c2d5d21
Subject: iscsiuio: Change socket bind to use the same struct size as iscsid
c2d5d21
c2d5d21
Without this patch connections to iscsiuio fail, and strace prints:
c2d5d21
c2d5d21
connect(8, {sa_family=AF_FILE, path=@"ISCSID_UIP_ABSTRACT_NAMESPACE"}, 32) = -1 ECONNREFUSED (Connection refused)
c2d5d21
c2d5d21
Note that updating mgmt_ipc_listen and ipc_connect to use sizeof(addr) instead
c2d5d21
of the precomputed values also fixes the issue.
c2d5d21
Looks like "(Null bytes in the name have no special significance.)" [man 7 unix] is the culprit here.
c2d5d21
c2d5d21
Signed-off-by: Jan Vesely <jvesely@redhat.com>
c2d5d21
---
c2d5d21
 iscsiuio/src/unix/iscsid_ipc.c | 6 ++++--
c2d5d21
 1 file changed, 4 insertions(+), 2 deletions(-)
c2d5d21
c2d5d21
diff --git a/iscsiuio/src/unix/iscsid_ipc.c b/iscsiuio/src/unix/iscsid_ipc.c
c2d5d21
index 5c097e6..e22de0d 100644
c2d5d21
--- a/iscsiuio/src/unix/iscsid_ipc.c
c2d5d21
+++ b/iscsiuio/src/unix/iscsid_ipc.c
c2d5d21
@@ -958,7 +958,7 @@ static void *iscsid_loop(void *arg)
c2d5d21
  */
c2d5d21
 int iscsid_init()
c2d5d21
 {
c2d5d21
-	int rc;
c2d5d21
+	int rc, addr_len;
c2d5d21
 	struct sockaddr_un addr;
c2d5d21
 
c2d5d21
 	iscsid_opts.fd = socket(AF_LOCAL, SOCK_STREAM, 0);
c2d5d21
@@ -967,12 +967,14 @@ int iscsid_init()
c2d5d21
 		return iscsid_opts.fd;
c2d5d21
 	}
c2d5d21
 
c2d5d21
+	addr_len = offsetof(struct sockaddr_un, sun_path) + strlen(ISCSID_UIP_NAMESPACE) + 1;
c2d5d21
+
c2d5d21
 	memset(&addr, 0, sizeof(addr));
c2d5d21
 	addr.sun_family = AF_LOCAL;
c2d5d21
 	memcpy((char *)&addr.sun_path + 1, ISCSID_UIP_NAMESPACE,
c2d5d21
 	       strlen(ISCSID_UIP_NAMESPACE));
c2d5d21
 
c2d5d21
-	rc = bind(iscsid_opts.fd, (struct sockaddr *)&addr, sizeof(addr));
c2d5d21
+	rc = bind(iscsid_opts.fd, (struct sockaddr *)&addr, addr_len);
c2d5d21
 	if (rc < 0) {
c2d5d21
 		LOG_ERR(PFX "Can not bind IPC socket: %s", strerror(errno));
c2d5d21
 		goto error;
c2d5d21
-- 
c2d5d21
1.8.1.4
c2d5d21