From 325360789e03812cc75e46f748502d6c287404c4 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Tue, 30 Apr 2013 18:46:26 -0700 Subject: [PATCH] TEST: Improve the test for cmdsn too high with more documentation and verify that the target did ignore the command and the session is still good. --- test-tool/test_iscsi_cmdsn_toohigh.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test-tool/test_iscsi_cmdsn_toohigh.c b/test-tool/test_iscsi_cmdsn_toohigh.c index 193a68f..70e3ea1 100644 --- a/test-tool/test_iscsi_cmdsn_toohigh.c +++ b/test-tool/test_iscsi_cmdsn_toohigh.c @@ -28,11 +28,17 @@ static int change_cmdsn; static int my_iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu) { + static uint32_t old_cmdsn; + switch (change_cmdsn) { case 1: + old_cmdsn = *(uint32_t *)&pdu->outdata.data[24]; /* change the cmdsn so it becomes too big */ *(uint32_t *)&pdu->outdata.data[24] = htonl(iscsi->maxcmdsn + 1); break; + case 2: + *(uint32_t *)&pdu->outdata.data[24] = old_cmdsn; + break; } change_cmdsn = 0; @@ -47,8 +53,8 @@ void test_iscsi_cmdsn_toohigh(void) logging(LOG_VERBOSE, "Test sending invalid iSCSI CMDSN"); logging(LOG_VERBOSE, "CMDSN MUST be in the range EXPCMDSN and MAXCMDSN"); - logging(LOG_VERBOSE, "Test that a CMDSN > MAXCMDSN is an error"); - logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == MAXCMDSN+1"); + logging(LOG_VERBOSE, "RFC3720:3.2.2.1 CMDSN > MAXCMDSN must be silently ignored by the target"); + logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == MAXCMDSN+1. Should be ignored by the target."); iscsic->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; iscsic->target_max_recv_data_segment_length = block_size; @@ -62,4 +68,18 @@ void test_iscsi_cmdsn_toohigh(void) ret = testunitready(iscsic, tgt_lun); CU_ASSERT_EQUAL(ret, -1); + if (ret == -1) { + logging(LOG_VERBOSE, "[SUCCESS] We did not receive a reply"); + } else { + logging(LOG_VERBOSE, "[FAILURE] We got a response from the target but SMDSN was outside of the window."); + } + + + + iscsi_set_noautoreconnect(iscsic, 0); + logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN. should work again"); + change_cmdsn = 2; + ret = testunitready(iscsic, tgt_lun); + CU_ASSERT_EQUAL(ret, 0); + }