2246 Commits

Author SHA1 Message Date
Bart Van Assche
fddacc0600 lib/libiscsi.syms: Sort alphabetically 2021-07-17 21:34:46 -07:00
Bart Van Assche
8b4670db3e ci: First phase of adding MingW support 2021-07-17 21:06:19 -07:00
Bart Van Assche
cb4489776b configure.ac: Run autoupdate 2021-07-17 20:59:53 -07:00
Bart Van Assche
1e545eedb2 README.md: Update
Change the reference to the 'src' directory into a reference to the 'utils'
directory since commit c07779cfa7 ("AUTOTOOLS: Add a Makefile.am for the
iscsi-* utilities") renamed the 'src' directory into 'utils'.

Document the purpose of the test-tool directory.

Fix the link to the release tarballs.
2021-07-17 19:35:18 -07:00
Bart Van Assche
c9fd0743bc README: Rename into README.md
Additionally, restrict the contents of README.md to 80 columns.
2021-07-17 19:35:17 -07:00
Bart Van Assche
b446ab3188 ci: Switch from Travis to AppVeyor
Since June 15th, 2021, the building on travis-ci.org is ceased. Hence switch
to AppVeyor.
2021-07-16 21:31:50 -07:00
Bart Van Assche
c49461e4b7 test-tool: Do not use empty initializers
Empty initializers are a GNU extension that is not supported by older
versions of gcc.

Fixes: https://github.com/sahlberg/libiscsi/issues/356
2021-06-24 20:07:54 -07:00
Bart Van Assche
70759869ff Port to MinGW
Compile-tested only.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-05-23 13:23:52 -07:00
Bart Van Assche
ca9c585ef6 win32/win32_compat.c: Reformat this file
This file has been reformatted with clang-format --style=file and the Linux
kernel .clang-format style file.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-05-23 13:23:52 -07:00
Bart Van Assche
2a5a0b3291 Enable -Wno-unused-parameter
Instead of adding __attribute__((unused)) to unused arguments, add the
-Wno-unused-parameter compiler flag.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-05-23 13:23:41 -07:00
Bart Van Assche
ea6b2282d4 Use __attribute__((format(printf, ...))) directly
Instead of defining the macro _R_(), define __attribute__() as a macro for
compilers that do not support __attribute__(), namely Microsoft Visual
Studio.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-05-23 11:52:40 -07:00
Bart Van Assche
4ea2bc6acb Merge pull request #352 from orbea/automake
Makefile.am improvements
2021-05-23 09:22:07 -07:00
orbea
c437afa825 build: Add -no-undefined where missing
Signed-off-by: orbea <orbea@riseup.net>
2021-05-22 19:32:12 -07:00
orbea
9649fe1ddc build: Correct usage of LIBADD and LDADD
Signed-off-by: orbea <orbea@riseup.net>
2021-05-22 19:31:52 -07:00
orbea
c547d2dc7f build: Remove bogus LDADD variables
Signed-off-by: orbea <orbea@riseup.net>
2021-05-22 19:31:50 -07:00
Bart Van Assche
4072e608c1 Merge pull request #351 from concatime/patch-1
Include header <strings.h> for strncasecmp()
2021-05-03 07:56:00 -07:00
Issam Maghni
d08547f38a Add header <strings.h> for strncasecmp 2021-05-03 03:45:44 +00:00
Bart Van Assche
f87a5adaa0 test-tool: Change command_is_implemented from a global variable into an argument
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-02-08 19:01:31 -08:00
Bart Van Assche
c7a9f51d23 test-tool: Move a logging statement into write_residuals_test()
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-02-08 17:55:19 -08:00
Bart Van Assche
a21065cf71 test-tool: Add default clauses in recently modified switch statements
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-02-08 17:50:46 -08:00
Bart Van Assche
0c304f0c3c test-tool, residuals: Rename struct residuals_test_data members
Bring the names of these struture members closer to the names used in the
SCSI and iSCSI standards.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-02-08 17:50:38 -08:00
Bart Van Assche
88a46a03d3 Merge pull request #345 from nastya-nizharadze/residuals-tests-fix2
Improve WriteResidual tests
2021-02-08 17:13:11 -08:00
Anastasia Kovaleva
1b7d1743ae test-tool: Add overwrite check for all test cases
Check if the residual data does not owerwrite existing data blocks has now
been added for all testing data to improve the uniformity of test runs,
increase test readability and remove the duplicate testing data records.
2021-02-08 15:28:26 +03:00
Anastasia Kovaleva
e9bf7c2d05 test-tool: Change write residuals tests overwrite check according to FCP-4
According to FCP-4 there are several possibilities for target to react on
incorrect data length field value in CDB:

a) process the command normally except that data beyond the FCP_DL count
shall not be requested or transferred;

b) transfer no data and return CHECK CONDITION status with the sense key
set to ILLEGAL REQUEST and the additional sense code set to
INVALID FIELD IN COMMAND INFORMATION UNIT;

Add check to support the second one and accept no data write.
2021-02-08 15:23:55 +03:00
Anastasia Kovaleva
2e8c571955 test-tool: Refactoring residuals write tests
Looking at test_write10_residuals.c, test_write12_residuals.c and
test_write16_residuals.c tests the similarity of the testing scenario
can be found. There are several EDTL and SPDTL combinations which are
the same for different length write command tests. They form the core
of testing scenario of these commands. There aren't so much differences
in the way of testing these combinations itself either. It is possible
to move the main parameters describing the testing scenario into a
separate structure and move the scenario itself into a separate function.
It will increase the readability and reduce the duplicate code of these tests.
2021-02-08 15:23:49 +03:00
Anastasia Kovaleva
34fd477ede test-tool: Allow CHECK CONDITION in response to overflow/underflow
According to the RFC 7143 11.4.5.1:
"Targets may set the residual count,and initiators may use
 it when the response code is Command Completed at Target (even if the
 status returned is not GOOD)."

Therefore valid retuned status may be not only GOOD. Also this check:
task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT
would make Underflow/Overflow response universal for FC/ISCSI.
2021-02-02 11:46:27 +03:00
Bart Van Assche
a2fa59bef0 .travis.yml: Multiple changes
Install the xsltproc package, remove the deprecated 'sudo' keyword and
specify the Linux distribution explicitly.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-01-24 16:50:26 -08:00
Bart Van Assche
10da1d269a Merge pull request #349 from ddiss/report_luns
test-tool: add simple REPORT LUNS test
2021-01-22 19:25:49 -08:00
David Disseldorp
88a6060c7a test-tool: add simple REPORT LUNS test
Check for duplicate LUN entries in the REPORT LUNS response.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2021-01-22 21:27:18 +01:00
Bart Van Assche
51313c7912 Merge pull request #348 from vcunat/p/32bit-formt
init: Fix Wformat on 32-bit platforms
2021-01-21 20:35:06 -08:00
Vladimír Čunát
7f97ac0e4c init: fix Wformat on 32-bit platforms 2021-01-21 10:29:57 +01:00
Bart Van Assche
a8fcd18850 Revert "specify number of blocks in write_same command"
As reported by Sitsofe Wheeler, the WRITE SAME commands with zero blocks are
only issued if WSNZ == 0. WSNZ == 0 means that zero in the NUMBER OF LOGICAL
BLOCKS field means that all logical blocks until the end are affected. In
other words, the original code was fine. Hence revert commit dfff7e9d16.

Reported-by: Sitsofe Wheeler <sitsofe@yahoo.com>
2020-12-17 13:58:13 -08:00
Bart Van Assche
72dd7beb1b Merge pull request #347 from bytedance/fix_iser_sigsegv_v2
Fix iSER segmentation faults
2020-11-08 07:29:17 -08:00
Hou Pu
03fa3f627c iser: fix segmentation fault when task management pdu is received
As iser_pdu->desc->data_dir is not initialised when sending a PDU.
The value remains what it was when it was used last time. Thus
a PDU could be considered to have data if it previously had and
might cause segmentation fault.

For example if a pdu is a reset task management task with no data
to transfer and the pdu is previously used as a read task. Thus
it would cause fault like below:

> struct scsi_iovector *iovector_in = &task->iovector_in;

0  0x00007ffff7bcb2d1 in iser_rcv_completion (rx_desc=0x555555b79e48, iser_conn=0x555555b573a0) at iser.c:1349
1  0x00007ffff7bcb53e in iser_handle_wc (wc=0x7fffffffdc00, iser_conn=0x555555b573a0) at iser.c:1426
2  0x00007ffff7bcb685 in cq_event_handler (iser_conn=0x555555b573a0) at iser.c:1468
3  0x00007ffff7bcb81b in cq_handle (iser_conn=0x555555b573a0) at iser.c:1516
4  0x00007ffff7bc8b28 in iscsi_iser_service (iscsi=0x555555b58710, revents=1) at iser.c:118
5  0x00007ffff7bc3862 in iscsi_service (iscsi=0x555555b58710, revents=1) at socket.c:1016
6  0x00007ffff7bc3f6c in event_loop (iscsi=0x555555b58710, state=0x7fffffffe000) at sync.c:71
7  0x00007ffff7bc4605 in iscsi_task_mgmt_sync (iscsi=0x555555b58710, lun=0, function=ISCSI_TM_LUN_RESET, ritt=4294967295, rcmdsn=0) at sync.c:281
8  0x00007ffff7bc46cf in iscsi_task_mgmt_lun_reset_sync (iscsi=0x555555b58710, lun=0) at sync.c:312
9  0x000055555555500d in iscsi_lun_reset_sync (iscsi=0x555555b58710) at iscsiclient_lun_reset.c:34
10 0x0000555555555680 in main (argc=7, argv=0x7fffffffe1c8) at iscsiclient_lun_reset.c:211

Signed-off-by: Hou Pu <houpu@bytedance.com>
2020-11-08 15:45:00 +08:00
Hou Pu
ed90d56579 iser: fix segmentation fault when async message pdu is received
The target sometimes sends a logout request to libiscsi
in case it is going down or for some other reason.
The opcode of such a request is ISCSI_PDU_ASYNC_MSG.

On receiving these kinds of PDU, there is no related pdu on the
list of iscsi->waitpdu. Just skip finding them from iscsi->waitpdu.
Or segment fault might happen.

Also rename nop_target label to no_waitpdu to be more clear.

Signed-off-by: Hou Pu <houpu@bytedance.com>
2020-11-08 15:35:06 +08:00
Bart Van Assche
bc83b0ddb0 Merge pull request #344 from ddiss/compareandwrite_miscompare_sense
test-tool: check compare and write miscompare sense information
2020-10-23 19:19:12 -07:00
David Disseldorp
957cc96232 test-tool: add COMPARE AND WRITE MiscompareSense test
This test checks regular sense/ascq values on miscompare as well as
the Information sense field, which should be set as follows:
  sense key set to MISCOMPARE and the additional sense code set to
  MISCOMPARE DURING VERIFY OPERATION. In the sense data (see 4.18 and
  SPC-5) the offset from the start of the Data-Out Buffer to the first
  byte of data that was not equal shall be reported in the INFORMATION
  field.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-10-19 14:54:58 +02:00
David Disseldorp
53c58f8aea lib: parse Information fixed sense field
This field is documented in SPC-5 (r17 4.4.3). Unlike the descriptor
type, the fixed Information field is four bytes wide.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-10-19 14:54:58 +02:00
David Disseldorp
6eb4b7b6e5 lib: parse Information sense descriptor type
The Information descriptor type is defined in SPC-5 (r17 4.4.2.2) and
may be used to provide the data offset on COMPARE_AND_WRITE miscompare.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-10-19 14:54:18 +02:00
David Disseldorp
02b9b01fa1 lib: check length for sense key specific sense data descriptors
Explicitly check that the sense data descriptor ADDITIONAL LENGTH field
matches the expected value for sense key specific sense data
descriptors.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-10-19 14:37:13 +02:00
David Disseldorp
34a632a04e lib: drop generic sense data descriptor VALID check
According to SPC-5 (r17), the sense data descriptor format follows:
byte	field
----	-----
0:	DESCRIPTOR TYPE
1:	ADDITIONAL LENGTH
2-n:	Sense data descriptor specific

The VALID bit is a sense data descriptor specific flag, and is not
present in the only sense data descriptor supported by libiscsi -
Sense key specific sense data descriptors.
Drop the generic VALID bit check, in preparation for handling it on
a sense data descriptor specific basis.

Suggested-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-10-19 14:23:12 +02:00
Bart Van Assche
971bac8cfb Merge pull request #343 from almilos/fix-sbc3-check
test-tool: add version descriptor checks for more SBC-3 versions
2020-09-11 14:57:12 -07:00
Aleksandr Miloserdov
f342056a52 test-tool: add version descriptor checks for more SBC-3 versions
If device claims SBC-3 version in its version descriptors it won't be marked as SBC-3 compliant.

This commit adds checks for:
* SBC-3 T10/BSR INCITS 514 revision 35
* SBC-3 T10/BSR INCITS 514 revision 36
* SBC-3 ANSI INCITS 514-2014
2020-09-11 13:26:26 +03:00
Bart Van Assche
2a34e8fe1e Merge pull request #342 from heroin-moose/fix-iscsi-cmdsn-tests
test-tool: Fix CmdSN tests
2020-09-03 17:14:06 -07:00
Consus
859070854d test-tool: Fix CmdSN tests
After commit 10868c491d CmdSN tests no
longer work because iscsi->cmdsn is incremented during the second test
phase (sending "good" TUR after "bad" TUR), so the resulting CmdSN is
not ExpCmdSN, but ExpCmdSN + 1 that is not acknowledged by the target.
This commit fixes the issue by setting iscsi->cmdsn to iscsi->expcmdsn - 1.

Affected tests:

 * iSCSI.iSCSIcmdsn.iSCSICmdSnTooLow
 * iSCSI.iSCSIcmdsn.iSCSICmdSnTooHigh
2020-09-03 09:56:52 +03:00
Dharmesh Shah
5553d6bddf test-tool/test_async_lu_reset_simple: Move an assert statement
In the test iSCSI.iSCSITMF.LUNResetSimpleAsync
CU_ASSERT_EQUAL(reconnect_succeeded, 1) must be called after the async
TMF command completes. Hence move that assert into the TMF completion
callback.

This patch fixes a race condition.

[bvanassche: edited commit message]
2020-09-01 13:37:20 -07:00
Bart Van Assche
b5cd42e103 Remove an unused function from the iSER code
This was detected by clang.

Fixes: 68ce3363aa ("iser: dynamic memory region allocator")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-08-18 20:03:53 -07:00
Bart Van Assche
17fd81a69d Merge pull request #339 from ddiss/async_logout_during_write
test-tool: Add LogoutDuringIOAsync
2020-08-18 19:06:26 -07:00
David Disseldorp
54b3dcaa30 test-tool: add LogoutDuringIOAsync test case
This attempts to reproduce upstream LIO reports of a use after free bug
when logout occurs alongside concurrent I/O.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-08-18 17:12:28 +02:00
David Disseldorp
4080c09839 test-tool: rename async write dispatch/complete counters
Add an io_ prefix, to differentiate between I/O and future iSCSI Logout
request tracking.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-08-18 16:43:54 +02:00