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>
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>
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>
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>
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>
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>
Extend struct scsi_sense with sense specific descriptor information,
introduce the function scsi_parse_sense_data() and let that function
parse the sense specific descriptor.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
I didn't set up the transfer length properly for the vectored SG_IO
support in the previous patch, which makes some implementations
of the ioctl unhappy. Fix this up per the spec.
Command like PERSISTENT RESERVE OUT fill out DATA OUT data in their
CDB setup routine, but the SG_IO code doesn't look at that, leading
to a segfault when issueing such commands. Fix this by copying over
some code from the iSCSI path.
Signed-off-by: Christoph Hellwig <hch@lst.de>
This allows all tests to properly work on /dev/sg nodes instead
of segfaulting when a test is written the iSCSI-specific APIs.
Signed-off-by: Christoph Hellwig <hch@lst.de>
The variable user in struct iscsi_url is a character array, not a pointer.
Therefore its address will never be NULL.
When libscsi is built using clang instead of gcc, those errors are reported:
iscsi-perf.c:256:17: error:
comparison of array 'iscsi_url->user' not equal to a null
pointer is always true [-Werror,-Wtautological-pointer-compare]
iscsi-dd.c:272:17: error:
comparison of array 'iscsi_url->user' not equal to a null
pointer is always true [-Werror,-Wtautological-pointer-compare]
iscsi-dd.c:331:17: error:
comparison of array 'iscsi_url->user' not equal to a null
pointer is always true [-Werror,-Wtautological-pointer-compare]
ld_iscsi.c:99:18: error:
comparison of array 'iscsi_url->user' not equal to a null
pointer is always true [-Werror,-Wtautological-pointer-compare]
Fix those errors and also similar code patterns in aros/iscsi-ls.c and
test-tool/iscsi-support.c.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
ascq is NULL if there are no ascqs provided for this failure mode.
Do not try to dereference the 0-th element in this array before checking
that the array has at least one element.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
There is no agreement among the T10 committee whether a SCSI target should
report "invalid opcode", "invalid field in CDB" or "invalid field in
parameter list" if the opcode consists of two bytes. Hence accept all three
sense codes for two-byte opcodes. For more information see also Frederick
Knight, RE: INVALID COMMAND OPERATION CODE, T10 Reflector, 16 May 2008
(http://t10.org/ftp/t10/t10r/2008/r0805167.htm).
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
A quote from SPC-4: "When using the MODE SENSE command, a
parameters saveable (PS) bit set to one indicates that the mode
page may be saved by the logical unit in a nonvolatile, vendor
specific location. A PS bit set to zero indicates that the device
server is not able to save the supported parameters. When using
the MODE SELECT command, the PS bit is reserved."
Hence clear the PS bit after having queried a mode page via MODE
SENSE and before changing it via MODE SELECT.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Add 0x2701/0x2702 to the list of valid ASCQ values we accept for devices
that are write protected.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
valgrind does not know that sense will be initialized by the ioctl
so we need to to it explicitely to keep it from warning us.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Create a wrapper for sending scsi_commands so that we can hide the
libiscsi function far away from the "opcode" helpers.
This means we only have a single place later to switch to a different
type of device, such as a SG_IO one.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>