Commit Graph

1352 Commits

Author SHA1 Message Date
Ronnie Sahlberg
d33e41c9d4 Merge pull request #147 from plieven/destroy_segfault2
init: fix segfault in iscsi_destroy_context
2015-03-19 06:18:43 -07:00
Peter Lieven
ea2bcfd308 init: fix segfault in iscsi_destroy_context
observed when iscsi_destroy_context is called while a iscsi NOP out is in flight.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-19 12:40:37 +01:00
Sebastian Herbszt
373d5883d4 update .gitignore
Add test-tool/iscsi-test-cu to .gitignore.

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
2015-03-14 11:11:21 -07:00
Ronnie Sahlberg
b1d0ac45f1 Add support for bidirectional CHAP
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-03-14 10:43:03 -07:00
Ronnie Sahlberg
b03959dbb5 Merge pull request #146 from stweil/master
Fix wrong checks for username
2015-03-07 07:38:04 -08:00
Stefan Weil
dd1ee0f51c Add more entries to .gitignore
When building on a host with installed libtool, some files are generated
which should be ignored by git:

	examples/iscsi-dd
	examples/iscsiclient
	examples/ld_iscsi.so
	utils/iscsi-inq
	utils/iscsi-ls
	utils/iscsi-perf
	utils/iscsi-readcapacity16
	utils/iscsi-swp

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-03-07 09:54:38 +01:00
Stefan Weil
86adf5847c Fix wrong checks for username
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>
2015-03-07 09:54:38 +01:00
Stefan Weil
d7a8ab0f1e Remove trailing blanks
The files touched here need a bug fix which is applied with the
following patch.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-03-07 09:54:38 +01:00
Ronnie Sahlberg
54e32122d3 Merge branch 'requeue-pdu' 2015-03-02 19:47:23 -08:00
Ronnie Sahlberg
7ffce43dc9 iscsi-util.c: use PRIu64 instead of llu
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-03-02 19:46:46 -08:00
Ronnie Sahlberg
a6b301cfdf Merge pull request #145 from sitsofe/iscsi-perf-clang
Iscsi perf clang
2015-03-02 19:38:16 -08:00
Sitsofe Wheeler
7c6a3e4a0b iscsi-perf: Use gettimeofday if clock_gettime is unavailable
clock_gettime doesn't existing on OS X
(http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x
) so add an autoconf test to check if the platform has it and fall back
on gettimeofday if not.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
2015-03-01 16:15:51 +00:00
Sitsofe Wheeler
5629afa364 test_preventallow_*.c: Silence clang empty body warning
Clang whinges about an empty loop body when it sees code like
while (i = 0; i++; i < 2);
but in test_preventallow_*.c this looks intentional, so move the
semi-colon to a line of its own to make clang happy.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
2015-03-01 16:13:45 +00:00
Sitsofe Wheeler
04ff9584ee iscsi-perf.c: Use %llu format string.
Compiling with clang gives a format warning like
iscsi-perf.c:98:53: error: format specifies type 'unsigned long' but the
argument has type 'uint64_t' (aka 'unsigned long long')
      [-Werror,-Wformat]
so replace %lu with %llu where appropriate.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
2015-03-01 16:12:13 +00:00
Ronnie Sahlberg
ec4266392e connect.c: improve comment in reconnect code that we ONLY requeue SCSI COMMAND
The only PDU type that does not have ISCSI_PDU_DROP_ON_RECONNECT is the
SCSI COMMAND PDU. Thsi is the only PDU that we re-queue on reconnect.
All other, including DATA-OUT, NOP, task management, PDUs are simply
dropped.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-24 07:01:20 -08:00
Ronnie Sahlberg
6822baee3f reconnect: we need to reset the in/out iovectors on reconnect
This is a bug that has been there a long time.
When we reconnect and requeue a PDU we must reset the iovectors
for the task. Otherwise, any partially sent/received data when the
command is reconnected would end up containing garbage.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-24 06:54:18 -08:00
Ronnie Sahlberg
76f8296dbb reconnect logic and pdu handling
Rework the reconnect logic so we just call iscsi_scsi_command_async()
for the scsi commands we are re-quining instead of poking into the
private fields of the structures themself.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-23 20:46:57 -08:00
Ronnie Sahlberg
aedced3b95 login.c: dont modify pdu->flags directly from iscsi_logout_async_internal
We no longer need to modify pdu->flags directly any more from
iscsi_logout_async_internal. We can just pass these as extra flags to
iscsi_allocate_pdu().

We also always set ISCSI_PDU_DROP_ON_RECONNECT unconditionally so there is
no need to pass this flag in from the callers in pdu.c .

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-23 20:39:37 -08:00
Ronnie Sahlberg
63c2e7583d task_mgmt.c: drop tmgmt pdus on reconnect
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-23 20:31:25 -08:00
Ronnie Sahlberg
0a9bd03b2d login.c: drop login PDUs on reconnect
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-23 20:31:25 -08:00
Ronnie Sahlberg
44c5089a21 discovery.c: drop discovery requests on reconnect instead or re-queuing them
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-23 20:31:25 -08:00
Ronnie Sahlberg
511c2fdbd1 pdu.c: remove iscsi_allocate_pdu_with_itt_flags()
Remove iscsi_allocate_pdu() which is just a wrapper.
Rename iscsi_allocate_pdu_with_itt_flags() to iscsi_allocate_pdu()
and update all callers.

This only removes a wrapper function and contains no logic changes.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-23 20:26:22 -08:00
Ronnie Sahlberg
d30e8e9beb Merge pull request #144 from plieven/fix_unsolicited
iscsi-command: fix unsolicited data-out length
2015-02-23 06:26:12 -08:00
Peter Lieven
de7b38d9a0 use MIN and MAX macros at some places
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-02-23 08:03:27 +01:00
Peter Lieven
dd6831a50f iscsi-command: fix unsolicited data-out length
the recent implementation allows to send
iscsi->first_burst_length + iscsi->target_max_recv_data_segment_length
bytes if immediate and unsolicited data-out is send and
iscsi->target_max_recv_data_segment_length < iscsi->first_burst_length.

RFC3720 defines the length as:

Length=(min(FirstBurstLength, Expected Data
   Transfer Length) - Received Immediate Data Length).

so that immediate data and unsolicited data-out are together
FirstBurstLength at maximum.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-02-23 07:53:41 +01:00
Peter Lieven
c94fb840bc iscsi-private: add MIN and MAX macros
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-02-23 07:48:29 +01:00
Ronnie Sahlberg
2f5d21b09c iscsi-command.c: Use common function to write unsolicited data-out pdus.
We write unsolicited data-out PDUs from two places;
when we originally write the command in iscsi_scsi_command_async()
but also when we re-queue the PDUs during a session reconnect.

The re-queuing during the session re-connect was recently (almost) fixed
but was still buggy in that it did not correctly clamp the amount of written
data as per first burst length restriction.
This attempts to fix that.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-20 20:51:14 -08:00
Ronnie Sahlberg
831ecb3656 iscsi-command.c: use pdu->expxferlen instead of pdu->expxferlen
Both are the same value at this point but it is better to
do the computation only based on pdy-> fields.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-20 20:39:51 -08:00
Sebastian Herbszt
7dfd42ebfe test-tool: fix unregister of initiator 2 in test_prout_reserve_access
Initiator 2 registered with key2.

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
2015-02-17 19:21:46 -08:00
Ronnie Sahlberg
b001d980ef reconnect: we must re-queue any missing data-outs during reconnect
If we have writes that do not have the Final bit set during reconnect
we must send out any missing data-out PDU.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-17 06:46:58 -08:00
Ronnie Sahlberg
8ae706630e iscsi-command.c: Better fix for the length bug for immediatedata
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-16 17:36:58 -08:00
Ronnie Sahlberg
db7924fc90 iscsi_command: fix length bug when sending unsolicited data.
If we have send unsolicited immediate data and are ALSO sending
unsilocoted data-out, then we have to exclude the length of data we have already sent.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-16 17:27:56 -08:00
Ronnie Sahlberg
51bd0ce3ec test-tool: remove the --usb argument and use BLCSECTGET to read max xfer
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-16 16:04:28 -08:00
Sebastian Herbszt
cb7882a84c test-tool: fix SG_IO
Handle io_hdr.resid and adjust datain.size.

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
2015-02-16 15:39:31 -08:00
Sebastian Herbszt
4fbf802d32 update .gitignore
Update .gitignore.

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
2015-02-16 15:38:39 -08:00
Ronnie Sahlberg
6422fad7de RPM: add iscsi-perf to the package
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-11 06:11:44 -08:00
Ronnie Sahlberg
db4757766d README: add links to useful xml stuff
Suggested-by: CyberLoiter <yanming.xiao@gmail.com>
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-10 17:02:14 -08:00
Ronnie Sahlberg
68acbb7c3f rand_key: fix non-randomness in rand_key()
If rand_key() is called twive within the same second it would return the
same key both times. Not very random.
Redo how rand_key() works to make it more likely to be random and more likely
that two consequtive calls do not yield the same result.

Reported-by: CyberLoiter <yanming.xiao@gmail.com>
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-10 16:57:22 -08:00
Ronnie Sahlberg
bff95df881 Merge branch 'master' of github.com:sahlberg/libiscsi 2015-01-26 17:56:34 -08:00
Ronnie Sahlberg
d69d955fa6 test-tool: SEGV when dereferencing a NULL pointer ascq array
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>
2015-01-26 17:56:12 -08:00
Ronnie Sahlberg
b84119611c test-tool: fix segv in reserve6_2initiators
Fix a SEGV in one of the reserve6 tests.

Signed-off-by: Vadim Finkelstein <vadim@pi-coral.com>
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-01-26 17:56:12 -08:00
Ronnie Sahlberg
004f16675e Merge pull request #141 from plieven/iscsi-io
util: introduce iscsi-perf
2015-01-23 06:18:11 -08:00
Ronnie Sahlberg
7dc0ea200d socket.c: allow re-using a context after disconnect
From Adam Endrodi <adam.endrodi@nsn.com>
Fix a bug and clear is_corked during socket disconnect so that we
can re-use the context for a new connection.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-01-09 15:13:58 -08:00
Ronnie Sahlberg
1971188764 Merge pull request #142 from cuinutanix/master
set_tcp_* functions should be static
2015-01-08 07:31:06 -08:00
Mike Cui
2284a8763c set_tcp_* functions should be static since they are not used anywhere else.
set_tcp_sockopt in particular conflicts with libnfs's function of the same
name and prevents a a program from statically linking against both libnfs and
libiscsi.

Similar fix should also go into libnfs.
2015-01-05 09:24:01 -08:00
Ronnie Sahlberg
52d9d84f9c README: update the readme and describe the family/suite/test better
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-12-30 19:54:56 -08:00
Ronnie Sahlberg
d33a0438a4 TESTS: replace read* flags tests with dedicated dpo/fua tests
Remove the flags tests for READ* and replace them with a test for the DPO
and FUA bits.
IF the device claims DPOFUA support in modesense then the READ* CDBs
MUST allow these two flags. IF the device does NOT claim DPOFUA then any
READ* CDB with these flags must fail with invalod field in cdb.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-12-22 20:05:29 -08:00
Ronnie Sahlberg
3aef8a0d4f README: mention that we can test against /dev/sg devices
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-12-21 15:14:29 -08:00
Ronnie Sahlberg
7865a8a26e Merge branch 'sgio' 2014-12-21 15:07:40 -08:00
Ronnie Sahlberg
646c8b963d New version 1.13.0
- Fix UNMAP tests
 - Build updates
 - Check residuals also when status != GOOD
 - Add WSNZ bit to the tests
 - Various test updates
 - Fix bug in scsi_create_task so it sets cdb_len correctly
 - Add a getter function for scsi task status and sense
 - Fixes and workarounds for Dell Equallogic issues
 - Be more flexible when allowing for unit attentions during connect time

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-12-21 14:58:46 -08:00