diff --git a/iscsi-scst/doc/manpages/iscsi-scstd.8 b/iscsi-scst/doc/manpages/iscsi-scstd.8 index 0ce805e09..6b536556e 100644 --- a/iscsi-scst/doc/manpages/iscsi-scstd.8 +++ b/iscsi-scst/doc/manpages/iscsi-scstd.8 @@ -18,8 +18,6 @@ iscsi-scstd \- iSCSI SCST Target Daemon .IR address \|] .RB [\| \-p .IR port \|] -.RB [\| \-s -.IR IP \|] .RB [\| \-u .IR UID \|] .SH DESCRIPTION @@ -53,9 +51,6 @@ Specify on which port the server should listen, default is 3260. .BI \-h,\ \-\-help Display help message on command line options. .TP -.BI \-s\ IP ,\ \-\-isns= IP -isns server's IP address -.TP .BI \-u\ UID ,\ \-\-uid= UID Specify running user id, default is current uid. .SH FILES diff --git a/iscsi-scst/doc/manpages/iscsi-scstd.conf.5 b/iscsi-scst/doc/manpages/iscsi-scstd.conf.5 index b9768aa3b..6958b15ec 100644 --- a/iscsi-scst/doc/manpages/iscsi-scstd.conf.5 +++ b/iscsi-scst/doc/manpages/iscsi-scstd.conf.5 @@ -134,7 +134,7 @@ Optional. If set to "CRC32C" and the initiator is configured accordingly, the in Optional. If set to "CRC32C" and the initiator is configured accordingly, the integrity of an iSCSI PDU's data segment will be protected by a CRC32C checksum. The default is "None". Note that data digests are not supported during discovery sessions. .TP .B [MaxConnections ] -Optional. Has to be set to "1" (in words: one), which is also the default. +Optional. The number of connections within a session. Has to be set to "1" (in words: one), which is also the default since MC/S is not supported. .TP .B [InitialR2T ] Optional. If set to "Yes", the initiator has to wait for the target to solicit SCSI data before sending it. Setting it to "No" (default) allows the initiator to send a burst of diff --git a/iscsi-scst/include/iscsi_scst_ver.h b/iscsi-scst/include/iscsi_scst_ver.h index b38197845..343a1438f 100644 --- a/iscsi-scst/include/iscsi_scst_ver.h +++ b/iscsi-scst/include/iscsi_scst_ver.h @@ -13,4 +13,4 @@ * GNU General Public License for more details. */ -#define ISCSI_VERSION_STRING "1.0.1/0.4.16r155" +#define ISCSI_VERSION_STRING "1.0.1/0.4.17r191" diff --git a/iscsi-scst/kernel/target.c b/iscsi-scst/kernel/target.c index 278dcdff8..9ad6f586d 100644 --- a/iscsi-scst/kernel/target.c +++ b/iscsi-scst/kernel/target.c @@ -116,8 +116,6 @@ static int iscsi_target_create(struct target_info *info, u32 tid) mutex_init(&target->target_mutex); INIT_LIST_HEAD(&target->session_list); - list_add(&target->target_list_entry, &target_list); - target->scst_tgt = scst_register(&iscsi_template, target->name); if (!target->scst_tgt) { PRINT_ERROR("%s", "scst_register() failed"); @@ -125,6 +123,8 @@ static int iscsi_target_create(struct target_info *info, u32 tid) goto out_free; } + list_add(&target->target_list_entry, &target_list); + return 0; out_free: diff --git a/iscsi-scst/usr/iscsi_scstd.c b/iscsi-scst/usr/iscsi_scstd.c index b1ef68e56..ba2505fa9 100644 --- a/iscsi-scst/usr/iscsi_scstd.c +++ b/iscsi-scst/usr/iscsi_scstd.c @@ -656,14 +656,25 @@ int main(int argc, char **argv) exit(res); } - chdir("/"); + if (chdir("/") < 0) { + log_error("failed to set working dir to /: %m"); + exit(1); + } + if (lockf(fd, F_TLOCK, 0) < 0) { log_error("unable to lock pid file"); exit(1); } - ftruncate(fd, 0); + if (ftruncate(fd, 0) < 0) { + log_error("failed to ftruncate the PID file: %m"); + exit(1); + } + sprintf(buf, "%d\n", getpid()); - write(fd, buf, strlen(buf)); + if (write(fd, buf, strlen(buf)) < strlen(buf)) { + log_error("failed to write PID to PID file: %m"); + exit(1); + } close(0); open("/dev/null", O_RDWR); diff --git a/iscsi-scst/usr/iscsid.c b/iscsi-scst/usr/iscsid.c index d4ce17fc9..c52b98cdb 100644 --- a/iscsi-scst/usr/iscsid.c +++ b/iscsi-scst/usr/iscsid.c @@ -727,36 +727,28 @@ int cmnd_execute(struct connection *conn) case ISCSI_OP_LOGIN_CMD: //if conn->state == STATE_FULL -> reject cmnd_exec_login(conn); - conn->rsp.bhs.ahslength = conn->rsp.ahssize / 4; - conn->rsp.bhs.datalength[0] = conn->rsp.datasize >> 16; - conn->rsp.bhs.datalength[1] = conn->rsp.datasize >> 8; - conn->rsp.bhs.datalength[2] = conn->rsp.datasize; - log_pdu(2, &conn->rsp); break; case ISCSI_OP_TEXT_CMD: //if conn->state != STATE_FULL -> reject cmnd_exec_text(conn); - conn->rsp.bhs.ahslength = conn->rsp.ahssize / 4; - conn->rsp.bhs.datalength[0] = conn->rsp.datasize >> 16; - conn->rsp.bhs.datalength[1] = conn->rsp.datasize >> 8; - conn->rsp.bhs.datalength[2] = conn->rsp.datasize; - log_pdu(2, &conn->rsp); break; case ISCSI_OP_LOGOUT_CMD: //if conn->state != STATE_FULL -> reject cmnd_exec_logout(conn); - conn->rsp.bhs.ahslength = conn->rsp.ahssize / 4; - conn->rsp.bhs.datalength[0] = conn->rsp.datasize >> 16; - conn->rsp.bhs.datalength[1] = conn->rsp.datasize >> 8; - conn->rsp.bhs.datalength[2] = conn->rsp.datasize; - log_pdu(2, &conn->rsp); break; default: //reject res = 0; - break; + goto out; } + conn->rsp.bhs.ahslength = conn->rsp.ahssize / 4; + conn->rsp.bhs.datalength[0] = conn->rsp.datasize >> 16; + conn->rsp.bhs.datalength[1] = conn->rsp.datasize >> 8; + conn->rsp.bhs.datalength[2] = conn->rsp.datasize; + log_pdu(2, &conn->rsp); + +out: return res; } diff --git a/iscsi-scst/usr/iscsid.h b/iscsi-scst/usr/iscsid.h index 5371890ce..b976873fb 100644 --- a/iscsi-scst/usr/iscsid.h +++ b/iscsi-scst/usr/iscsid.h @@ -65,7 +65,6 @@ struct connection { char *user; union iscsi_sid sid; u16 cid; - u16 pad; int session_type; int auth_method; diff --git a/iscsi-scst/usr/isns.c b/iscsi-scst/usr/isns.c index b6ddec3cd..f29689a64 100644 --- a/iscsi-scst/usr/isns.c +++ b/iscsi-scst/usr/isns.c @@ -201,8 +201,10 @@ static int isns_scn_deregister(char *name) memset(buf, 0, sizeof(buf)); tlv = (struct isns_tlv *) hdr->pdu; - length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name), name); - length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name), name); + length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name) + 1, + name); + length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name) + 1, + name); flags = ISNS_FLAG_CLIENT | ISNS_FLAG_LAST_PDU | ISNS_FLAG_FIRST_PDU; isns_hdr_init(hdr, ISNS_FUNC_SCN_DEREG, length, flags, @@ -251,9 +253,9 @@ static int isns_scn_register(void) target = list_entry(targets_list.q_forw, struct target, tlist); length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, - strlen(target->name), target->name); + strlen(target->name) + 1, target->name); length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, - strlen(target->name), target->name); + strlen(target->name) + 1, target->name); length += isns_tlv_set(&tlv, 0, 0, 0); scn_flags = ISNS_SCN_FLAG_INITIATOR | ISNS_SCN_FLAG_OBJECT_REMOVE | @@ -301,14 +303,15 @@ static int isns_attr_query(char *name) tlv = (struct isns_tlv *) hdr->pdu; if (name) - snprintf(mgmt->name, sizeof(mgmt->name), name); + snprintf(mgmt->name, sizeof(mgmt->name), "%s", name); else { mgmt->name[0] = '\0'; target = list_entry(targets_list.q_forw, struct target, tlist); name = target->name; } - length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name), name); + length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name) + 1, + name); length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NODE_TYPE, sizeof(node), &node); length += isns_tlv_set(&tlv, 0, 0, 0); @@ -350,10 +353,10 @@ static int isns_deregister(void) target = list_entry(targets_list.q_forw, struct target, tlist); length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, - strlen(target->name), target->name); + strlen(target->name) + 1, target->name); length += isns_tlv_set(&tlv, 0, 0, 0); length += isns_tlv_set(&tlv, ISNS_ATTR_ENTITY_IDENTIFIER, - strlen(eid), eid); + strlen(eid) + 1, eid); flags = ISNS_FLAG_CLIENT | ISNS_FLAG_LAST_PDU | ISNS_FLAG_FIRST_PDU; isns_hdr_init(hdr, ISNS_FUNC_DEV_DEREG, length, flags, @@ -371,7 +374,7 @@ int isns_target_register(char *name) uint16_t flags = 0, length = 0; struct isns_hdr *hdr = (struct isns_hdr *) buf; struct isns_tlv *tlv; - uint32_t port = htonl(ISCSI_LISTEN_PORT); + uint32_t port = htonl(server_port); uint32_t node = htonl(ISNS_NODE_TARGET); uint32_t type = htonl(2); struct target *target; @@ -389,14 +392,14 @@ int isns_target_register(char *name) target = list_entry(targets_list.q_back, struct target, tlist); length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, - strlen(target->name), target->name); + strlen(target->name) + 1, target->name); length += isns_tlv_set(&tlv, ISNS_ATTR_ENTITY_IDENTIFIER, - strlen(eid), eid); + strlen(eid) + 1, eid); length += isns_tlv_set(&tlv, 0, 0, 0); length += isns_tlv_set(&tlv, ISNS_ATTR_ENTITY_IDENTIFIER, - strlen(eid), eid); + strlen(eid) + 1, eid); if (initial) { length += isns_tlv_set(&tlv, ISNS_ATTR_ENTITY_PROTOCOL, sizeof(type), &type); @@ -413,7 +416,8 @@ int isns_target_register(char *name) } } - length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name), name); + length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name) + 1, + name); length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NODE_TYPE, sizeof(node), &node); @@ -478,14 +482,15 @@ int isns_target_deregister(char *name) memset(buf, 0, sizeof(buf)); tlv = (struct isns_tlv *) hdr->pdu; - length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name), name); + length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name) + 1, + name); length += isns_tlv_set(&tlv, 0, 0, 0); if (last) length += isns_tlv_set(&tlv, ISNS_ATTR_ENTITY_IDENTIFIER, - strlen(eid), eid); + strlen(eid) + 1, eid); else length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, - strlen(name), name); + strlen(name) + 1, name); flags = ISNS_FLAG_CLIENT | ISNS_FLAG_LAST_PDU | ISNS_FLAG_FIRST_PDU; isns_hdr_init(hdr, ISNS_FUNC_DEV_DEREG, length, flags, @@ -689,7 +694,8 @@ found: ini = malloc(sizeof(*ini)); if (!ini) goto free_qry_mgmt; - snprintf(ini->name, sizeof(ini->name), name); + snprintf(ini->name, sizeof(ini->name), "%s", + name); insque(&ini->ilist, &target->isns_head); } else name = NULL; @@ -797,7 +803,8 @@ static void send_scn_rsp(char *name, uint16_t transaction) tlv = (struct isns_tlv *) ((char *) hdr->pdu + 4); length +=4; - length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name), name); + length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name) + 1, + name); flags = ISNS_FLAG_CLIENT | ISNS_FLAG_LAST_PDU | ISNS_FLAG_FIRST_PDU; isns_hdr_init(hdr, ISNS_FUNC_SCN_RSP, length, flags, transaction, 0);