svn commit: r294932 - head/usr.sbin/iscsid

Edward Tomasz Napierala trasz at FreeBSD.org
Wed Jan 27 18:12:44 UTC 2016


Author: trasz
Date: Wed Jan 27 18:12:42 2016
New Revision: 294932
URL: https://svnweb.freebsd.org/changeset/base/294932

Log:
  Improve reporting of connection problems in iscsid(8).
  
  Obtained from:	Mellanox Technologies
  MFC after:	1 month
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/usr.sbin/iscsid/pdu.c

Modified: head/usr.sbin/iscsid/pdu.c
==============================================================================
--- head/usr.sbin/iscsid/pdu.c	Wed Jan 27 17:59:39 2016	(r294931)
+++ head/usr.sbin/iscsid/pdu.c	Wed Jan 27 18:12:42 2016	(r294932)
@@ -34,7 +34,9 @@ __FBSDID("$FreeBSD$");
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <assert.h>
+#include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 #include "iscsid.h"
@@ -177,18 +179,23 @@ pdu_padding(const struct pdu *pdu)
 }
 
 static void
-pdu_read(int fd, char *data, size_t len)
+pdu_read(const struct connection *conn, char *data, size_t len)
 {
 	ssize_t ret;
 
 	while (len > 0) {
-		ret = read(fd, data, len);
+		ret = read(conn->conn_socket, data, len);
 		if (ret < 0) {
-			if (timed_out())
+			if (timed_out()) {
+				fail(conn, "Login Phase timeout");
 				log_errx(1, "exiting due to timeout");
+			}
+			fail(conn, strerror(errno));
 			log_err(1, "read");
-		} else if (ret == 0)
+		} else if (ret == 0) {
+			fail(conn, "connection lost");
 			log_errx(1, "read: connection lost");
+		}
 		len -= ret;
 		data += ret;
 	}
@@ -207,7 +214,7 @@ pdu_receive(struct pdu *pdu)
 
 	assert(pdu->pdu_connection->conn_conf.isc_iser == 0);
 
-	pdu_read(pdu->pdu_connection->conn_socket,
+	pdu_read(pdu->pdu_connection,
 	    (char *)pdu->pdu_bhs, sizeof(*pdu->pdu_bhs));
 
 	len = pdu_ahs_length(pdu);
@@ -227,13 +234,13 @@ pdu_receive(struct pdu *pdu)
 		if (pdu->pdu_data == NULL)
 			log_err(1, "malloc");
 
-		pdu_read(pdu->pdu_connection->conn_socket,
+		pdu_read(pdu->pdu_connection,
 		    (char *)pdu->pdu_data, pdu->pdu_data_len);
 
 		padding = pdu_padding(pdu);
 		if (padding != 0) {
 			assert(padding < sizeof(dummy));
-			pdu_read(pdu->pdu_connection->conn_socket,
+			pdu_read(pdu->pdu_connection,
 			    (char *)dummy, padding);
 		}
 	}


More information about the svn-src-all mailing list