Commit Graph

425 Commits

Author SHA1 Message Date
Ronnie Sahlberg
c5bd95aac9 Remove the use of TCP_CORK 2013-08-04 16:15:22 -07:00
Ronnie Sahlberg
6041dcd136 Add a new function to create a scsi_task using an existing CDB 2013-08-04 14:35:58 -07:00
Ronnie Sahlberg
06eab264f6 Rewrite and simplify iscsi_iovector_readv_writev 2013-08-04 14:34:57 -07:00
Ronnie Sahlberg
4ccfe10a70 Merge pull request #71 from bonzini/aliasing-more
use scsi_get/set_uint16/32/64 in tests
2013-08-03 06:52:43 -07:00
Paolo Bonzini
3916872d27 use scsi_get/set_uint16/32/64 in tests
Fixes ARM problems too.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-08-02 17:30:24 +02:00
Ronnie Sahlberg
912b5dc495 Merge pull request #67 from plieven/small_allocations
MEMORY introduce a small allocation pool
2013-08-02 06:45:35 -07:00
Paolo Bonzini
73ce7f40c8 avoid casting struct sockaddr
On ARM, this produces a warning.  Use a union instead.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-08-02 15:06:16 +02:00
Paolo Bonzini
31a3aeb0e0 fix another aliasing problem
scsi_set_uint64 should just use scsi_set_uint32, similar to
what scsi_get_uint64 does.  This avoids problems on architectures
where "uint32_t" requires more alignment than "char", e.g. ARM.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-08-02 14:07:42 +02:00
Ronnie Sahlberg
49698e0322 Dont fail the login just because a sanitize is in progress 2013-07-21 14:04:41 -07:00
Ronnie Sahlberg
804c5b0211 Dont reference *pdu after it has been freed 2013-07-21 13:29:43 -07:00
Ronnie Sahlberg
83a0cd90f9 Add SANITIZE_IN_PROGRESS ASCQ 2013-07-21 09:55:35 -07:00
Ronnie Sahlberg
52a83e91af Add POWER_CONDITION modepage marshalling/unmarshalling 2013-07-20 15:35:38 -07:00
Ronnie Sahlberg
fd38ff4bfc Add MODESENSE6/10 and MODESELECT6/10 support 2013-07-20 14:05:20 -07:00
Ronnie Sahlberg
e556a0399b SCSI MODESELECT: leave the 4/8 byte header completely blank.
The convention is to not fill this header in when sending modeselect to a target
2013-07-20 09:08:52 -07:00
Peter Lieven
d429276907 MEMORY introduce a small allocation pool
This patch finally introduces a small allocation pool
which recycles all the small portions of memory that
are used for headers and pdu structures. This was
the initial idea behind wrapping all memory functions
in libiscsi.

The results of booting are test system up to the login
prompt are quite impressive:

BEFORE:
libiscsi:5 memory is clean at iscsi_destroy_context() after 10712 mallocs, 18 realloc(s) and 10712 free(s)

AFTER:
libiscsi:5 memory is clean at iscsi_destroy_context() after 41 mallocs, 18 realloc(s), 41 free(s) and 10584 reused small allocations

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-07-18 11:15:56 +02:00
Ronnie Sahlberg
cc02faabb0 Add TCP_CORK support when available 2013-07-10 14:14:36 -07:00
Ronnie Sahlberg
9e9ca71247 Modesense6 decoding bugs, start preparing for modesense10 decoding 2013-07-08 01:31:03 -07:00
Ronnie Sahlberg
ebb1f06830 Add parameter list length error sense code 2013-07-06 23:35:03 -07:00
Ronnie Sahlberg
a51d706d32 Add invalid field in parameter list sense code 2013-07-06 22:35:36 -07:00
Ronnie Sahlberg
7895fb700c Add MODESELECT6 support
Add support for MODESELECT6 and add marshalling functions for the
mode pages we support so far.
2013-07-06 16:11:17 -07:00
Ronnie Sahlberg
b6e5af558d Unmarshall support for Control modepage 2013-07-05 22:38:45 -07:00
Ronnie Sahlberg
3edd40953e TESTS: SANITIZE, Add tests for WABEREQ/WACEREQ 2013-07-05 14:25:43 -07:00
Paolo Bonzini
0a7c084603 scsi-lowlevel: do not use unsafe pointer casts
Casting unsigned char * pointers to uint32_t * may cause wrong
results if the pointers are not correctly aligned.  Instead,
build up the big-endian values from each byte with multiple
dereferences of the original pointer.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-01 16:00:25 +02:00
Ronnie Sahlberg
8140c5b726 Flag another argument as _U_ 2013-06-29 11:20:23 -07:00
Ronnie Sahlberg
bc7b1dc600 Add _U_ to some variables that might be unused 2013-06-29 11:14:46 -07:00
Ronnie Sahlberg
b555bbebdd Add a cast to ssize_t 2013-06-29 11:12:41 -07:00
Ronnie Sahlberg
21a6a08814 Update libiscsi.def/.syms for iscsi_set_bind_interfaces
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2013-06-25 20:15:35 -07:00
Ronnie Sahlberg
e061cba1b9 URL encoded Targetnames
Assume target names are URL encoded with '%' as the special character.

Any sequence of '%' followed by two bytes in the target name will be replaced
with the byte that the second two bytes represent in hexadecimal.

Example
iqn.ronnie.test%3A1234
will be translated to iqn.ronnie.test:1234
2013-06-16 11:35:14 -07:00
Bart Van Assche
49d1145a10 Next to BUS RESET, also accept NEXUS LOSS unit attention after login
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2013-06-08 07:44:43 -07:00
Ronnie Sahlberg
dcb9504ec0 READ6, make the truncation from a potantial 9-bit value (0-256) to 8 bits
explicit by masking it with 0xff instead of relying on obscure truncation
rules.
2013-05-30 19:29:53 -07:00
Bart Van Assche
7b011a5ee2 Fix scsi_cdb_read6()
The maximum number of blocks that can be transferred at once via a READ6
command is 256 instead of 265.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2013-05-29 18:56:27 -07:00
Bart Van Assche
9dce01bbea Fix PERSISTENT RESERVE IN / READ RESERVATION response unmarshalling
The code that verifies the pr_type response must compare only the
lower four bits of byte 21 of the response ("TYPE") and must ignore
the upper four bits ("SCOPE").

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2013-05-29 18:56:00 -07:00
Bart Van Assche
0577fa9d66 Fix a buffer overflow in the code for unmarshalling the, PERSISTENT RESERVE IN / READ RESERVATION
If no reservation is held a SCSI target sends a response that is eight
bytes long while scsi-lowlevel.c fills in the first twelve bytes of a
data structure for which only eight bytes are allocated. Fix this buffer
overflow by always allocating a full
scsi_persistent_reserve_in_read_reservation structure.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2013-05-29 18:55:02 -07:00
Ronnie Sahlberg
99a74310a2 Block Device Characteristics: Add decode of the rest of this page that was missing 2013-05-27 08:28:26 -07:00
Ronnie Sahlberg
4e08d27031 Add tests from SANITIZE OVERWRITE parameter length 2013-05-26 15:21:43 -07:00
Ronnie Sahlberg
92b987de52 Add helpers for the SANITIZE service actions 2013-05-26 10:51:19 -07:00
Ronnie Sahlberg
eebd04e613 Add initial support for SANITIZE and a simple test to generate this opcode. 2013-05-25 16:02:02 -07:00
Ronnie Sahlberg
fcbeb2858f REPORT_SUPPORTED_OPCODES, serviceaction is a 16 bit integer at offset 4, not a 32 bit integer 2013-05-19 09:47:45 -07:00
Ronnie Sahlberg
4df179bfd4 TESTS: Add checks for CDB sanity to REPORT SUPPORTED OPCODES
Read all individual opcodes and check that CDB length > 0  and that
CDB[0] Usage Data is 0xFF
2013-05-19 08:18:09 -07:00
Ronnie Sahlberg
709410b1d7 TESTS: Add some REPORT SUPPORTED OPCODES tests
Add a simple test that it works or is not implemented.

Add a RCTD test to verify that with this flag clear we get command descriptors without CTDP set  and with it set we get command descriptors with CTDP set and a timeout descriptor
2013-05-18 13:56:02 -07:00
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