Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx> --- usr/iscsi/iscsi_proto.h | 23 ++++++++++++----------- usr/iscsi/iscsid.c | 27 ++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/usr/iscsi/iscsi_proto.h b/usr/iscsi/iscsi_proto.h index c8bd1a7..d5e58df 100644 --- a/usr/iscsi/iscsi_proto.h +++ b/usr/iscsi/iscsi_proto.h @@ -568,17 +568,18 @@ struct iscsi_reject { }; /* Reason for Reject */ -#define ISCSI_REASON_CMD_BEFORE_LOGIN 1 -#define ISCSI_REASON_DATA_DIGEST_ERROR 2 -#define ISCSI_REASON_DATA_SNACK_REJECT 3 -#define ISCSI_REASON_PROTOCOL_ERROR 4 -#define ISCSI_REASON_CMD_NOT_SUPPORTED 5 -#define ISCSI_REASON_IMM_CMD_REJECT 6 -#define ISCSI_REASON_TASK_IN_PROGRESS 7 -#define ISCSI_REASON_INVALID_SNACK 8 -#define ISCSI_REASON_BOOKMARK_INVALID 9 -#define ISCSI_REASON_BOOKMARK_NO_RESOURCES 10 -#define ISCSI_REASON_NEGOTIATION_RESET 11 +#define ISCSI_REASON_CMD_BEFORE_LOGIN 1 +#define ISCSI_REASON_DATA_DIGEST_ERROR 0x02 +#define ISCSI_REASON_DATA_SNACK_REJECT 0x03 +#define ISCSI_REASON_PROTOCOL_ERROR 0x04 +#define ISCSI_REASON_CMD_NOT_SUPPORTED 0x05 +#define ISCSI_REASON_IMM_CMD_REJECT 0x06 +#define ISCSI_REASON_TASK_IN_PROGRESS 0x07 +#define ISCSI_REASON_INVALID_SNACK 0x08 +#define ISCSI_REASON_INVALID_PDU_FIELD 0x09 +#define ISCSI_REASON_OUT_OF_RESOURCES 0x0a +#define ISCSI_REASON_NEGOTIATION_RESET 0x0b +#define ISCSI_REASON_WAINTING_FOR_LOGOUT 0x0c /* Max. number of Key=Value pairs in a text message */ #define MAX_KEY_VALUE_PAIRS 8192 diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c index e7d4c11..634e0d1 100644 --- a/usr/iscsi/iscsid.c +++ b/usr/iscsi/iscsid.c @@ -593,6 +593,26 @@ static int cmnd_exec_auth(struct iscsi_connection *conn) return res; } +static void cmnd_reject(struct iscsi_connection *conn, uint8_t reason) +{ + struct iscsi_reject *rsp = (struct iscsi_reject *)&conn->rsp.bhs; + + memset(rsp, 0, BHS_SIZE); + + rsp->opcode = ISCSI_OP_REJECT; + rsp->reason = reason; + rsp->ffffffff = ISCSI_RESERVED_TAG; + rsp->flags = ISCSI_FLAG_CMD_FINAL; + + rsp->statsn = cpu_to_be32(conn->stat_sn++); + rsp->exp_cmdsn = cpu_to_be32(conn->exp_cmd_sn); + rsp->max_cmdsn = cpu_to_be32(conn->max_cmd_sn); + + conn->rsp.data = conn->rsp_buffer; + conn->rsp.datasize = BHS_SIZE; + memcpy(conn->rsp.data, &conn->req.bhs, BHS_SIZE); +} + static void cmnd_exec_login(struct iscsi_connection *conn) { struct iscsi_login *req = (struct iscsi_login *)&conn->req.bhs; @@ -602,7 +622,8 @@ static void cmnd_exec_login(struct iscsi_connection *conn) memset(rsp, 0, BHS_SIZE); if ((req->opcode & ISCSI_OPCODE_MASK) != ISCSI_OP_LOGIN || !(req->opcode & ISCSI_OP_IMMEDIATE)) { - /* reject */ + cmnd_reject(conn, ISCSI_REASON_PROTOCOL_ERROR); + return; } rsp->opcode = ISCSI_OP_LOGIN_RSP; @@ -844,7 +865,7 @@ static void cmnd_exec_text(struct iscsi_connection *conn) } else conn->ttt = ISCSI_RESERVED_TAG; } else if (!conn->text_datasize || conn->ttt != be32_to_cpu(req->ttt)) { - /* reject */ + cmnd_reject(conn, ISCSI_REASON_INVALID_PDU_FIELD); return; } @@ -902,7 +923,7 @@ static int cmnd_execute(struct iscsi_connection *conn) hton24(conn->rsp.bhs.dlength, conn->rsp.datasize); break; default: - /* reject */ + cmnd_reject(conn, ISCSI_REASON_CMD_NOT_SUPPORTED); res = 1; break; } -- 1.5.6.5 -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html