diff options
author | mav <mav@FreeBSD.org> | 2014-07-15 18:21:26 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2014-07-15 18:21:26 +0000 |
commit | e6aad795782ef4a872f748ad09e30f70235ba942 (patch) | |
tree | 830ad6baa2fa0f487d2cd79d0febaf011a9d1187 /usr.sbin | |
parent | 2c6230a1adb4e420bb9bd3ba65643b39d8f987d1 (diff) | |
download | FreeBSD-src-e6aad795782ef4a872f748ad09e30f70235ba942.zip FreeBSD-src-e6aad795782ef4a872f748ad09e30f70235ba942.tar.gz |
MFC r268326:
Make iSCSI initiator keep Initiator Session ID (ISID) across reconnects.
Previously ISID was changed every time, that made impossible correct
persistent reservation, because reconnected session was identified as
completely new one.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/iscsid/iscsid.c | 11 | ||||
-rw-r--r-- | usr.sbin/iscsid/iscsid.h | 1 | ||||
-rw-r--r-- | usr.sbin/iscsid/login.c | 22 |
3 files changed, 10 insertions, 24 deletions
diff --git a/usr.sbin/iscsid/iscsid.c b/usr.sbin/iscsid/iscsid.c index 743e02a..1693d30 100644 --- a/usr.sbin/iscsid/iscsid.c +++ b/usr.sbin/iscsid/iscsid.c @@ -149,8 +149,8 @@ resolve_addr(const struct connection *conn, const char *address, } static struct connection * -connection_new(unsigned int session_id, const struct iscsi_session_conf *conf, - int iscsi_fd) +connection_new(unsigned int session_id, const uint8_t isid[8], uint16_t tsih, + const struct iscsi_session_conf *conf, int iscsi_fd) { struct connection *conn; struct addrinfo *from_ai, *to_ai; @@ -176,6 +176,8 @@ connection_new(unsigned int session_id, const struct iscsi_session_conf *conf, conn->conn_first_burst_length = 65536; conn->conn_session_id = session_id; + memcpy(&conn->conn_isid, isid, sizeof(conn->conn_isid)); + conn->conn_tsih = tsih; conn->conn_iscsi_fd = iscsi_fd; /* @@ -264,7 +266,7 @@ handoff(struct connection *conn) idh.idh_socket = conn->conn_socket; 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)); + idh.idh_tsih = conn->conn_tsih; idh.idh_statsn = conn->conn_statsn; idh.idh_header_digest = conn->conn_header_digest; idh.idh_data_digest = conn->conn_data_digest; @@ -430,7 +432,8 @@ handle_request(int iscsi_fd, const struct iscsi_daemon_request *request, int tim setproctitle("%s", request->idr_conf.isc_target_addr); } - conn = connection_new(request->idr_session_id, &request->idr_conf, iscsi_fd); + conn = connection_new(request->idr_session_id, request->idr_isid, + request->idr_tsih, &request->idr_conf, iscsi_fd); set_timeout(timeout); capsicate(conn); login(conn); diff --git a/usr.sbin/iscsid/iscsid.h b/usr.sbin/iscsid/iscsid.h index b19542d..9623559 100644 --- a/usr.sbin/iscsid/iscsid.h +++ b/usr.sbin/iscsid/iscsid.h @@ -51,6 +51,7 @@ struct connection { struct iscsi_session_conf conn_conf; char conn_target_alias[ISCSI_ADDR_LEN]; uint8_t conn_isid[6]; + uint16_t conn_tsih; uint32_t conn_statsn; int conn_header_digest; int conn_data_digest; diff --git a/usr.sbin/iscsid/login.c b/usr.sbin/iscsid/login.c index 4f53258..81a965d 100644 --- a/usr.sbin/iscsid/login.c +++ b/usr.sbin/iscsid/login.c @@ -199,6 +199,7 @@ login_receive(struct connection *conn, bool initial) "is %d, should be %d", ntohl(bhslr->bhslr_statsn), conn->conn_statsn + 1); } + conn->conn_tsih = ntohs(bhslr->bhslr_tsih); conn->conn_statsn = ntohl(bhslr->bhslr_statsn); return (response); @@ -218,6 +219,7 @@ login_new_request(struct connection *conn) login_set_csg(request, BHSLR_STAGE_SECURITY_NEGOTIATION); login_set_nsg(request, BHSLR_STAGE_OPERATIONAL_NEGOTIATION); memcpy(bhslr->bhslr_isid, &conn->conn_isid, sizeof(bhslr->bhslr_isid)); + bhslr->bhslr_tsih = htons(conn->conn_tsih); bhslr->bhslr_initiator_task_tag = 0; bhslr->bhslr_cmdsn = 0; bhslr->bhslr_expstatsn = htonl(conn->conn_statsn + 1); @@ -749,24 +751,6 @@ login_chap(struct connection *conn) log_debugx("CHAP authentication done"); } -static void -login_create_isid(struct connection *conn) -{ - int rv; - - /* - * RFC 3720, 10.12.5: 10b, "Random" ISID. - * - */ - conn->conn_isid[0] = 0x80; - - rv = RAND_bytes(&conn->conn_isid[1], 3); - if (rv != 1) { - log_errx(1, "RAND_bytes failed: %s", - ERR_error_string(ERR_get_error(), NULL)); - } -} - void login(struct connection *conn) { @@ -777,8 +761,6 @@ login(struct connection *conn) const char *auth_method; int i; - login_create_isid(conn); - log_debugx("beginning Login phase; sending Login PDU"); request = login_new_request(conn); |