Commit Graph

563 Commits

Author SHA1 Message Date
Peter Lieven
fbfa6bca61 ISCSI-READCAPACITY16 fix missing free of scsi_task 2012-11-03 10:58:35 +01:00
Peter Lieven
36527c5122 Merge remote-tracking branch 'aredlich/master'
Conflicts:
	lib/init.c
	lib/socket.c
2012-11-03 10:39:23 +01:00
Peter Lieven
c4dc380262 PDU reduce number of mallocs/memcpys in iscsi_add_data()
This patch adds logarithmic malloc behaviour to iscsi_add_data().
Currently for each new call there is a new buffer allocated
and all old data is copied to the new buffer. Change this by
allocating at least PAGE_SIZE bytes and increase the allocation
by powers of 2 each time it does no longer fit.
2012-11-03 02:49:56 +01:00
Peter Lieven
d9fbe37f4b HEADERS fix early commit of new header data 2012-11-03 02:28:23 +01:00
Peter Lieven
3268ae4c88 INIT fix iscsi_destroy_url 2012-11-03 02:26: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
7f98233169 Merge remote-tracking branch 'upstream/master' 2012-11-03 01:07:40 +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
Arne Redlich
f618d08350 T1030_unsolicited_data_overflow: fix uninitialized variable warning
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-02 21:28:40 +01:00
Arne Redlich
13b1f49fe5 T1031_unsolicited_data_out: fix uninitialised variable warning
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-02 21:23:47 +01:00
Arne Redlich
d2e68d7a25 T0122_read6_invalid: suppress signed/unsigned comparison warnings
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-02 21:16:45 +01:00
Arne Redlich
0bf9b6389c Annotate iscsi_set_error with printf format attribute
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-02 21:11:30 +01:00
Arne Redlich
081ae59cdf T0105_read10_invalid: suppress signed/unsigned comparison warnings
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 17:05:47 +01:00
Arne Redlich
5cd48f87ff T0403_inquiry_supported_vpd: fix signed/unsigned comparison warning
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 17:00:46 +01:00
Arne Redlich
b5372272b1 T0422_reserve6_logout: fix compiler warnings
Remove unused labels and mark unused parameter as such.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 16:54:29 +01:00
Arne Redlich
578bdae3af T0421_reserve6_lun_reset: fix compiler warnings
Remove unused label and mark unused parameter as such.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 16:53:26 +01:00
Arne Redlich
af33ca36ff T1031_unsolicited_data_out: mark unused parameters as such
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 16:50:38 +01:00
Arne Redlich
17e8b54759 T1030_unsolicited_data_overflow: remove unused variable
old_first_burst_len is set but never used - remove it. Also replace an
  if (!ptr)
    free(ptr)
with
  free(ptr)

as the check is redundant.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 16:48:48 +01:00
Peter Lieven
389f6a8ba5 SCSI half mallocs in scsi_malloc 2012-10-31 16:46:33 +01:00
Arne Redlich
e0555555bb T0430_report_all_supported_ops: fix compiler warnings
* remove unused label
* mark unused parameter
* fix signedness warnings

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 16:46:01 +01:00
Arne Redlich
ea560255a6 T0424_reserve6_target_reset: fix compiler warnings
Remove unused labels and mark unused parameter as such.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 16:40:29 +01:00
Arne Redlich
ab411e4401 T0423_reserve6_sessionloss: fix compiler warnings
Remove unused labels and mark unused parameters as such.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 16:34:11 +01:00
Arne Redlich
d402a337e3 T0420_reserve6_simple: fix compiler warnings
Mark unused parameter as such and remove unused labels.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 16:32:12 +01:00
Arne Redlich
88341c0a73 T0410_readtoc_basic: fix compiler warnings
Remove unused labels and mark unused parameter as such.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 16:25:47 +01:00
Arne Redlich
13c253f0dc T0404_inquiry_all_reported_vpd: fix compiler warnings
* mark unused parameter as such
* wrap parens around a bitop
* remove unused labels
* fix error messages

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 16:20:55 +01:00
Arne Redlich
c195348e4d T0403_inquiry_supported_vpd: fix compiler warnings
Remove unused labels and mark unused parameter as such.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 16:12:21 +01:00
Arne Redlich
ea20edb513 T0402_inquiry_evpd: fix compiler warnings
Remove unused label and mark unused parameter as such.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 16:06:25 +01:00
Arne Redlich
6819637ddc T0401_inquiry_alloclen: fix compiler warnings
Remove unused variables and mark unused parameter as such.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 15:59:42 +01:00
Arne Redlich
e991146902 T0241_prefetch10_flags: remove unused variable
Pointed out by gcc: num_blocks is set but unused

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 15:58:31 +01:00
Arne Redlich
1be5fe1bda T0251_prefetch16_flags: remove unused variable
gcc points out that num_blocks is set but never used

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 15:55:52 +01:00
Arne Redlich
d983cdfc2c T0161_readcapacity16_alloclen: remove unused variable
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 15:54:33 +01:00
Arne Redlich
34b25f94c1 0122_read6_invalid.c: add missing include
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 15:53:08 +01:00
Arne Redlich
45ce1537f2 T0400_inquiry_basic: fix compiler warnings
gcc complains about an unused parameter (mark it as such) and unused labels
(remove 'em).

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 15:52:11 +01:00
Arne Redlich
311a63c61d T0401_inquiry_alloclen: remove unused label
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 15:50:59 +01:00
Arne Redlich
4d27ecae32 test-tool: fix initiatorname and initiatorname2 issues
gcc-4.6.3 warned about this one on several occasions:
  gcc -DHAVE_CONFIG_H -I.  -I. -I./include "-D_U_=__attribute__((unused))" -I./test-tool  -Wall -W -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -ggdb3 -O0 -MT test-tool/bin_iscsi_test-0000_testunitready_simple.o -MD -MP -MF test-tool/.deps/bin_iscsi_test-0000_testunitready_simple.Tpo -c -o test-tool/bin_iscsi_test-0000_testunitready_simple.o `test -f 'test-tool/0000_testunitready_simple.c' || echo './'`test-tool/0000_testunitready_simple.c
  test-tool/0000_testunitready_simple.c: In function 'T0000_testunitready_simple':
  test-tool/0000_testunitready_simple.c:23:44: warning: declaration of 'initiator' shadows a global declaration [-Wshadow]
  test-tool/iscsi-test.h:20:20: warning: shadowed declaration is here [-Wshadow]

For now the global initiator is renamed to initiatorname1 (and initiator2 is
renamed to initiatorname2, respectively), but ultimately the globals should
probably go away.

While fixing this it also became apparent that initiator-name-2 was parsed
into the "initiator" variable as well.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 15:32:18 +01:00
Arne Redlich
3af45f5867 testunitready_simple: fix compiler warnings
The compiler complains about an unused label and and unused
variable.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 15:19:55 +01:00
Arne Redlich
558ad00038 iscsi_service_reconnect_if_loggedin: fix compiler warning and make it static
Quoth gcc-4.6.3:
  libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -I./include "-D_U_=__attribute__((unused))" -Wall -W -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -g -O2 -MT lib/socket.lo -MD -MP -MF lib/.deps/socket.Tpo -c lib/socket.c  -fPIC -DPIC -o lib/.libs/socket.o
  lib/socket.c:445:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]

Fix this and make it a static function.
Also remove trailing whitespace from this file while at it.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 14:39:51 +01:00
Arne Redlich
b910efa7c5 iscsi_parse_url: fix spurious compiler warnings
gcc-4.6.3 reports these:
  libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -I./include "-D_U_=__attribute__((unused))" -Wall -W -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -g -O2 -MT lib/init.lo -MD -MP -MF lib/.deps/init.Tpo -c lib/init.c  -fPIC -DPIC -o lib/.libs/init.o
  lib/init.c: In function 'iscsi_parse_url':
  lib/init.c:410:18: warning: 'l' may be used uninitialized in this function [-Wuninitialized]
  lib/init.c:409:10: warning: 'target' may be used uninitialized in this function [-Wuninitialized]

Both warnings appear to be spurious though, as both "target" and "l" are only used if
"full" is set, which implies that these are initialized before.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-10-31 14:34:30 +01:00
Ronnie Sahlberg
6507f4050f Merge pull request #31 from plieven/master
memory leak fixes + suggestion for iscsi context + qemu-kvm bug
2012-10-30 18:54:38 -07:00
Ronnie Sahlberg
1d56c2f970 Merge pull request #33 from jongrimm/master
Skip test for read supported ops, rather than failure
2012-10-30 18:50:48 -07:00
Ronnie Sahlberg
9e9c6946c0 TESTS: Add a test that a target handles an unsolicited DATA-OUT correctly.
Send a large number of DATA-OUT PDUs that do not have a matching SCSI-COMMAND
PDU and verify that the target responds correctly. Either by terminating the
session or by just ignoring the data.

Verify also that the target is not "surprised" and crashes.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2012-10-30 18:44:35 -07:00
Ronnie Sahlberg
48d5ab9f39 Fix typo
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2012-10-30 18:33:58 -07:00
Peter Lieven
1d348de71f INIT fix typo in iscsi_parse_url() 2012-10-30 21:00:46 +01:00
Peter Lieven
a9257d52a7 CONNECT only read/write from sockets when connection is established
qemu-kvm/qemu-img starts in+out polls from the socket before the connection is
established. This leads to a hang if the connection cant be established
(i.e. the target is down when qemu-kvm is started).

before:
LIBISCSI_DEBUG=2 qemu-img convert -f iscsi -O raw iscsi://127.0.0.1/iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac/0 /dev/null
libiscsi: connecting to portal 127.0.0.1 [iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac]
libiscsi: read from socket failed, errno:111 [iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac]
libiscsi: connection to 127.0.0.1 established [iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac]
->success!!

after:
LIBISCSI_DEBUG=1 qemu-img convert -f iscsi -O raw iscsi://127.0.0.1/iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac/0 /dev/null
libiscsi: iscsi_service: socket error Connection refused(111) while connecting. [iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac]
libiscsi: Failed to connect to iSCSI socket. iscsi_service: socket error Connection refused(111) while connecting. [iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac]
qemu-img: iSCSI: Failed to connect to LUN : Failed to connect to iSCSI socket. iscsi_service: socket error Connection refused(111) while connecting.
qemu-img: Could not open 'iscsi://127.0.0.1/iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac/0': Invalid argument
qemu-img: Could not open 'iscsi://127.0.0.1/iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac/0'
2012-10-30 17:22:39 +01:00
Peter Lieven
a0fb2d179d ERROR fix error string creation
At some points in the code the error string includes itself. This
generates self-repeating error messages.
2012-10-30 16:38:09 +01:00
Peter Lieven
820410526e INIT fix missing export of iscsi_set_tcp_syncnt() 2012-10-30 12:05:25 +01:00
Peter Lieven
ef3b6fe911 INIT fix url parsing error message 2012-10-30 12:02:09 +01:00
Peter Lieven
ca6f28437a INIT remove redundant url parsing code 2012-10-30 11:56:12 +01:00
Peter Lieven
9f82d0bf83 INIT allow a trailing / in iscsi_parse_portal_url() 2012-10-30 11:47:12 +01:00