2246 Commits

Author SHA1 Message Date
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
190ea92810 Rework error messages generated when login fails to not repeat the same
thing "Failed to login to target" several times as the error cascades
up through the layers of callbacks.
2011-01-02 12:12:30 +11:00
Ronnie Sahlberg
796b3a6acc login.c: Dont end error strings with \n, Leave that for the caller. 2011-01-02 08:22:38 +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
6947502759 Add negotiation of IFMarker, OFMarker and MaxConnections during login 2011-01-01 12:42:48 +11:00
Ronnie Sahlberg
ec252d78f8 Changte time2retain default from 20 to 0 2011-01-01 12:38:41 +11:00
Ronnie Sahlberg
820fffe04e Add negotiation of MaxOutstandingR2T and ErrorRecoveryLevel during login phase 2011-01-01 11:51:09 +11:00
Ronnie Sahlberg
27038e5c8b Negotiate DefaultTime2Wait and DefaultTime2Retain during login phase 2011-01-01 11:45:07 +11:00
Ronnie Sahlberg
172dbb6846 Update what we try to negotiate as header digest when we receive
a reply back from the target.
2011-01-01 11:38:06 +11:00
Ronnie Sahlberg
e004161c1f Update login functions to use asprint to build the key=value pairs
instead of calling iscsi_pdu_add_data twice, once for key= and once for value
2011-01-01 10:07:24 +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
a0acddb627 Update to the public header to better document the api 2010-12-31 12:26:46 +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
2b30e3a7fe When getting a socket POLLERR event, use getsockopt(SO_ERROR)
to create a better error message about the reason for the socket failing.
2010-12-31 06:01:41 +11:00
Stefan Hajnoczi
6981b79516 Check SO_ERROR when async connect completes
When non-blocking connect completes the error code can be read using
getsockopt(SO_ERROR).  Doing this is important for identifying failure
to connect, especially if POLLERR and POLLHUP were not employed by the
user.

The QEMU iscsi block driver does not use POLLERR/POLLHUP and depends on
SO_ERROR to detect connection failure.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2010-12-29 08:57:48 +00:00
Stefan Hajnoczi
faec3c0dfd Only await POLLOUT events until connected
Non-blocking socket connect(2) involves waiting for the socket to become
writeable to detect that a connection has been made.  POLLIN events
should not be requested until the socket is connected because they are
processed even if the iSCSI context is not yet connected.

For example, the QEMU iscsi block driver does something like this:

iscsi_full_connect_async(...)

/* Now wait until the socket becomes ready */
poll(POLLIN|POLLOUT) = POLLIN|POLLOUT

/* QEMU calls POLLIN and POLLOUT handlers individually and it happens to
 * call the POLLIN handler *before* the POLLOUT handler.
 */
iscsi_service(POLLIN)
iscsi_service(POLLOUT)

POLLIN processing will read from the socket and consume the error code
if connect failed.  As a result, the POLLOUT handler will write to a
disconnected socket and raise a SIGPIPE which kills the process.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2010-12-29 08:57:48 +00:00
Ronnie Sahlberg
f449b31150 Change makefile to use -O2 optimizations 2010-12-29 18:02:18 +11:00
Ronnie Sahlberg
647ebd222e Try to resolve hostnames into ip addresses
Dont assume everyone just uses dotted-decimal always on their networks.
Try resolve hostnames specified in the iscsi URLs into addresses
2010-12-28 13:51:54 +11:00
Ronnie Sahlberg
7a7a227fee Suppress a compiler warning 2010-12-27 10:12:45 +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
ef7ba259b1 TODO
We have CHAP now, and somewhat more sohpisticated login negotiation
so remove those from the TODO list
2010-12-22 22:29:46 +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
d53b882682 MAKEFILE
Add md5.o to the makefile
2010-12-22 22:12:38 +11:00
Ronnie Sahlberg
633a08bc22 MD5
Add a public domain implementation of MD5 so we can compute CHAP
The md5 implementation is copied from TGTD
2010-12-22 21:57:58 +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
3ef5a375dc TODO
MTX patch is complete so no longer TODO
2010-12-22 16:57:16 +11:00
Ronnie Sahlberg
79b821db44 LOGIN
We pass header and data separately now so no need to check id size
is less than header size.

Add error reporting of login type and error string describing
the error when login status has failed.
2010-12-22 16:55:48 +11:00
Ronnie Sahlberg
6cb843682f RPM
Install the libiscsi shared library as part of the normal RPM,
not as part of the special devel RPM
2010-12-21 20:09:46 +11:00
Ronnie Sahlberg
61db77394c README
Update readme with text what libiscsi is about
2010-12-21 20:03:13 +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
dba66b2a7d update the TODO file with suggestion of mtx and dvdrecord as
otential consumers
2010-12-05 18:03:07 +11:00
Ronnie Sahlberg
d124f44469 update intall instructions 2010-12-05 16:13:44 +11:00
Ronnie Sahlberg
5e5a5a2c56 Add autogen/configure to the build instructions.
Update the RPM sepcfile to run autogen/configure
2010-12-05 14:53:02 +11:00
Ronnie Sahlberg
4e5fb3a60b We need libpopt-dev to compile the utilities.
Add a test to configure to verify popt development libraries are available
and print an error and exit otherwise.
2010-12-05 14:48:34 +11:00
Ronnie Sahlberg
1cfeadb015 add a todo list 2010-12-05 14:02:39 +11:00
Ronnie Sahlberg
3d3da6c6e3 include config.h from lib/socket.c and use this to conditionaly
compile code to set sin_len on platforms that require this field
in the sockaddr structures.
2010-12-05 13:53:41 +11:00
Ronnie Sahlberg
631954405a add prefix exec_prefix libdir and bindir to the makefile 2010-12-05 13:40:48 +11:00
Ronnie Sahlberg
d7a1103e13 Add initial autoconf support to make it easier to get ported to
other platforms
2010-12-05 13:31:11 +11:00
Ronnie Sahlberg
709d85c4da Add a COPYING file and updat ehte LGPL boilerplate 2010-12-05 11:11:37 +11:00
Ronnie Sahlberg
4f49ca5d54 Add missing LGPL boilerplate to crc32c.c 2010-12-05 11:11:09 +11:00
Ronnie Sahlberg
32b39f62bd Update iscsi-ls and iscsi-inq
to take the URLs in the form
iscsi://<host>[:<port>]
and
iscsi://<host>[:<port>]/<target-iqn>/<lun>

instead of specifying the values as --portal/--target/--lun
2010-12-05 08:57:10 +11:00
Ronnie Sahlberg
b76c7acb25 Update the readme file to show how to build libiscsi rpms 2010-12-05 08:33:06 +11:00
Ronnie Sahlberg
30177426b4 Update the RPM specfile to point to the githup libiscsi URL 2010-12-05 08:30:59 +11:00
Ronnie Sahlberg
098bc5a9a7 Initial import of libiscsi 2010-12-05 08:24:57 +11:00