TEST: Add test that invalid DATASN for DATAIN is detected as an error
Send a write containing two DATA-IN PDUs in a sequence but both PDUs have DATASN==0 This is an error and the target should react to this as an invalid command Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -15,22 +15,16 @@
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/types.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "iscsi.h"
|
||||
#include "iscsi-private.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test.h"
|
||||
|
||||
static int (*real_iscsi_queue_pdu)(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
|
||||
|
||||
static int change_cmdsn;
|
||||
|
||||
int iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
|
||||
static int my_iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
|
||||
{
|
||||
switch (change_cmdsn) {
|
||||
case 1:
|
||||
@@ -44,7 +38,6 @@ int iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
|
||||
}
|
||||
|
||||
change_cmdsn = 0;
|
||||
return real_iscsi_queue_pdu(iscsi, pdu);
|
||||
}
|
||||
|
||||
static void test_cb(struct iscsi_context *iscsi _U_, int status,
|
||||
@@ -73,8 +66,6 @@ int T1000_cmdsn_invalid(const char *initiator, const char *url, int data_loss, i
|
||||
unsigned char data[512 * 256];
|
||||
struct iscsi_async_state test_state;
|
||||
|
||||
real_iscsi_queue_pdu = dlsym(RTLD_NEXT, "iscsi_queue_pdu");
|
||||
|
||||
printf("1000_cmdsn_invalid:\n");
|
||||
printf("==================\n");
|
||||
if (show_info) {
|
||||
@@ -128,6 +119,7 @@ int T1000_cmdsn_invalid(const char *initiator, const char *url, int data_loss, i
|
||||
|
||||
iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
|
||||
iscsi->target_max_recv_data_segment_length = 512;
|
||||
local_iscsi_queue_pdu = my_iscsi_queue_pdu;
|
||||
|
||||
printf("Write 2 blocks with CMDSN > MAXCMDSN ... ");
|
||||
change_cmdsn = 1;
|
||||
@@ -200,6 +192,7 @@ test3:
|
||||
iscsi_set_noautoreconnect(iscsi, 0);
|
||||
|
||||
finished:
|
||||
local_iscsi_queue_pdu = NULL;
|
||||
iscsi_logout_sync(iscsi);
|
||||
iscsi_destroy_context(iscsi);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user