Commit Graph

42 Commits

Author SHA1 Message Date
Peter Lieven
14bee1007f RECONNECT do not increase CmdSN for immediate PDUs
Immediate PDUs such as queued NOP-Outs will cause
a protocol error on reconnect.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-11-29 15:17:30 +01:00
Peter Lieven
562dd46833 PDU avoid incrementing itt to 0xffffffff
This patch avoid incrementing itt to 0xffffffff which is
a reserved value for immediate pdus. Avoid incrementing
it to 0xfffffff to avoid unexpected behaviour.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-11-28 10:58:33 +01:00
Ronnie Sahlberg
700d363a88 Create a wrapper function for when we add pdus to the out queue
so that we can add them so that they are send in increasing itt order.
2012-11-27 20:26:13 -08:00
Peter Lieven
a75727d989 RECONNECT avoid deadlock on reconnect retry timeout
If there is a clock jump e.g. due to daylight saving time
the wait can be almost infinite
2012-11-18 14:03:13 -08:00
Peter Lieven
328755fb68 CONNECT add further debug output regardint login and reconnect 2012-11-18 14:02:29 -08:00
Peter Lieven
00baa9bd6c CONNECT fixed memleak in case iscsi_connect_async fails directly 2012-11-18 13:57:02 -08:00
Peter Lieven
8cb369b87f Merge remote-tracking branch 'upstream-git/master'
Conflicts:
	include/iscsi-private.h
	include/iscsi.h
	lib/connect.c
	lib/init.c
	lib/scsi-lowlevel.c
2012-11-12 16:02:57 +01:00
Peter Lieven
144026a7bd RECONNECT allow a consecutive reconnect only every 5 seconds
In case there is an error condition e.g. out of memory. We are heavily
disconnecting and reconnecting without any limit. This patch
adds a 5 seconds period that has to go by between 2 reconnects.
2012-11-08 16:56:44 +01:00
Ronnie Sahlberg
50e7c682bb Add a logging subsystem and change all DPRINTF to ISCSI_LOG
Add a mechanism where we can set a logging subsystem that libiscsi can use.
Create an example 'log to stderr' that utilities can use for convenience.
2012-11-07 06:34:38 -08:00
Peter Lieven
3e57a612db SOCKET add more skill to interface binding
If a process opens more than once connection the interfaces are assigned
round-robin from the available ones. However, different processes will
uses a random interface of as starting point. This patch will also
make the redirect case handled correctly.
2012-11-06 15:47:30 +01:00
Peter Lieven
a6caad107c INIT zero out sensitive data before its freed
The iscsi_url and iscsi_context might contain clear text
login credentials for an iscsi target. As Linux zeroes
on allocate this data might remain in memory for a long
time.
2012-11-03 02:12:46 +01:00
Peter Lieven
871c56ce7a MEMORY add compatibility for qemu-kvm
qemu-kvm iscsi block driver calls iscsi_parse_full_url without
a valid iscsi_context. The driver also creates its own scsi_task
objects.
2012-11-03 02:05:16 +01:00
Peter Lieven
d327ab09c6 MEMORY add wrappers around all mallocs and frees and trace them
This patch adds a wrapper around all memory allocations and frees.
The idea is to get warned immediately if the application leaks memory.
Additionally the wrapper functions make it easy to add different
memory allocators or memory pools in the future.
2012-11-03 01:05:57 +01:00
Peter Lieven
2e30d7aafb CONNECT correctly free ct in case first testunitready fails 2012-10-29 21:37:39 +01:00
Peter Lieven
923b9a4fb2 ISCSI-CONTEXT change dynamic string allocations to statics 2012-10-27 17:23:40 +02:00
Peter Lieven
0906109d8a CONNECT fix mem leak of connection_task object 2012-10-27 16:31:56 +02:00
Peter Lieven
4785dd9933 CONNECT do not reseed RNG in iscsi_reconnect 2012-10-26 20:47:35 +02:00
Peter Lieven
0b4424cca0 CONNECT Fix memory leak in iscsi_reconnect 2012-10-26 20:47:15 +02:00
Ronnie Sahlberg
97dcf94d72 iSCSI: when reconnecting we should not automatically requeue any DATA-OUT PDUs
Dont requeue data-out pdus, or other pdus with the DELETE_WHEN_SENT flag, such
as nops.
These, like the DATA-OUT pdu will instead be automatically re-sent when the original write command is sent again.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2012-10-24 19:32:00 -07:00
Peter Lieven
6e82c48185 RECONNECT fix read from freed iscsi context 2012-10-23 10:55:04 +02:00
Peter Lieven
20cf2b279e Fix incorrect whitespaces
At a few places there where spaces where tabulators where appropriate
2012-10-20 19:08:57 +02:00
Peter Lieven
78a31ad4a1 Add iscsi_set_tcp_syncnt function
This patch adds support for setting TCP_SYNCNT to overwrite
the system default values. This allows indirect support
for a configurable connect timeout.

Linux uses a exponential backoff for SYN retries starting
with 1 second.

This means for a value n for TCP_SYNCNT, the connect will
effectively timeout after 2^(n+1)-1 seconds.
2012-10-20 18:43:48 +02:00
Peter Lieven
236aaa011f Fix compiler warnings
These patch fixes 3 compiler warnings introduce by my recent patches.
2012-10-19 23:48:04 +02:00
Peter Lieven
ad9cd56b2d Add setters for TCP keepalive values
This patch adds 3 functions to set the 3 keepalive values TCP_KEEPIDLE, TCP_KEEPCNT
and TCP_KEEPINTVL. The values have to be set after iscsi context creation and are
then configured on the socket on each new connection.
2012-10-19 23:40:12 +02:00
Ronnie Sahlberg
abd20f3587 Use the literal ISCSI_STATUS_REDIRECT instead of the numeric value 2012-10-18 20:03:58 -07:00
Peter Lieven
326b2ea49d Add backoff mechanism to iscsi_reconnect
This patch adds a linear backoff mechanishm + jitter in case
a reconnect fails. If there is a longer outage this is to
avoid a large amount of simultaneous connects to the storage.
2012-10-18 12:18:40 +02:00
Peter Lieven
f973608578 Add iscsi_tcp_set_user_timeout function
This patch adds a user configurable option to set the TCP_USER_TIMEOUT
socket option. With this timeout set a broken TCP session is shutdown
after a given timeout even there are unacked packets. SO_KEEPALIVE
seems not to work in this case.
2012-10-18 11:55:15 +02:00
Peter Lieven
cb6f2ce252 iSCSI Redirect support
This patch adds support for persistant portals like they are common
to storage arrays with different interfaces or physical members.
2012-10-18 10:48:52 +02:00
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
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
77d8e41be7 TESTS: Add a mechanism to temporarily disable the session reconnect
Some tests may cause a target to drop the session.
For these tests we DO want the test tool to detect that the command
failed and later reconnect the session again when we proceed to the next subtest

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2012-08-01 16:32:40 +10:00
Ronnie Sahlberg
6f4afb6edb MEDIUM_NOT_PRESENT/TRAY-CLOSED/TRAY_OPEN is not an error that blocks a successful connect 2012-07-12 18:55:35 +10:00
Ronnie Sahlberg
801bfb342d Login: dont fail the login just because there is no media in a device
in that case we will never reach test unit ready being successful since it will fail with NOT_READY/MEDIUM_NOT_PRESENT.
Treat this sense code as a successful login as far as the login process is concerned
2012-07-11 15:33:32 +10:00
Ronnie Sahlberg
dafa186868 win32: connect.c needs the compatibility functions 2012-05-15 21:54:10 +10:00
Ronnie Sahlberg
05d2f81a84 win32: unistd.h is not available under win32 2012-05-15 21:45:30 +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
Ronnie Sahlberg
343d86dca7 get rid of the _async() scsi functions.
We dotn need two interfaces that only diuffer in whether they return a pointer or NULL vs an semiidentical interface that returns 0 or <0

All uses of _async() for scsi tasks should be replaced with the equivalent _task() function instead
2011-03-27 18:17:12 +11:00
Ronnie Sahlberg
f4f6ef5033 change dont automatically free the scsi_task once the callback completes.
Freeing the scsi_task structure is the responsibility of the application
to either do so during the callback, or later.
2011-03-27 17:53:05 +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
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