189 Commits

Author SHA1 Message Date
Anatoliy Glagolev
19d05ab7a7 RTPG support
Implementing support of the Report Target Port Groups command.

Tested on Ubuntu against Pure Storage Flash Array
using designated unit tests and new iscsi-rtpg utility

./iscsi-rtpg  -i iqn.2005-03.org.open-iscsi:6feb2db21ea iscsi://192.168.1.12/iqn.2010-06.com.purestorage:flasharray.4e8d52d82e4b2c0f/1
RTPG retrieved 2 groups
Group 0x0000: preferred 0, format 0x00, ALUA state ACTIVE-OPTIMIZED,flags 0x8f, status code 0x02, port count 65
Ports: [ 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf 0x10 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4a 0x4b 0x4c
0x4d 0x4e 0x4f 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5a 0x5b 0x5c 0x5d 0x5e 0x5f 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67
0x68 0x69 0x6a 0x6b 0x6c 0x6d 0x6e 0x6f 0x70 0x71]
Group 0x0001: preferred 0, format 0x00, ALUA state ACTIVE-OPTIMIZED,flags 0x8f, status code 0x02, port count 65
Ports: [ 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f 0x20 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7a
0x7b 0x7c 0x7d 0x7e 0x7f 0x80 0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90 0x91 0x92 0x93 0x94 0x95
0x96 0x97 0x98 0x99 0x9a 0x9b 0x9c 0x9d 0x9e 0x9f 0xa0 0xa1 0xa2]
2025-07-03 17:20:52 -06:00
Ronnie Sahlberg
91cc1e4197 Protect outqueue and waitpdu with a spinlock
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-04-26 08:56:16 +10:00
folkert van heusden
5fc2dcb88f A possible 'fix' for https://github.com/sahlberg/libiscsi/issues/415
This patch adds a timestamp before each logged line. That could help
correlating a logging to a network-trace. Because of offsets in time
between the tracer and the test and the DUT, this does not always help.
2024-02-14 00:44:26 +01:00
folkert van heusden
a51eafa90d Previously, 'task->status' was printed as decimal. In iscsi.h, the
values that are put into it are defined as hexadecimal. This is a bit
confusing (grepping through the code for 251658241 did not result in
anything while the hex variant f000001 resulted in SCSI_STATUS_ERROR).
2024-01-30 19:47:28 +01:00
folkert van heusden
abedc1848c Fix for https://github.com/sahlberg/libiscsi/issues/409
'ms->pages' was not checked for being NULL. This can happen when a
target does not return any pages.
2024-01-30 06:39:08 -08:00
Li Feng
97d2f681d7 iscsi-support: fix memory leak
If doesn't support the report_supported_opcodes, the task will not be
freed in REPORT_SUPPORTED_OPCODES.

Change-Id: I1e251eec518721fb35e51013621aa61865d4b46b
Signed-off-by: Li Feng <fengli@smartx.com>
2021-09-30 19:54:08 -07:00
Bart Van Assche
b781b21d50 test-tool, xcopy: Fix target descriptor handling
Fail the XCOPY tests if no appropriate target descriptor is available
instead of causing memory corruption or truncating the descriptor.
2021-09-05 20:00:02 -07:00
Consus
7258fbfd83 test-tool: Use block_size instead of hardcoded 512 bytes
This commit fixes some tests (like ProutReserve) on pure 4k devices.
2020-06-17 15:50:44 +03:00
Bart Van Assche
9fcdce3101 test-tool: Use asprintf() in sg_send_scsi_cmd()
Use asprintf() instead of snprintf() + strdup().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-15 10:40:00 -07:00
Bart Van Assche
b9effb556f test-tool: Fix a comment in sg_send_scsi_cmd()
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-14 11:50:57 -07:00
Bart Van Assche
6aa5acb659 test-tool: Split send_scsi_command()
This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-14 11:47:56 -07:00
David Disseldorp
c8992f45b1 test: add support for 0x0A type XCOPY segment descriptors
Type 0x0A segment descriptors provide a 32-bit wide number-of-bytes
field, allowing for much larger copy offloads with a single segment
descriptor.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-03-18 18:59:34 +01:00
David Disseldorp
da7c1c4b0a test: use spec defined XCOPY segment descriptor lengths
The SPC4r37 specification defines XCOPY Segment Descriptor lengths for
each SD type. The spec defined SD lengths don't account for the four SD
header bytes. To make it easier to match the spec to the implementation,
use the spec defined lengths in get_desc_len() with a four byte SD
header addition.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-03-18 00:49:36 +01:00
David Disseldorp
8dbf6e51e2 test: use scsi_set_uintX marshalling helpers for XCOPY
Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-03-18 00:49:36 +01:00
Bart Van Assche
3804f3c2e0 Remove the discard_const() macro
Declare dynamically allocated strings as 'char *' instead of 'const char *'.
Remove the discard_const() macro. Do not test whether or not a pointer is
NULL before calling free() because it is allowed to pass NULL to free().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-02-28 21:54:49 -08:00
Bart Van Assche
9d2493248b Use dynamic memory allocation instead of variable-length arrays
Since it is easy to trigger a stack overflow with variable-length arrays,
use dynamic memory allocation instead of VLAs. Add -Wvla to the compiler
options such that no new VLAs get introduced.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2019-11-09 13:39:34 -08:00
Bart Van Assche
2bbf7b5017 test-tool: If SG_IO fails, report why it failed
See also https://github.com/sahlberg/libiscsi/issues/302.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2019-10-31 14:16:56 -07:00
David Disseldorp
dd17293bcc test-tool: remove unused iscsi_queue_pdu() symbol overload
All users have now been changed to overload via the iscsi_ctx transport
callback, so the dlsym based overloading can now be dropped.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-16 19:29:52 +02:00
Tim Crawford
9347cfebf2 Replace file variables with .dir-locals.el
Signed-off-by: Tim Crawford <tcrawford@datto.com>
2019-02-21 11:54:02 -05:00
David Disseldorp
31ab1e1ac9 test-tool: add prin_read_keys() allocation_len parameter
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>
2018-05-31 23:08:39 +02:00
Bart Van Assche
ba8cac6b05 test-tool, check_result(): Make failure output more informative
If a SCSI command fails, report the SCSI status code.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
2018-03-02 14:02:18 -08:00
Sushil
0593ac20de 251_SCSI Executing with SCSI device only (no ISCSI URL) ProutRegister test case failed
<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.
2017-11-09 06:15:06 +10:00
Ronnie Sahlberg
fb45f0343e Fix another compiler warning
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>
2017-06-03 11:33:51 -07:00
Ronnie Sahlberg
854e37aab7 Fix compiler warning/error under gcc7
Gcc7 complains about falling through from the previous case to the default arm

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-03 11:20:20 -07:00
Ronnie Sahlberg
8c9519b145 TESTS: Setup and use iovectors for ALL data transfers in send_scsi_command
We need to use iovectors for iSER to work as it requires that the vectors
are attached to the task before we queue the task.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-11-15 18:07:23 -08:00
Ronnie Sahlberg
39001203b7 TESTS: simple support for READDEFECTDATA10/12
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-09-22 22:43:16 -07:00
Ronnie Sahlberg
df1dc08eb7 TESTS: cleanup and remove noise warnings for iscsi cmdsn tests
The iscsi cmdsn tests are noisy and generate a lot of [FAILURE]
warnings for things that are expected.
Fix this by do the plumbing to allow using a EXPECT_STATUS_TIMEOUT
for commands we expect will never be replied to and will thus time out.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-07-11 20:50:47 -07:00
David Disseldorp
bfd614053e test-tool: add test_get_clock_sec() helper
Useful for test IO timeouts.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2016-03-22 21:19:59 +01:00
Ronnie Sahlberg
c5bc0a49b0 Tests: Fix the retry loop for the reserve6 helpers.
We should exit the loop once we have a command that is NOT
aborted with unit attention.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-23 21:34:34 -08:00
Ronnie Sahlberg
8a44851128 Tests: Add a helper for the all_zero checker
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-23 19:26:15 -08:00
Ronnie Sahlberg
b4320bd76c Tests: convert tabs to 8 spaces
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-21 16:17:18 -08:00
Ronnie Sahlberg
5a80c7b581 Fix some clang warnings
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-21 16:13:53 -08:00
Ronnie Sahlberg
f88bcf61cc Tests: Create a global scratch buffer and avoid allocating memory in the tests
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-21 15:17:43 -08:00
Ronnie Sahlberg
99a5f99527 Add some emacs defaults. Tabs are 8 spaces.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-18 21:34:43 -08:00
Bart Van Assche
be9b803334 test-tool: Avoid that using receive_copy_results() triggers a use-after-free
Move the scsi_free_scsi_task() call from receive_copy_results() to the
callers of this function to avoid that accessing the unmarshalled data
triggers a use-after-free.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-12-24 10:38:38 -08:00
Ronnie Sahlberg
5532325042 Test-tool: call iscsi_service on MP devices once every second so we respond to NOP
The test tool is simplistic and uses the synchronous API. In this API
we will only poll() the socket and process events during the lifetime of any
iscsi_*_sync() calls.

A problem with this approach arises with multipath tests. When iscsi-test-cu
is used with multiple devices we will first open a session for each
multipath leg, but then as most tests are only using the first device we end
up with creating secondary sessions we don't do any iscsi_*_sync() calls on
for very long times. If a target is set up to send NOPs on these
secondary paths it will not get any responses and eventually tear down the
connection.

To avoid this, try to make sure we service any secondary paths we have
created by calling iscsi_service(POLLIN|POLLOUT) every few seconds
to make sure we do service and respond to any NOPs.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-12-15 21:55:03 -08:00
Bart Van Assche
2d412530c1 test-tool: Move all_zeroes() helper function to iscsi-support.c
This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-10-07 07:44:18 -07:00
David Disseldorp
a1d11eb0f9 test: move UA drain helper function into iscsi-support
test_iscsi_tur_until_good() dispatches TUR requests until the target has
cleared all UAs for the given sd, or the maximum number of retries is
reached.
This helper function is useful for any test that needs to deal with UAs
(e.g. PRs), so should be moved out into common code.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-30 11:00:25 +02:00
David Disseldorp
760ae95d9c test: add prout_preempt() helper function
Issue a Persistent Reservation Out PREEMPT request, with keys and type
provided.
PREEMPT allows for the removal of registrations, and replacement of
reservations.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-30 11:00:25 +02:00
David Disseldorp
9c524b37fa test: add prin_report_caps() helper function
Issue a Persistent Reservation In REPORT CAPABILITIES request and parse
the response. Callers can obtain the unmarshalled response data via the
_rcaps parameter.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-30 11:00:19 +02:00
David Disseldorp
a90e5a3d4c test/iscsi-support: PR Out CLEAR helper function
Add a helper function to dispatch Persistent Reserve Out requests with
CLEAR service action.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-18 18:06:19 +02:00
Ronnie Sahlberg
e59d2ce1d3 TESTS: ifdef out iov_tot_len if we do not have SG_IO
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-12 12:43:07 -07:00
Ronnie Sahlberg
fd55600d39 TESTS: Print correct sense data when a command fail that were expected to succeed 2015-09-10 16:45:24 -07:00
Ronnie Sahlberg
6c16f9e322 Add tests for WRITE_ATOMIC_16
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-08 10:17:15 -07:00
Ronnie Sahlberg
a6f7c06119 Add support and tests for ExtendedCopy and ReceiveCopyResults
From sushma.gurram@sandisk.com
Add support to libiscsi and tests for these two opcodes.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-08-02 12:57:21 -07:00
Ronnie Sahlberg
4518dfa43c Don't leak memory in the test helper for write16
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-08-02 12:16:58 -07:00
Adam Grare
838c35b693 test_modesense6_control_swp test: read current control before modeselect6
After checking if SWP can be changed the current control page has
to be read back before sending it to initiator with modeselect6.
2015-06-11 16:48:43 -04:00
Craig Rodrigues
1995298914 test_modesense6_control_swp: skip test if target cannot change swp
Signed-off-by: Vadim Finkelstein <vadim@pi-coral.com>
2015-06-03 18:54:29 +00:00
Ronnie Sahlberg
811c04f01a TESTS: read12/read16 change signature to return an optional task structure
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-12 20:25:04 -07:00
Bart Van Assche
52a57d26f2 test-tool: Improve reliability of status_is_invalid_opcode()
The test_report_supported_opcodes_one_command() sends SCSI commands
to the target for which the target has to reply with ILLEGAL REQUEST
/ INVALID FIELD IN CDB. Avoid that such a reply is misinterpret as
"command not supported" by checking the field offset in the sense
descriptor. See also patch "test tool: Detect unsupported opcodes
correctly" (commit ID fe9620092c).

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-27 19:18:41 -07:00