diff options
author | trasz <trasz@FreeBSD.org> | 2014-05-07 07:29:39 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2014-05-07 07:29:39 +0000 |
commit | 690b7a7a127bf05683bcac2f8623f493fa28647f (patch) | |
tree | 45ec51b4a29a711d6386f8830a84b1a439c93a3f /usr.sbin/ctld/pdu.c | |
parent | 7420d3ad268a728f49008826fe586a7d613617bf (diff) | |
download | FreeBSD-src-690b7a7a127bf05683bcac2f8623f493fa28647f.zip FreeBSD-src-690b7a7a127bf05683bcac2f8623f493fa28647f.tar.gz |
MFC r264524:
Make it possible for the iSCSI target side to operate in both normal
and ICL_KERNEL_PROXY mode, and fix some bit rot so the latter actually
works again.
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'usr.sbin/ctld/pdu.c')
-rw-r--r-- | usr.sbin/ctld/pdu.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/usr.sbin/ctld/pdu.c b/usr.sbin/ctld/pdu.c index eb8921e..084423c 100644 --- a/usr.sbin/ctld/pdu.c +++ b/usr.sbin/ctld/pdu.c @@ -44,6 +44,8 @@ #include <sys/ioctl.h> #endif +extern bool proxy_mode; + static int pdu_ahs_length(const struct pdu *pdu) { @@ -101,11 +103,13 @@ pdu_new_response(struct pdu *request) #ifdef ICL_KERNEL_PROXY -void -pdu_receive(struct pdu *pdu) +static void +pdu_receive_proxy(struct pdu *pdu) { size_t len; + assert(proxy_mode); + kernel_receive(pdu); len = pdu_ahs_length(pdu); @@ -117,15 +121,17 @@ pdu_receive(struct pdu *pdu) pdu->pdu_data_len = len; } -void -pdu_send(struct pdu *pdu) +static void +pdu_send_proxy(struct pdu *pdu) { + assert(proxy_mode); + pdu_set_data_segment_length(pdu, pdu->pdu_data_len); kernel_send(pdu); } -#else /* !ICL_KERNEL_PROXY */ +#endif /* ICL_KERNEL_PROXY */ static size_t pdu_padding(const struct pdu *pdu) @@ -161,6 +167,13 @@ pdu_receive(struct pdu *pdu) size_t len, padding; char dummy[4]; +#ifdef ICL_KERNEL_PROXY + if (proxy_mode) + return (pdu_receive_proxy(pdu)); +#endif + + assert(proxy_mode == false); + pdu_read(pdu->pdu_connection->conn_socket, (char *)pdu->pdu_bhs, sizeof(*pdu->pdu_bhs)); @@ -202,6 +215,13 @@ pdu_send(struct pdu *pdu) struct iovec iov[3]; int iovcnt; +#ifdef ICL_KERNEL_PROXY + if (proxy_mode) + return (pdu_send_proxy(pdu)); +#endif + + assert(proxy_mode == false); + 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); @@ -234,8 +254,6 @@ pdu_send(struct pdu *pdu) log_errx(1, "short write"); } -#endif /* !ICL_KERNEL_PROXY */ - void pdu_delete(struct pdu *pdu) { |