diff options
author | Scott Moser <smoser@brickies.net> | 2018-09-19 17:38:26 -0400 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2018-09-19 17:38:26 -0400 |
commit | 4baefcf5a18589ab9e95fe172af76b16c722f43e (patch) | |
tree | 8c1169ee186241c7cbac854573e1ef6b97adcd17 | |
parent | 38952aa277df116da0b7ef389440de34a3e61cd0 (diff) | |
download | open-iscsi-4baefcf5a18589ab9e95fe172af76b16c722f43e.tar.gz |
Better error message and failure if netlink socket fails.
This does 2 things:
a.) shows strerror when the socket creation of NETLINK_ISCSI fails.
b.) moves the attempt to create the socket to after pid file writing.
The reason for 'b' is that if failure happens in 'a', then no pid
file is written. Systemd's tracking would then not notice the failure.
-rw-r--r-- | usr/iscsid.c | 10 | ||||
-rw-r--r-- | usr/netlink.c | 6 |
2 files changed, 9 insertions, 7 deletions
diff --git a/usr/iscsid.c b/usr/iscsid.c index 7d60322..35e95ba 100644 --- a/usr/iscsid.c +++ b/usr/iscsid.c @@ -442,11 +442,6 @@ int main(int argc, char *argv[]) exit(0); } - if ((control_fd = ipc->ctldev_open()) < 0) { - log_close(log_pid); - exit(ISCSI_ERR); - } - if (chdir("/") < 0) log_debug(1, "Unable to chdir to /"); if (fd > 0) { @@ -469,6 +464,11 @@ int main(int argc, char *argv[]) } close(fd); + if ((control_fd = ipc->ctldev_open()) < 0) { + log_close(log_pid); + exit(ISCSI_ERR); + } + daemon_init(); } else { if ((control_fd = ipc->ctldev_open()) < 0) { diff --git a/usr/netlink.c b/usr/netlink.c index 1a0bf80..f1aab52 100644 --- a/usr/netlink.c +++ b/usr/netlink.c @@ -1704,7 +1704,8 @@ ctldev_open(void) ctrl_fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ISCSI); if (ctrl_fd < 0) { - log_error("can not create NETLINK_ISCSI socket"); + log_error("can not create NETLINK_ISCSI socket [%s]", + strerror(errno)); goto free_setparam_buf; } @@ -1713,7 +1714,8 @@ ctldev_open(void) src_addr.nl_pid = getpid(); src_addr.nl_groups = 1; if (bind(ctrl_fd, (struct sockaddr *)&src_addr, sizeof(src_addr))) { - log_error("can not bind NETLINK_ISCSI socket"); + log_error("can not bind NETLINK_ISCSI socket [%s]", + strerror(errno)); goto close_socket; } |