Commit Graph

2087 Commits

Author SHA1 Message Date
Bart Van Assche
3fe06e8563 ci: Add ci/install.bat
Move the MinGW package installation commands from ci/build.sh into
ci/install.sh.
2022-11-12 18:12:45 -08:00
Ronnie Sahlberg
505b2a0ab4 Merge pull request #387 from lgtm-migrator/codeql
Add CodeQL workflow for GitHub code scanning
2022-11-09 07:59:43 +10:00
LGTM Migrator
2229f42246 Add CodeQL workflow for GitHub code scanning 2022-11-08 13:08:20 +00:00
Li kunyu
6b520bee52 test-tool: remove a redundant semicolon
Signed-off-by: Li kunyu <kunyu@nfschina.com>
2022-10-08 20:34:36 -07:00
Bart Van Assche
51df0d0512 lib/scsi-lowlevel: Make the REPORT LUNS unmarshalling code more flexible
Instead of rejecting REPORT LUNS responses if the data buffer size exceeds
the LUN list size, truncate the data buffer.

Fixes: https://github.com/sahlberg/libiscsi/issues/385
2022-09-09 15:02:44 -07:00
sallyjunjun
1017435ca9 Fix segmentation fault problem.
When execute iscsi_task_mgmt_lun_reset_async function,
pdus are already removed from waitpdu list. In iscsi_service
function, this will call iscsi_process_pdu and release
pdu from waitpdu again, which cause segmentation fault.

Whether waitpud list is NULL should be checked here to avoid
the problem.

Signed-off-by: geruijun <geruijun@huawei.com>
2022-06-14 20:49:09 -07:00
geruijun
8ef5d8243b Check return value of scsi_malloc in order to
avoid dereferencing NULL return value.

Signed-off-by: geruijun <geruijun@huawei.com>
2022-06-10 19:44:16 -07:00
sallyjunjun
045c2387e7 fix iscsi-ls parameter parse
If invalid option is input with iscsi-ls,such as "iscsi-ls -a iscsi://", the command just stuck here and do not print useful information for the user to correct.
Fix this problem with getopt_long.
2022-06-07 19:19:39 -07:00
sallyjunjun
b087a09a0b iscsi-swp: handle setting of debug_level correctly
According to the man page and help info, --debug=integer can specify the
debug_level, while it would report following error:

iscsi-swp --debug=1
iscsi-swp: option '--debug' doesn't allow an argument
2022-05-31 15:12:49 -07:00
sallyjunjun
8592dc5883 Update iscsi-dd.c
add check after malloc to avoid referencing an illegal pointer
2022-05-31 15:12:49 -07:00
Ronnie Sahlberg
babb0c3d51 Merge pull request #375 from wenchao-hao/master
iscsi-inq: handle setting of debug_level correctly
2022-04-07 17:23:43 +10:00
Wenchao Hao
5e63853230 iscsi-inq: handle setting of debug_level correctly
According to the man page and help info, --debug=integer can specify the
debug_level, while it would report following error:

iscsi-inq --debug=2
iscsi-inq: option '--debug' doesn't allow an argument

It's because the iscsi-inq code did not handle this parameters
correctly. So here we just correct it.

Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
2022-04-06 10:28:23 +08:00
Sergey Samoylenko
fbfa387d9a Retain the immediate data param during login processing
If a test sets the use_immediate_data parameter to ISCSI_IMMEDIATE_DATA_NO
for the iSCSI context, then the test expects that a data associated with
the Write command to be sent in a separate PDU.

But if for execute the command it is necessary to login on a target then
the use_immediate_data was previously set, will be rewrite during
the processing of the Login Response packet.

This happen during the iSCSI.iSCSIdatasn.iSCSIDataSnInvalid
(test_iscsi_datasn_invalid.c) test:

    --> iSCSI 114 SCSI: Write(10) LUN: 0x01 (LBA: 0x00000064, Len: 1)
    <-- iSCSI 114 Ready To Transfer
    --> iSCSI 578 SCSI: Data Out LUN: 0x01 (Write(10) Request Data)

    --> iSCSI 550 Login Command
Here we lose use_immediate_data value for iSCSI session.
    <-- iSCSI 426 Login Response (Success)
    --> iSCSI 114 SCSI: Test Unit Ready LUN: 0x01
    <-- iSCSI 114 SCSI: Response LUN: 0x01 (Test Unit Ready) (Good)
And this Write command includes payload into iSCSI PDU packet, but should not do it.
    --> iSCSI 578 SCSI: Write(10) LUN: 0x01 (LBA: 0x00000064, Len: 1)SCSI: Data Out LUN: 0x01 (Write(10) Request Data)
    <-- iSCSI 114 SCSI: Response LUN: 0x01 (Write(10)) (Good)

    --> iSCSI 114 SCSI: Write(10) LUN: 0x01 (LBA: 0x00000064, Len: 2)
    <-- iSCSI 114 Ready To Transfer
    --> iSCSI 578 SCSI: Data Out LUN: 0x01 (Write(10) Request Data)
    --> iSCSI 626 SCSI: Data Out LUN: 0x01 (Write(10) Request Data)

Signed-off-by: Sergey Samoylenko <s.samoylenko@yadro.com>
2022-03-21 06:58:00 -07:00
Raphael Norwitz
2674070fb8 iscsi-command: Fix leak in iscsi_send_data_out
In iscsi_send_data_out() a PDU is allocated, but there is no error
handling logic to free it if the PDU cannot be queued.
iscsi_allocate_pdu() may allocate memory for the PDU. This memory may be
leaked if iscsi_queue_pdu() fails since there is no call to free it.

Orignally there was a free() call but it was removed as a part of a
cleanup adding checks for NULL pdu callbacks.

Fixes: 423b82efa4 ("pdu: check callback for NULL everywhere")
Signed-off-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
2022-03-03 12:58:08 -08:00
zhenwei pi
fb9c3f93ed iscsi-pr: add persistent reservation tool
iscsi-pr uses libiscsi to connect target and issues PR command.
In most cases, iscsi-pr use the same parameters as sg_persist(from sg3-utils).

For example, use iscsi-pr to dump keys by command:
  ~# ./utils/iscsi-pr --read-keys iscsi://192.168.122.44/iqn.2003-01.org.linux-iscsi.bytedance.x8664:sn.a6b7bff3d509/0 -i iqn.2005-03.org.open-iscsi:12345678
  PR generation=0x20, 19 registered reservation keys follow:
    0xabcd1234
    0xabcd
    0xabcd
    0xabc

A few command is not implemented in this patch, add them if necessary
in future.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2022-02-20 21:17:40 -08:00
John Levon
30dd7c6429 add iscsi_force_reconnect()
If a connection attempt is hung, then iscsi_reconnect() won't do anything. This
makes sense if we'd just re-try to connect to the same target, but if (for
example) login redirect might point us to a different, healthy, target, it
should be possible to restart the full connection process on request.

Signed-off-by: John Levon <john.levon@nutanix.com>
2022-01-17 13:14:49 -08:00
John Levon
314aa26576 add libiscsi.syms to .gitignore
This file is generated; add it to .gitignore.

Signed-off-by: John Levon <john.levon@nutanix.com>
2022-01-17 13:14:38 -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
d592e2e01e Merge pull request #364 from tianrenz2/fix-dist-make
Add some files into the dist tarball necessary for rpm generation
2021-09-12 15:06:42 -07:00
Tianren Zhang
2b8905b4f9 add README.md to dist tarball
README is required in rpm spec, but not included into the dist
tarball
2021-09-12 03:44:23 -04:00
Tianren Zhang
e31fe70fb5 add libiscsi.syms.in to dist tarball
libiscsi.syms.in is required for 'make libiscsi.syms'
2021-09-12 03:30:51 -04: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
Bart Van Assche
aa214feaf3 iser: Fix a compiler warning triggered by the container_of() definition
This patch fixes the following compiler warning:

iser.c:338:14: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'struct iser_pdu *' increases required alignment from 1 to 8 [-Werror,-Wcast-align]
                iser_pdu = container_of(pdu, struct iser_pdu, iscsi_pdu);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-09-05 20:00:02 -07:00
Bart Van Assche
5cbbc95c20 configure: Remove -Wno-strict-aliasing
Using -Wno-strict-aliasing is almost always wrong. If any code would be
introduced in the future that violates the strict aliasing rules, please
use -fno-strict-aliasing instead.
2021-09-05 20:00:02 -07:00
Bart Van Assche
3f9735b3a4 slist: Clean up the slist.h header file
Fix indentation, align backslashes, surround multiline macros with
do { } while (0) and remove the unused ISCSI_LIST_LENGTH() macro.
2021-09-05 20:00:02 -07:00
Li Feng
6b93325b39 slist: Make this header file compatible with C++
C++ requires explicit conversions from a void to a non-void pointer.

Signed-off-by: Li Feng <fengli@smartx.com>
[ bvanassche: edited commit message, removed casts and changed the declaration
  type ]
2021-09-05 20:00:02 -07:00
Bart Van Assche
c412ae0e1d scsi-lowlevel.h: Include <assert.h>
Checking whether static_assert() is defined must happen after <assert.h> has
been included. Hence include <assert.h>.
2021-09-05 20:00:02 -07:00
Simon Rowe
35dcf89599 examples/iscsi-dd: use stderr for all error text
Signed-off-by: Simon Rowe <simon.rowe@nutanix.com>
2021-09-05 20:00:02 -07:00
Simon Rowe
b3a30d995e examples/iscsi-dd: fix typos
Signed-off-by: Simon Rowe <simon.rowe@nutanix.com>
2021-09-05 20:00:02 -07:00
Bart Van Assche
d7bdd9690e ci: Add a github build action 2021-09-05 20:00:02 -07:00
Bart Van Assche
7d3d6f6242 Merge pull request #359 from ddiss/xcopy_large_fix_skip
test: fix ExtendedCopy.Large SKIPPED cases
2021-07-29 14:31:42 -07:00
David Disseldorp
73d541b00b test: fix ExtendedCopy.Large SKIPPED cases
CU_PASS() needs to be coupled with a return to actually skip the test.
Similarly, the CU_PASS message isn't printed, so a logging() call is
also needed here.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2021-07-29 17:39:39 +02:00
Bart Van Assche
3c977c573a Merge pull request #358 from zippy2/pkg_config_fixup
configure.ac: Quote argument to m4_esyscmd() properly
2021-07-27 08:03:41 -07:00
Michal Privoznik
07464ec0a3 configure.ac: Quote argument to m4_esyscmd() properly
In one of recent commits the argument passed to m4_esyscmd()
macro was switched to its unescaped version. This is not correct
because package version is then defined as "Version 1.19.0"
instead of just "1.19.0".

Fixes: cb4489776b
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-27 09:21:07 +02:00
Bart Van Assche
696ac1e948 Merge pull request #353 from Ser01x/master
Before running the SCSI.ReceiveCopyResults.CopyStatus test we should check that it is supported
2021-07-26 20:34:19 -07:00
Ser01x
e8c15866fa Fixed several code style problems 2021-07-26 09:24:54 +00:00
Ser01x
053c6db9e1 test-tool: check that ReceiveCopyResults is implemented
We check that the RECEIVE COPY STATUS(LID1) command is supported
by SCSI device before sending it.
2021-07-21 16:37:57 +00:00
Ser01x
1c3e2083c9 lib: init version for 8Fh VPD page
The third-party copy (8Fh) VPD page helps to check the capabilities
supported by the copy manager.
2021-07-21 16:28:16 +00:00
Bart Van Assche
2a65548f22 ci: Enable MinGW 2021-07-18 20:13:03 -07:00
Bart Van Assche
5e6f6ec5ed MinGW: Second step of porting to MinGW 2021-07-18 20:13:03 -07:00
Bart Van Assche
16f817bfba configure.ac: Use AC_CONFIG_HEADERS() instead of AC_CONFIG_HEADER()
AC_CONFIG_HEADER() is obsolete since autoconf 2.70.
2021-07-18 20:10:08 -07:00
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