Commit Graph

385 Commits

Author SHA1 Message Date
Ronnie Sahlberg
ce4623b2fb READ SUPPORTED OPCODES. Update the signature to allow setting all of the
parameters to this command.
2013-05-18 12:34:03 -07:00
Ronnie Sahlberg
704e0f6448 SCSI: add a safe function to read a byte from the datain buffer and use it
throughout the unmarshalling code
2013-05-12 13:57:15 -07:00
Ronnie Sahlberg
772d220217 Add a version descriptor 2013-05-11 16:03:23 -07:00
Paolo Bonzini
bcb2950d8d use libgcrypt for MD5
This makes sure that CHAP authentication is disabled if the system
is running in FIPS 140-2 mode.  MD5 is not a secure algorithm according
to the standard.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-05-03 12:51:15 +02:00
Paolo Bonzini
cc742279d0 fix bug in md5 code 2013-05-03 12:50:58 +02:00
Ronnie Sahlberg
b7dd6b533b TEST: Add a test that is cmdsn is too low the target just ignores the pdu 2013-04-30 19:05:23 -07:00
Ronnie Sahlberg
4a8d967541 Add support for synchronous command timeout.
Default to 0 meaning no timeout.

Implement a test for iSCS to test what happens if we send a command
with CMDSN being higher than the target allows.
In this case we dont strictly know what will happen, just that what should
NOT happen is the target responding with success.
But we have to be prepared for any kind of failure, including a timeout,
scsi sense, or even iscsi reject or session failure.
2013-04-29 20:42:33 -07:00
Ronnie Sahlberg
d280ce8ad7 Create safe 16/32/64 bit accessors for reading from the datain buffer
and use it throughout the scsi lowlevel file.

We probably want a safe accessor for byte access to at some stage.
2013-04-22 22:11:53 -07:00
Ronnie Sahlberg
322be0cf24 add missing version descriptor 2013-04-22 18:34:02 -07:00
Ronnie Sahlberg
555906e76e Revert "Add SSC to the version descriptors."
This reverts commit 45f5fc2105.

Conflicts:

	include/scsi-lowlevel.h
2013-04-22 18:32:09 -07:00
Ronnie Sahlberg
e640fa3cde missing , broke compile 2013-04-22 18:28:20 -07:00
Ronnie Sahlberg
45f5fc2105 Add SSC to the version descriptors.
I actually have a usb-stick that claims it supports SSC. I stongly doubt it.
2013-04-22 17:44:13 -07:00
Ronnie Sahlberg
91a98d6b92 Add handling of inquiry version descriptors 2013-04-21 14:04:30 -07:00
Ronnie Sahlberg
402653b9f3 portability updates
add check if ipv6/sockaddr_in6 is availavble or not
add check for poll.h and only include when available
add includes for AROS
2013-04-18 19:43:36 -07:00
Ronnie Sahlberg
fbf58ead9f TESTS: When task management functions fail, print the reason why it failed. 2013-03-27 17:25:47 -07:00
Ronnie Sahlberg
aac7ed29b8 SYNC Task mgmt functions. Return !0 status if the command completed successfully
but the target responded with non-zero response code.
2013-03-26 17:38:47 -07:00
Ronnie Sahlberg
d5c5fb83af We should still be able to login even if the device is reserved.
TESTUNITREADY returning reservation conflict is no reason to fail the login
2013-03-21 19:26:55 -07:00
Ronnie Sahlberg
f8901ea18e Merge pull request #61 from plieven/ascq
Add ASCQ codes related to thin-provisioning
2013-03-11 06:46:20 -07:00
Peter Lieven
80ef1807ef Add ASCQ codes related to thin-provisioning
Signed-off-by: Peter Lieven <pl@kamp.de>
2013-03-11 12:13:42 +01:00
Peter Lieven
5a94d5d73a fix leak of iscsi_context in iscsi_reconnect
in case the maximum number of reconnects is limited with
iscsi_set_reconnect_max_retries() the an iscsi_context
is leaked if the limit is exhausted.

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-03-11 08:51:18 +01:00
Peter Lieven
327b51ed5b do not reconnect if reconnect is already defered
If the amount of reconnects is limited with iscsi_set_reconnect_max_retries()
it might happen that iscsi_reconnect is called while there is already a deferred
reconnect.

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-03-11 08:44:11 +01:00
Ronnie Sahlberg
3e28133a9a Add unmarshallers for READ*/VERIFY*/WRITE* cdb 2013-03-10 09:19:23 -07:00
Ronnie Sahlberg
0d5c8a4f11 TESTS: Add test for PREVENTALLOWMEDIUMREMOVAL are cleared on lun/target reset 2013-03-03 13:37:52 -08:00
Ronnie Sahlberg
100fcd796d Add ASCQ code for CAPACITY_DATA_HAS_CHANGED 2013-02-19 17:59:45 -08:00
Peter Lieven
8bc0046f51 changed iscsi_data.size from int to size_t
iscsi_data.size is used as parameter to memory
operation functions (such as malloc) which except
size_t rather than int.

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-01-28 09:36:00 +01:00
Peter Lieven
7e46a5a337 RECONNECT fix lost allocation on reconnect.
Signed-off-by: Peter Lieven <pl@kamp.de>
2013-01-28 09:31:13 +01:00
Ronnie Sahlberg
0f73f062d2 SCSI: remove LBDATA/PBDATA from the WriteSame10/16 signatures
Make LBA the third argument to the iscsi writesame functions
2013-01-21 21:15:37 -08:00
Ronnie Sahlberg
72598c0b46 UNMAP: Fix marshalling of DATA when more than one unmap descriptor is sent. 2013-01-21 20:06:11 -08:00
Ronnie Sahlberg
065319f996 SCSI Add support for STATUS_BUSY
Add support for BUSY status coide from the target and just pass this
back to the application as is (instead of converting it to _ERROR).

This allows the application to trap task->status==SCSI_STATUS_BUSY and
decide what/how to proceed.
2013-01-01 10:15:56 -08:00
Lee Duncan
d72e6b3717 Removed custom struct for tracking Persistent Resvn type. 2012-12-23 21:36:46 -08:00
Lee Duncan
474cec5556 Added new 1130* test file for PGR simple reserve testing.
Added infrastructure to support reading, setting, and
clearing reservations.
2012-12-22 13:50:55 -08:00
Ronnie Sahlberg
09df905d30 Add unmarshalling ot REPORT_CAPABILITIES 2012-12-18 21:19:25 -08:00
Ronnie Sahlberg
4522658254 Add unmarshalling og READ_RESERVATION data 2012-12-18 21:10:26 -08:00
Ronnie Sahlberg
2a74fc00bc Initial support for PERSISTENT_RESERVER_OUT and add a simple test to show the api 2012-12-17 21:25:46 -08:00
Ronnie Sahlberg
2b46e4adfa Add unmarshalling of PERSISTENT_RESERVE_IN/READ_KEYS DATA-IN blob 2012-12-17 19:26:43 -08:00
Ronnie Sahlberg
c60093eafe Add support for PERSISTENT_RESERVE_IN and add a simple test for READ_KEYS 2012-12-17 19:01:50 -08:00
Peter Lieven
4cbbc0e1e9 SOCKET order packets in outqueue by CmdSN
Ordering by itt adds the special case of handling
itt == 0xffffffff. Order by CmdSN instead as described
by RFC3720.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-16 12:36:34 +01:00
Peter Lieven
2f9fda19d2 SOCKET do not queue PDUs with itt==0xffffffff head of queue
Queing packets with itt = 0xffffffff (e.g. NOP-Out replies) ahead
of queue because they might have a higher CmdSN than following
packets. This again could lead to a deadlock AND its a protocol
violotion:

RFC3720 Section 3.2.2.1 second last paragraph on Page 21:
"On any connection, the iSCSI initiator MUST send the commands in
increasing order of CmdSN, except for commands that are retransmitted
due to digest error recovery and connection recovery."

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-15 13:27:52 +01:00
Peter Lieven
735e3063ad PDU log header of rejected PDUs
Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-15 13:27:41 +01:00
Peter Lieven
446b1829c8 SOCKET use readv/writev to write directly into iovectors
This patch adds support for read/writev to directly read and write
from/to iovectors. Before this patch on read and write from/to socket
the operation was limited by the iovec boundaries. If there is enough
data in the buffer or enough buffer space available its now possible
to transfer the whole data in one atomic operaion.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-10 19:24:28 +01:00
Peter Lieven
752c0ad396 SOCKET set TCP_NODELAY on iscsi->fd
This will set TCP_NODELAY on the socket connection
to the target. This is the first step to improve latency.
For systems supporting TCP_CORK we plan to add a cork
around certain PDUs e.g. DATA-Out, but this needs further
testing.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-07 15:01:19 +01:00
Peter Lieven
36be387547 SOCKET remove useless code
At this point in iscsi_write_to_socket() pdu->written can only be
equal to total.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-06 10:42:30 +01:00
Peter Lieven
154760a00e RECONNECT remove redundant requeue code
We first merge waitpdu and outqueue queues and then requeue
the elements. iscsi_add_to_outqueue() will sort them accordingly
so this is no problem.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-06 10:42:23 +01:00
Peter Lieven
5f18c72706 RECONNCT fix broken reconnect for iov out vectors
We where modifying out_offset and out_len in iscsi_write_to_socket().
If the packet that was being sent before reconnect was a write command
the was a significant change that out_offset and out_len where already
touched. When requeing the packet after reconnect we where
sending garbage!

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-06 10:42:16 +01:00
Peter Lieven
237729545a NOP count in flight of client generated NOP-Outs
This patch adds the abilitiy to libiscsi to count the number
of consecutive outstanding NOPs.

With this ability its fairly easy to implement a keepalive
check with NOPs in your application.

Periodically (e.g. every 5 secs) create a NOP-Out with:

iscsi_nop_out_async(iscsi, NULL, NULL, 0, NULL);

At that time check the number of consecutive missing NOP-Ins
with

iscsi_get_nops_in_flight(iscsi) > N.

Where N is the number of missing NOP-Ins you will allow.
Please note that it is legitime for the Target to ignore
a NOP if the load is very high as those packet are mark
as IMMEDIATE.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-06 10:42:09 +01:00
Ronnie Sahlberg
d1344a666b Merge pull request #53 from plieven/reconnect_on_login_error
RECONNECT add option to limit the number of reconnect retries
2012-12-04 19:16:44 -08:00
Ronnie Sahlberg
22797e0f67 NOPs should not be requeued when reconnecting a session.
Just like DATA_OUT we should just discard NOPs instead of requeueing them
on session reconnect.
Add new flag that to indicate this behaviour on reconnect and set it for
both data out and nops
2012-12-04 19:07:49 -08:00
Peter Lieven
ee83c7ce75 RECONNECT add option to limit the number of reconnect retries
In specific situation it might be useful to give up if a reconnect
is not successful or after a given number reconnect retries.
This patch adds the ability to change that. The default remains
the same: retry forever.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-04 13:38:50 +01:00
Peter Lieven
be998cdaed DATA-IN fix broken read without iov
The preallocation logic was messing with size and offset of pdu->indata.
This was broken when we removed iscsi_data->alloc_size. Removing
entirely since reading without iovectors is deprecated.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-03 17:08:07 +01:00
Peter Lieven
dbe9a1e73a SOCKET queue cmd PDUs directly in waitpdu queue
A storage might sent an R2T response for a WRITE command while
we still sending out the WRITE command PDU. This is especially
the case when the command PDU carries immediata data.

Without this patch the R2T response will get lost as
the cmdpdu for the R2T cannot be found in iscsi_process_pdu()
leading to a deadlock.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-03 11:05:21 +01:00