From d8946c45480b9647a00a67aac28149dede2520cb Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Tue, 17 Sep 2019 12:59:56 +0200 Subject: [PATCH] test-tool: replace some manual PDU tweaks with helper calls For now this only changes iSCSIDataSnInvalid to use iscsi_pdu_set_datasn() instead of scsi_set_uint32(). iSCSICmdSnTooHigh/Low changes should also be possible, as noted, but haven't been converted yet. Signed-off-by: David Disseldorp --- test-tool/test_iscsi_cmdsn_toohigh.c | 9 ++++++--- test-tool/test_iscsi_cmdsn_toolow.c | 9 ++++++--- test-tool/test_iscsi_datasn_invalid.c | 8 ++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/test-tool/test_iscsi_cmdsn_toohigh.c b/test-tool/test_iscsi_cmdsn_toohigh.c index 19c8b91..0bffd52 100644 --- a/test-tool/test_iscsi_cmdsn_toohigh.c +++ b/test-tool/test_iscsi_cmdsn_toohigh.c @@ -31,7 +31,10 @@ static int my_iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu { switch (change_cmdsn) { case 1: - /* change the cmdsn so it becomes too big */ + /* + * change the cmdsn so it becomes too big. TODO: use + * iscsi_pdu_set_cmdsn(), which also changes pdu->cmdsn? + */ scsi_set_uint32(&pdu->outdata.data[24], iscsi->maxcmdsn + 1); /* fudge the cmdsn value back to where it should be if this * pdu is ignored. @@ -40,12 +43,12 @@ static int my_iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu break; } - change_cmdsn = 0; + change_cmdsn = 0; return iscsi_drv_orig.queue_pdu(iscsi, pdu); } void test_iscsi_cmdsn_toohigh(void) -{ +{ int ret; logging(LOG_VERBOSE, LOG_BLANK_LINE); diff --git a/test-tool/test_iscsi_cmdsn_toolow.c b/test-tool/test_iscsi_cmdsn_toolow.c index 23b93c3..d16b161 100644 --- a/test-tool/test_iscsi_cmdsn_toolow.c +++ b/test-tool/test_iscsi_cmdsn_toolow.c @@ -31,7 +31,10 @@ static int my_iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu { switch (change_cmdsn) { case 1: - /* change the cmdsn so it becomes too big */ + /* + * change the cmdsn so it becomes too low. TODO: use + * iscsi_pdu_set_cmdsn(), which also changes pdu->cmdsn? + */ scsi_set_uint32(&pdu->outdata.data[24], iscsi->expcmdsn - 1); /* fudge the cmdsn value back to where it should be if this * pdu is ignored. @@ -40,12 +43,12 @@ static int my_iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu break; } - change_cmdsn = 0; + change_cmdsn = 0; return iscsi_drv_orig.queue_pdu(iscsi, pdu); } void test_iscsi_cmdsn_toolow(void) -{ +{ int ret; logging(LOG_VERBOSE, LOG_BLANK_LINE); diff --git a/test-tool/test_iscsi_datasn_invalid.c b/test-tool/test_iscsi_datasn_invalid.c index c25631a..2698885 100644 --- a/test-tool/test_iscsi_datasn_invalid.c +++ b/test-tool/test_iscsi_datasn_invalid.c @@ -37,20 +37,20 @@ static int my_iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu switch (change_datasn) { case 1: /* change DataSN to 0 */ - scsi_set_uint32(&pdu->outdata.data[36], 0); + iscsi_pdu_set_datasn(pdu, 0); break; case 2: /* change DataSN to 27 */ - scsi_set_uint32(&pdu->outdata.data[36], 27); + iscsi_pdu_set_datasn(pdu, 27); break; case 3: /* change DataSN to -1 */ - scsi_set_uint32(&pdu->outdata.data[36], -1); + iscsi_pdu_set_datasn(pdu, -1); break; case 4: /* change DataSN from (0,1) to (1,0) */ datasn = scsi_get_uint32(&pdu->outdata.data[36]); - scsi_set_uint32(&pdu->outdata.data[36], 1 - datasn); + iscsi_pdu_set_datasn(pdu, 1 - datasn); break; } out: