Commit Graph

32 Commits

Author SHA1 Message Date
Peter Lieven
4cb845477d Add debugging framework
This patch adds a user configurable debug level. For testing
it includes connection info and reporting errors.
2012-10-18 10:36:26 +02:00
Ronnie Sahlberg
06cc2d2ece CONNECT: connect data is not always malloc()ed so we can demand it is free()able
After a sync connection, make sure to clear connect_data since it will otherwise
point to a structure on the stack.
2012-08-09 08:27:48 +10:00
Ronnie Sahlberg
439f68e555 CONNECTION: Track the connection state and callback via the context structure
Dont free the connection state when login is finished, instead track it via the
iscsi context structure and free it once the context is destroyed
2012-08-02 08:51:25 +10:00
Ronnie Sahlberg
9e5535adfd Reconnect: If we are logged in and we experience a session failure, then
try to re-connect and redrive all I/O

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2012-05-01 18:46:30 +10:00
Paolo Bonzini
a1975e90f6 fix warning from -Wuninitialized 2011-09-21 12:00:20 +02:00
Ronnie Sahlberg
c3d3123981 Windows: Add support to build as a DLL under windows 2011-08-31 13:12:30 +10:00
Ronnie Sahlberg
356a6571bb Login: remember what the TargetAddress returned during login is so we can
handle redirect 'errors'.
2011-02-25 15:35:49 +11:00
Ronnie Sahlberg
d1fdaef5c6 Username/password separator: Allow ':' to separate the chap username/password in addition to '%' 2011-02-20 10:44:53 +11:00
Ronnie Sahlberg
d22a2aee3c When initializing a new session, default to set the
"random" ISID randomly.

Dont assume that users will never create multiple contexts
concurrently, in which case the previous getpid()^time(NULL)
would create duplicates.
2011-01-27 11:02:16 +11:00
Ronnie Sahlberg
7b5ff1095c Improve help/usage strings for iscsi-ls and iscsi-inq
For help output, also print the syntax for the iscsi url required.
2011-01-09 10:36:53 +11:00
Ronnie Sahlberg
5e11bb17b1 Replace index() with strchr() 2011-01-09 09:46:42 +11:00
Ronnie Sahlberg
e312aa2ae0 ISID: Add helper functions to set any type of ISID value for the iscsi context.
Let default be to create a 'random' ISID during context creation.
2011-01-09 09:26:03 +11:00
Ronnie Sahlberg
6f36a6ca2b Change HeaderDigest to default to None,CRC32C instead of None
This allows our default setting to work with any target configuration.
2011-01-03 15:54:38 +11:00
Ronnie Sahlberg
9ddce8dc24 Replace bzero() with memset() 2011-01-03 15:35:36 +11:00
Ronnie Sahlberg
7253a667ae Add a helper function to parse a Portal URL.
A Portal URL is of the form
   iscsi://[<username>[%<password>]@]<host>[:<port>]
and is used by command such as iscsi-ls during the discovery login phase.

During discovery we do not yet know the target iqn name, nor the lun of
any devices.
2011-01-03 15:22:01 +11:00
Ronnie Sahlberg
178f9c8751 Only set CHAP username/password if BOTH have been provided.
There is no point in setting the username if there is no password
and vice versa.

Also, if we only set username but not passwd this would lead to a segv.
2011-01-03 15:01:38 +11:00
Ronnie Sahlberg
5928575bac Allow setting the CHAP username/password via environment variables
so that the password will not be showing up in log where the application
logs the "filename/iscsi url" or in ps aux output.

LIBISCSI_CHAP_USERNAME and LIBISCSI_CHAP_PASSWORD environment variables are
available to set these outside of the url.
If hte username/password is ALSO set in the URL, the settings in the URL
will override the environment variables.
2011-01-03 14:58:52 +11:00
Ronnie Sahlberg
d240e8b5aa Use an initiator specific and one target specific value for MaxRecvDataSegmentLength 2011-01-02 19:27:16 +11:00
Ronnie Sahlberg
72f9d8fa82 Add a new pdu flag : NO_CALLBACK
This flag is used when we dont want the CANCEL callback to be invoked if the
context is destroyed.

Thsi will be used for the sequence where we send multiple PDUs
to the target for one single scsi task, such as
    -> WRITE10 cdb
    -> DATAOUT
    -< RESPONSE

Since if the context is destroyed when the command is in flight, we
already get the CANCEL callback for the WRITE10 PDU, so we dont need to invoke
it again for when we destroy the DATAOUT pdu, since they both refer to the same
task.
2011-01-02 18:00:37 +11:00
Ronnie Sahlberg
1f1e5111d4 Negotiate ImmediateData during login and store the result in iscsi->
We will use this later to decide when we should send unsolicited imemdiate
data to the target. Currently we always send unsolicited immediate data
but targets configured to not allow immediate data may refuce this and
turn an error.
2011-01-02 12:59:41 +11:00
Ronnie Sahlberg
32228a4509 Negotiate InitialR2T during login. Default to offer No, but update
and accept what Target responds.

Store the result of the negotiated setting in the iscsi context
so we can use it later to determine how to send solicited/unsolicited
data.
2011-01-02 12:50:00 +11:00
Ronnie Sahlberg
8eb62fec87 Improve error messages when parsing of iscsi url fails
Always print the correct url syntax when parsing has failed.
Test if the user forgot to specify a <target-iqn> at all and log
this as a missing target-iqn error. Not as a missing <lun> error.

Remove \n from the error strings in init.c
2011-01-02 08:04:41 +11:00
Ronnie Sahlberg
a3328a85ef Negotiation of MaxBurstLength, FirstBurstLength, MaxRecvDataSegmentLength
Add these settings to the iscsi context structure and initialize them to
sane valued.
When sending login commands to the target, use these values instead
of hardcoded values.
Parse when the target sends a login reply back to us and update these variables
if the target asks us to.

This allows us to detect when our defaults are too big for the target
and adjust the settings we use so we match the target.

Some targets have a very small accepted default for some settings.
During login, we will initially send these keys with our dafult values.
These targets will then respond back by refusing to transition to the next
login phase, and by telling us back what the maximum of these values should be.
In this case we have to try the login again but use the smaller values we got
from the target.
Othervise, if we try again, ignoring the value from the target, and just repeat
using our defaults the target will abort the login with a "initiator error".
2011-01-01 09:51:16 +11:00
Ronnie Sahlberg
46199d2f59 Improve the parsing of iscsi URLs and validate the input.
Generate better error messages when a badly formed URL is given
and an error string that points to the field there is a problem with.
2010-12-31 09:44:14 +11:00
Ronnie Sahlberg
240e250b11 USERNAME / PASSWORD
When failing iscsi-ls due to a missing url, print the url syntax
in the error message before aborting
2010-12-25 12:04:29 +11:00
Ronnie Sahlberg
60718652a4 USERNAME PASSWORD
When generating an error after failing to parse a iscsi url
add username/password to the url syntax that is printed in the error message
2010-12-25 12:00:09 +11:00
Ronnie Sahlberg
40abe849b0 CHAP
Add unidirectional chap support so we can authenticate to the target.

Make the login phase more "intelligent" so we can iterate over login
pdus until we have reached full feature phase

Add a new helper functions to parse a iscsi url and break it down
into elements in a structure

Update iscsi-inq to allow CHAP authentication
2010-12-22 22:23:55 +11:00
Ronnie Sahlberg
cf0ddbd0d9 URL PARSER
Add a function to parse a common iscsi://... URL so we dont have to re
implement the same code in every application
2010-12-22 18:40:46 +11:00
Ronnie Sahlberg
1c024d6bc4 Input processing:
Input processing used to keep all data in one single input buffer, which
makes it hard to handle nested events as well as reading directly from the
socket into the application buffer without an extra copy.

Create a new iscsi_in_pdu structure where we store the header, and any data
for the recevied pdu and store them in a proper input queue.

Change the signature for all processing functions to tahe a iscsi_in_pdu
structure for the received pdu instead of just a pointer to a buffer.
2010-12-11 15:15:51 +11:00
Ronnie Sahlberg
8a6665a092 Licence
Change to LGPL 2.1+ to be compatible with kvm/qemu
2010-12-11 11:47:28 +11:00
Ronnie Sahlberg
709d85c4da Add a COPYING file and updat ehte LGPL boilerplate 2010-12-05 11:11:37 +11:00
Ronnie Sahlberg
098bc5a9a7 Initial import of libiscsi 2010-12-05 08:24:57 +11:00