svn commit: r265526 - in stable/10: sys/dev/iscsi usr.sbin/iscsid
Edward Tomasz Napierala
trasz at FreeBSD.org
Wed May 7 07:56:37 UTC 2014
Author: trasz
Date: Wed May 7 07:56:36 2014
New Revision: 265526
URL: http://svnweb.freebsd.org/changeset/base/265526
Log:
MFC r264549:
Make it possible for the initiator side to operate in both proxy
and normal mode; this makes it possible to compile with the former
by default, but use it only when neccessary. That's especially
important for the userland part.
Sponsored by: The FreeBSD Foundation
Modified:
stable/10/sys/dev/iscsi/iscsi.c
stable/10/sys/dev/iscsi/iscsi_ioctl.h
stable/10/usr.sbin/iscsid/iscsid.c
stable/10/usr.sbin/iscsid/iscsid.h
stable/10/usr.sbin/iscsid/pdu.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/dev/iscsi/iscsi.c
==============================================================================
--- stable/10/sys/dev/iscsi/iscsi.c Wed May 7 07:54:47 2014 (r265525)
+++ stable/10/sys/dev/iscsi/iscsi.c Wed May 7 07:56:36 2014 (r265526)
@@ -1303,12 +1303,19 @@ iscsi_ioctl_daemon_handoff(struct iscsi_
ISCSI_SESSION_UNLOCK(is);
-#ifndef ICL_KERNEL_PROXY
- error = icl_conn_handoff(is->is_conn, handoff->idh_socket);
- if (error != 0) {
- sx_sunlock(&sc->sc_lock);
- iscsi_session_terminate(is);
- return (error);
+#ifdef ICL_KERNEL_PROXY
+ if (handoff->idh_socket != 0) {
+#endif
+ /*
+ * Handoff without using ICL proxy.
+ */
+ error = icl_conn_handoff(is->is_conn, handoff->idh_socket);
+ if (error != 0) {
+ sx_sunlock(&sc->sc_lock);
+ iscsi_session_terminate(is);
+ return (error);
+ }
+#ifdef ICL_KERNEL_PROXY
}
#endif
@@ -1419,13 +1426,18 @@ iscsi_ioctl_daemon_connect(struct iscsi_
if (idc->idc_from_addrlen > 0) {
error = getsockaddr(&from_sa, (void *)idc->idc_from_addr, idc->idc_from_addrlen);
- if (error != 0)
+ if (error != 0) {
+ ISCSI_SESSION_WARN(is,
+ "getsockaddr failed with error %d", error);
return (error);
+ }
} else {
from_sa = NULL;
}
error = getsockaddr(&to_sa, (void *)idc->idc_to_addr, idc->idc_to_addrlen);
if (error != 0) {
+ ISCSI_SESSION_WARN(is, "getsockaddr failed with error %d",
+ error);
free(from_sa, M_SONAME);
return (error);
}
Modified: stable/10/sys/dev/iscsi/iscsi_ioctl.h
==============================================================================
--- stable/10/sys/dev/iscsi/iscsi_ioctl.h Wed May 7 07:54:47 2014 (r265525)
+++ stable/10/sys/dev/iscsi/iscsi_ioctl.h Wed May 7 07:56:36 2014 (r265526)
@@ -129,9 +129,9 @@ struct iscsi_daemon_fail {
/*
* When ICL_KERNEL_PROXY is not defined, the iscsid(8) is responsible
- * for creating the socket, connecting, performing Login Phase using
- * socked in the usual userspace way, and then passing the socket file
- * descriptor to the kernel part using ISCSIDHANDOFF.
+ * for creating the socket, connecting, and performing Login Phase using
+ * the socket in the usual userspace way, and then passing the socket
+ * file descriptor to the kernel part using ISCSIDHANDOFF.
*
* When ICL_KERNEL_PROXY is defined, the iscsid(8) creates the session
* using ISCSICONNECT, performs Login Phase using ISCSISEND/ISCSIRECEIVE
@@ -162,7 +162,7 @@ struct iscsi_daemon_send {
void *ids_spare2;
size_t ids_data_segment_len;
void *ids_data_segment;
- int ids_spare[4];
+ int ids_spare3[4];
};
struct iscsi_daemon_receive {
@@ -172,7 +172,7 @@ struct iscsi_daemon_receive {
void *idr_spare2;
size_t idr_data_segment_len;
void *idr_data_segment;
- int idr_spare[4];
+ int idr_spare3[4];
};
#define ISCSIDCONNECT _IOWR('I', 0x04, struct iscsi_daemon_connect)
Modified: stable/10/usr.sbin/iscsid/iscsid.c
==============================================================================
--- stable/10/usr.sbin/iscsid/iscsid.c Wed May 7 07:54:47 2014 (r265525)
+++ stable/10/usr.sbin/iscsid/iscsid.c Wed May 7 07:56:36 2014 (r265526)
@@ -194,30 +194,32 @@ connection_new(unsigned int session_id,
resolve_addr(conn, to_addr, &to_ai, false);
#ifdef ICL_KERNEL_PROXY
+ if (conn->conn_conf.isc_iser) {
+ memset(&idc, 0, sizeof(idc));
+ idc.idc_session_id = conn->conn_session_id;
+ if (conn->conn_conf.isc_iser)
+ idc.idc_iser = 1;
+ idc.idc_domain = to_ai->ai_family;
+ idc.idc_socktype = to_ai->ai_socktype;
+ idc.idc_protocol = to_ai->ai_protocol;
+ if (from_ai != NULL) {
+ idc.idc_from_addr = from_ai->ai_addr;
+ idc.idc_from_addrlen = from_ai->ai_addrlen;
+ }
+ idc.idc_to_addr = to_ai->ai_addr;
+ idc.idc_to_addrlen = to_ai->ai_addrlen;
- memset(&idc, 0, sizeof(idc));
- idc.idc_session_id = conn->conn_session_id;
- if (conn->conn_conf.isc_iser)
- idc.idc_iser = 1;
- idc.idc_domain = to_ai->ai_family;
- idc.idc_socktype = to_ai->ai_socktype;
- idc.idc_protocol = to_ai->ai_protocol;
- if (from_ai != NULL) {
- idc.idc_from_addr = from_ai->ai_addr;
- idc.idc_from_addrlen = from_ai->ai_addrlen;
- }
- idc.idc_to_addr = to_ai->ai_addr;
- idc.idc_to_addrlen = to_ai->ai_addrlen;
+ log_debugx("connecting to %s using ICL kernel proxy", to_addr);
+ error = ioctl(iscsi_fd, ISCSIDCONNECT, &idc);
+ if (error != 0) {
+ fail(conn, strerror(errno));
+ log_err(1, "failed to connect to %s "
+ "using ICL kernel proxy: ISCSIDCONNECT", to_addr);
+ }
- log_debugx("connecting to %s using ICL kernel proxy", to_addr);
- error = ioctl(iscsi_fd, ISCSIDCONNECT, &idc);
- if (error != 0) {
- fail(conn, strerror(errno));
- log_err(1, "failed to connect to %s using ICL kernel proxy",
- to_addr);
+ return (conn);
}
-
-#else /* !ICL_KERNEL_PROXY */
+#endif /* ICL_KERNEL_PROXY */
if (conn->conn_conf.isc_iser) {
fail(conn, "iSER not supported");
@@ -246,8 +248,6 @@ connection_new(unsigned int session_id,
log_err(1, "failed to connect to %s", to_addr);
}
-#endif /* !ICL_KERNEL_PROXY */
-
return (conn);
}
@@ -261,9 +261,7 @@ handoff(struct connection *conn)
memset(&idh, 0, sizeof(idh));
idh.idh_session_id = conn->conn_session_id;
-#ifndef ICL_KERNEL_PROXY
idh.idh_socket = conn->conn_socket;
-#endif
strlcpy(idh.idh_target_alias, conn->conn_target_alias,
sizeof(idh.idh_target_alias));
memcpy(idh.idh_isid, conn->conn_isid, sizeof(idh.idh_isid));
Modified: stable/10/usr.sbin/iscsid/iscsid.h
==============================================================================
--- stable/10/usr.sbin/iscsid/iscsid.h Wed May 7 07:54:47 2014 (r265525)
+++ stable/10/usr.sbin/iscsid/iscsid.h Wed May 7 07:56:36 2014 (r265526)
@@ -46,9 +46,7 @@
struct connection {
int conn_iscsi_fd;
-#ifndef ICL_KERNEL_PROXY
int conn_socket;
-#endif
unsigned int conn_session_id;
struct iscsi_session_conf conn_conf;
char conn_target_alias[ISCSI_ADDR_LEN];
Modified: stable/10/usr.sbin/iscsid/pdu.c
==============================================================================
--- stable/10/usr.sbin/iscsid/pdu.c Wed May 7 07:54:47 2014 (r265525)
+++ stable/10/usr.sbin/iscsid/pdu.c Wed May 7 07:56:36 2014 (r265526)
@@ -101,13 +101,15 @@ pdu_new_response(struct pdu *request)
#ifdef ICL_KERNEL_PROXY
-void
-pdu_receive(struct pdu *pdu)
+static void
+pdu_receive_proxy(struct pdu *pdu)
{
struct iscsi_daemon_receive *idr;
size_t len;
int error;
+ assert(pdu->pdu_connection->conn_conf.isc_iser != 0);
+
pdu->pdu_data = malloc(ISCSI_MAX_DATA_SEGMENT_LENGTH);
if (pdu->pdu_data == NULL)
log_err(1, "malloc");
@@ -136,12 +138,14 @@ pdu_receive(struct pdu *pdu)
free(idr);
}
-void
-pdu_send(struct pdu *pdu)
+static void
+pdu_send_proxy(struct pdu *pdu)
{
struct iscsi_daemon_send *ids;
int error;
+ assert(pdu->pdu_connection->conn_conf.isc_iser != 0);
+
pdu_set_data_segment_length(pdu, pdu->pdu_data_len);
ids = calloc(1, sizeof(*ids));
@@ -160,7 +164,7 @@ pdu_send(struct pdu *pdu)
free(ids);
}
-#else /* !ICL_KERNEL_PROXY */
+#endif /* ICL_KERNEL_PROXY */
static size_t
pdu_padding(const struct pdu *pdu)
@@ -196,6 +200,13 @@ pdu_receive(struct pdu *pdu)
size_t len, padding;
char dummy[4];
+#ifdef ICL_KERNEL_PROXY
+ if (pdu->pdu_connection->conn_conf.isc_iser != 0)
+ return (pdu_receive_proxy(pdu));
+#endif
+
+ assert(pdu->pdu_connection->conn_conf.isc_iser == 0);
+
pdu_read(pdu->pdu_connection->conn_socket,
(char *)pdu->pdu_bhs, sizeof(*pdu->pdu_bhs));
@@ -237,6 +248,13 @@ pdu_send(struct pdu *pdu)
struct iovec iov[3];
int iovcnt;
+#ifdef ICL_KERNEL_PROXY
+ if (pdu->pdu_connection->conn_conf.isc_iser != 0)
+ return (pdu_send_proxy(pdu));
+#endif
+
+ assert(pdu->pdu_connection->conn_conf.isc_iser == 0);
+
pdu_set_data_segment_length(pdu, pdu->pdu_data_len);
iov[0].iov_base = pdu->pdu_bhs;
iov[0].iov_len = sizeof(*pdu->pdu_bhs);
@@ -269,8 +287,6 @@ pdu_send(struct pdu *pdu)
log_errx(1, "short write");
}
-#endif /* !ICL_KERNEL_PROXY */
-
void
pdu_delete(struct pdu *pdu)
{
More information about the svn-src-stable
mailing list