61 Commits

Author SHA1 Message Date
Duncan Overbruck
2e4231d1d8 use PRIu64 printf format for uint64_t 2026-02-04 20:12:19 +01:00
Anatoliy Glagolev
4c39ccc9fc fixup! RTPG support 2025-07-03 17:44:05 -06:00
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
Anatoliy Glagolev
e7c44b802f iscsi-inq: binary values in hex
While printing device identification information format
binary values as hex instead of ASCII characters.
2025-06-27 17:21:44 -06:00
Ronnie Sahlberg
95a0d98cfd Add support for CHAP using SHA1
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-01-04 00:59:02 +10:00
Michael Tokarev
6e0206c135 spelling fixes: eventhough, shoudl, asyncronous, maxium, implicity
These changes are carried in debian for a long time, some since 2016.
The last one (implicity) is new in 1.20.0.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2024-02-05 10:22:23 -08:00
zhenwei pi
2794079fef iscsi-discard: adapt block limits
The blocks may exceed the block limits offered by the target,
query unmap/write zero max blocks by inquiry
SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS command, than use a loop to do the
job.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2023-08-08 15:07:23 +08:00
zhenwei pi
45b274aec8 iscsi-md5sum: Add new tool
The new tool 'iscsi-md5sum' is used to calculate MD5 value of an iSCSI
target. This help users to verify data at range [LBA, Length).

For example, double-write on a RAID1 of 2 iSCSI targets, a daemon
process runs iscsi-md5sum to check data periodically.

Originally, we have to use several steps to achieve:
1, use iscsiadm to login.(root privilege required)
2, use dd(dd if=/dev/sdX of=/TMPPATH bs=4k count=LENGTH skip=LBA)
   to dump data. (root privilege required, additional disk space required)
3, use md5sum to calculate MD5 value
4, remove data.

Instead, a single command iscsi-md5sum without root privilege is enough.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2023-07-31 15:29:11 +08:00
zhenwei pi
d631b08c19 iscsi-discard: Add new tool
The new tool 'iscsi-discard' is used to excute unmap or write zeros
on an ISCSI target. The parameters look like the command 'blkdiscard'
(from util-linux).

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2023-07-21 18:15:45 +08:00
zhenwei pi
6e2c677553 utils: use strtol instead of atoi
HEX format is friendly to iSCSI utils, for example:
./iscsi-inq -e 0x1 -c 0xb1 iscsi://...

atoi supports decimal only, this example does not work.
Use strtol(nptr, NULL, 0) to auto-detect format, then this works fine.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2023-07-08 07:44:16 -07:00
zhenwei pi
2b9d5bdbad iscsi-perf: Add -h/--help
Add -h/--help to show usage without "Unrecognized option".

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2023-05-31 06:49:59 -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
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
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
Bart Van Assche
5e6f6ec5ed MinGW: Second step of porting to MinGW 2021-07-18 20:13:03 -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
orbea
c437afa825 build: Add -no-undefined where missing
Signed-off-by: orbea <orbea@riseup.net>
2021-05-22 19:32:12 -07:00
orbea
c547d2dc7f build: Remove bogus LDADD variables
Signed-off-by: orbea <orbea@riseup.net>
2021-05-22 19:31:50 -07:00
Issam Maghni
d08547f38a Add header <strings.h> for strncasecmp 2021-05-03 03:45:44 +00:00
Han Han
6db782bb0a iscsi-ls: Fix iser url scheme parsing
Libiscsi supports to parse two iscsi url schemes: 'iscsi://' and 'iser://'.
Fix the missing iser parsing, introduced from 12222077.

Signed-off-by: Han Han <hhan@redhat.com>
2020-08-11 21:57:12 +08:00
Ronnie Sahlberg
c54c4cd202 iscsi-perf: Add explicit casts to avoid two warnings
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2020-07-31 09:21:33 +10: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
Ronnie Sahlberg
1ab84e2175 fix LGTM.com warning
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2019-09-28 17:32:29 -07: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
Tim Crawford
aba0f7da1a Replace WIN32 with _WIN32
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>
2017-11-29 10:07:44 -05:00
Ronnie Sahlberg
6d6cb515fb Update the documentation for the --debug flag to iscsi-ls
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-03 11:36:04 -07:00
Ronnie Sahlberg
12222077cc Add project file for iscsi-ls and make it build under visual studio
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-13 12:09:42 -07:00
Ronnie Sahlberg
cd0dcb5dae Make iscsi-ls default to HeaderDigest=None for its discovery session
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-02-17 18:18:08 -08:00
optimistyzy
63cfcd3384 iscsi-perf: fix overflow issue in fill_read_queue
If with int defintion, this statement:

num_blocks = client->num_blocks - client->pos;

May not get the exact value we want.

Signed-off-by: optimistyzy <optimistyzy@gmail.com>
2017-01-09 18:38:59 +08:00
Vicente Olivert Riera
f27bdf64f0 Do not use -I/usr/include. This is considered unsafe when cross-compiling
Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
2016-10-16 10:53:13 +01:00
Peter Lieven
ab01692ea6 iscsi-ls: strip portal group tag in url output
we do not use it in libiscsi anyway, but e.g. Qemu does not support in in the URL.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-07-07 12:00:56 +02:00
Peter Lieven
d0943249f6 iscsi-inq: use right int types
the block limits vpd has unsinged values. casting them to signed can return negative results.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-07-07 11:24:50 +02:00
Peter Lieven
19a3412d58 iscsi-perf: add a logging parameter
if specified the perf output will log the perf data once per second.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-07-07 10:44:24 +02:00
Roy Shterman
a628264ef0 Libiscsi: iSER implementation
This commit includes all iSER implementation in libscsi
library and utilities.

Also, adding iser option in url.

Change-Id: I55ca8a9d4db802e72eb991061260dbb0bd0ef9ba
Signed-off-by: Roy Shterman <roysh@mellanox.com>
2016-06-03 18:59:01 -07:00
Paolo Bonzini
d84ee65eaa iscsi-ls: skip link-local IPv6 addresses
Some iSCSI targets provide a link-local IPv6 address as a portal, but that
is unusable without knowing the interface (aka scope-id) to use for the
connection.  This causes iscsi-ls to report an EINVAL and exit.  Just
skip the error.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-30 17:55:03 +02: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
Sitsofe Wheeler
403ec4493a iscsi-perf: Add ULL suffix to large integer literals
Add ULL to all the large integer literals. Without this they can be
treated as being signed by the compiler (at least on 32 bit machines)
leading to underflow problems and strange output when calculating the
elapsed time.
2016-01-30 09:44:45 +00:00
Sitsofe Wheeler
831b222917 iscsi-perf: Allow a better clock to be used
7c6a3e4a0b wound up always forcing the
usage of gettimeofday (even when the more accurate CLOCK_MONOTONIC was
available) because the define to indicate its availability is in
config.h which wasn't included.

Fix this by including config.h, correct the misnamed variable in the
CLOCK_MONOTONIC branch and rename VERSION to PERF_VERSION to avoid the
naming conflict.
2016-01-30 09:44:34 +00:00
Ronnie Sahlberg
1c9792941f iscsi-perf: use uint64_t instead of u_int64_t
because portability

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-10 10:55:27 -07:00
Chris Zankel
e186169064 build: fix 'out-of-tree' build
Prefix include paths with '${srcdir}' to allow 'out-of-tree' builds:

  cd $BUILD
  $LIBISCSI/configure
  make

Signed-off-by: Chris Zankel <chris@zankel.net>
2015-04-22 18:18:14 -07:00
Peter Lieven
e219f1bb97 utils/examples: avoid busy waiting on wait for reconnect
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-13 10:26:28 +02:00
Peter Lieven
2c1b88e9e7 iscsi-perf: add a max reconnects switch and fix double CTRL-C
this adds a switch to define max_reconnects instead of just aborting
after a NOP timeout. It is now also possible to force an exit
if CTRL-C is pressed twice.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-31 15:44:46 +02:00
Peter Lieven
b9dc3749c9 iscsi-perf: add a switch to send requests of random size
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-27 12:18:58 +01:00
Peter Lieven
9d6f0690f8 iscsi-perf: add NOPs to the perf stream and account for timeouts
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-27 11:08:37 +01:00
Peter Lieven
44b1a2e1e0 iscsi-perf: use a common iovec for all requests
this avoids a lot of unnecessary mallocs and frees.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 11:08:31 +01:00
Peter Lieven
fe265aef9c connect: allow to avoid the testunit ready call in iscsi_full_connect_async
iscsi-ls show luns command does not work when the target redirects at login.
to avoid redundant code allow iscsi_full_connect_async to skip the testunit ready
part.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 10:48:01 +01:00
Peter Lieven
2955b2c616 init: apply settings to context in iscsi_parse_url
if iscsi_context is not NULL we apply the parsed settings
to the context.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 10:37:39 +01:00
Peter Lieven
2fc538c8be iscsi-perf: add SCSI_STATUS_BUSY and SCSI_STATUS_CHECK_CONDITION handling.
this also fixes abort on errors and time output.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-24 14:32:00 +01:00