This fixes some identation in iscsi_reconnect_cb() where whitespaces
were used instead of hard tabs.
Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
This test registers PR key and then sends a PR-In read-keys request with
an ALLOCATION LENGTH value that forces response truncation. Ensure that
the ADDITIONAL LENGTH is *not* modified as a result of the truncation.
This test currently passes against TGT but fails against LIO (fix
pending).
Signed-off-by: David Disseldorp <ddiss@suse.de>
When unmarshalling a SCSI_PERSISTENT_RESERVE_READ_KEYS response,
scsi_persistentreservein_datain_unmarshall() assumes that the ADDITIONAL
LENGTH field represents the number of keys packed in the key array.
This is incorrect as key array data buffer may be truncated while
ADDITIONAL LENGTH is left in tact, as per SPC5r17 4.2.5.6:
If the information being transferred to the Data-In Buffer includes
fields containing counts ..., then the contents of these fields shall
not be altered to reflect the truncation, if any, that results from an
insufficient ALLOCATION LENGTH value, unless the standard that
describes the Data-In Buffer format states otherwise.
Determine the number of keys returned based on the minimum of the
data-in length and the ADDITIONAL LENGTH value.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Accepting an Allocation Length parameter allows us to test for
truncation of response data, as per SPC5r17 4.2.5.6:
The device server shall terminate transfers to the Data-In Buffer when
the number of bytes or blocks specified by the ALLOCATION LENGTH field
have been transferred or when all available data have been
transferred, whichever is less.
With this change, all existing prin_read_keys() callers continue to use
same ALLOCATION LENGTH value as earlier (16K).
Signed-off-by: David Disseldorp <ddiss@suse.de>
The helper function -2 return paths already print this message, so the
duplicate in the caller can be dropped.
Signed-off-by: David Disseldorp <ddiss@suse.de>
The code was implicitly dependent on container_of from
inifiniband/verbs.h, however that's been removed in rdma-core
latest release:
ce0274acff
Define container_of locally if it's not already defined
Make sure that the end-of-LUN test happens at the end of the LUN instead
of at the start of the LUN.
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Since the argument num_blocks - i is passed as the LBA argument
to COMPAREANDWRITE(), avoid that a negative number is passed.
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Avoid that building with gcc 7 fails as follows:
iscsi-dd.c: In function 'cscd_ident_inq':
iscsi-dd.c:405:8: error: this statement may fall through [-Werror=implicit-fallthrough=]
if (prev_type <= desig->designator_type) {
^
iscsi-dd.c:409:4: note: here
default:
^~~~~~~
cc1: all warnings being treated as errors
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
2e947cc1de added logic to check that
targets missing zero block writesame support return INVALID_FIELD_IN_CDB
to such requests. However, this change incorrectly set the writesame
number_of_logical_blocks field to one.
Signed-off-by: David Disseldorp <ddiss@suse.de>
In our use at Datto, we have come across several issues related to the
automatic reconnect logic (mainly its interaction with POLLHUP). This
allows us to disable the functionality, at the expense of writing our
own reconnect logic.
Related: #241
Using WIN32 depends on the build environment defining the variable.
_WIN32 is a predefined MSVC macro and is always available.
Signed-off-by: Tim Crawford <crawfxrd@gmail.com>
The primary issue is that in MSVC 14.00 (VS2015) Microsoft added
snprintf as a function to the standard library and prevents users from
defining it to something else (typically, this was _snprintf). So, only
define it when using _MSC_VER < 1900.
Other changes are:
- Fix macro definition of dup2
- Add macro for getpid
- Add function definition for win32_dup
- Add missing EXTERNs
Signed-off-by: Tim Crawford <crawfxrd@gmail.com>
The set of sync connect calls use a stack variable to track the
connection status. This is ok because such calls block on event_poll()
until the connection is established. However, event_poll may return
early in case of errors (or timeout) while PDUs are still queued on the
context (and pointing to a local stack).
This cancels any pending PDUs before returning from sync connect calls.
Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
Introduce a helper exported from lib/pdu.c which cancels all pdus for a
given context. This patch eliminates repeated code from various other
files which have the same purpose. The only functional difference is
that the cancellation done from iscsi-command.c was (incorrectly) not
checking for iscsi->is_loggedin before issuing callbacks.
Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
<iscsi-url> parameter absent handled for SCSI devices.
* Verbose logging segfault fixed.
* For ioctl case, if reservation conflicts hits it is not considered as
test case failure.
There is something wrong with dup2 under win32 and I do not know win32
well enough to fix it, thus this workaround.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Since the data in the read buffer is not valid if READ10() failed,
only compare the data in the read buffer if READ10() succeeded.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Using any of the CU_ASSERT macros after a test has finished causes
the test tool to abort. This patch adds an iSCSI logout to two tests
to avoid that the test tool aborts e.g. as follows:
==11578== Process terminating with default action of signal 6 (SIGABRT)
==11578== at 0x54BB77F: raise (raise.c:58)
==11578== by 0x54BD379: abort (abort.c:89)
==11578== by 0x54B3B46: __assert_fail_base (assert.c:92)
==11578== by 0x54B3BF1: __assert_fail (assert.c:101)
==11578== by 0x504213E: CU_assertImplementation (in /usr/lib/x86_64-linux-gnu/libcunit.so.1.0.1)
==11578== by 0x16FA36: test_async_abort_cb (test_async_abort_simple.c:67)
==11578== by 0x5274B82: iscsi_process_task_mgmt_reply (task_mgmt.c:100)
==11578== by 0x525E226: iscsi_process_pdu (pdu.c:598)
==11578== by 0x526F2AA: iscsi_read_from_socket (socket.c:677)
==11578== by 0x5270015: iscsi_tcp_service (socket.c:963)
==11578== by 0x52700A5: iscsi_service (socket.c:980)
==11578== by 0x52707E1: event_loop (sync.c:69)
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Avoid that the test tool crashes due to a NULL pointer dereference
if unmarshalling the Data-In buffer fails.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
We do need a default: arm here as the switch is not supposed to deal with
all possible values for the enum.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Since the data in the read buffer is not valid if READ10() failed,
only compare the data in the read buffer if READ10() succeeded.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Using any of the CU_ASSERT macros after a test has finished causes
the test tool to abort. This patch adds an iSCSI logout to two tests
to avoid that the test tool aborts e.g. as follows:
==11578== Process terminating with default action of signal 6 (SIGABRT)
==11578== at 0x54BB77F: raise (raise.c:58)
==11578== by 0x54BD379: abort (abort.c:89)
==11578== by 0x54B3B46: __assert_fail_base (assert.c:92)
==11578== by 0x54B3BF1: __assert_fail (assert.c:101)
==11578== by 0x504213E: CU_assertImplementation (in /usr/lib/x86_64-linux-gnu/libcunit.so.1.0.1)
==11578== by 0x16FA36: test_async_abort_cb (test_async_abort_simple.c:67)
==11578== by 0x5274B82: iscsi_process_task_mgmt_reply (task_mgmt.c:100)
==11578== by 0x525E226: iscsi_process_pdu (pdu.c:598)
==11578== by 0x526F2AA: iscsi_read_from_socket (socket.c:677)
==11578== by 0x5270015: iscsi_tcp_service (socket.c:963)
==11578== by 0x52700A5: iscsi_service (socket.c:980)
==11578== by 0x52707E1: event_loop (sync.c:69)
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Avoid that the test tool crashes due to a NULL pointer dereference
if unmarshalling the Data-In buffer fails.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>