Commit Graph

114 Commits

Author SHA1 Message Date
agc d880ffcdf0 In READ_CAPACITY, send back the size of the LUN, not the maximum LBA,
which is zero-based.

Problem reported by, and fix verified by, Greg Oster. Thanks, Greg!
2007-11-06 15:59:10 +00:00
agc 2f510db93e Recognise the word "lun" as a synonym for "target" in the configuration
file - allows us to export luns as well as targets, which should reduce
some confusion when presenting storage to external entities.
2007-11-03 09:44:06 +00:00
agc d7728ae0d3 Update to version 20071025
Pay closer attention to the TSIH value that is assigned by the target -
rather than a simple (session id + 1) value, which cycles after 16 sessions
are used, use a central counter, and increment that whenever a TSIH is
apportioned. This fixes some problems for me with multiple targets being
ignored, and only the first target being used. Tested with the Microsoft
initiator, and the embryonic NetBSD initiator.

Use more enumerated types, rather than cpp definitions.

Use enumerated types also in preference to magic numbers.

In the iSCSI test harness, use the -t argument to specify a disk target
exported by the NetBSD iSCSI target. This allows us to test for the
situation outlined above.

Add my copyright to the test harness - there's no Intel code left anymore.

Modify the way initiator login and logout information is presented to the
user. This is only of concern to people who use this with the target in
non-detached (non-daemon) mode.

Get rid of the MODE_SENSE_10 and MODE_SELECT_10 cases in the disk switch,
since they do not return responses in the correct format yet.
2007-10-26 18:36:45 +00:00
agc 06e992a132 Correct the name of the AIX 5.3 initiator reporter (where known) 2007-10-26 18:19:36 +00:00
agc a7eecfa1f4 Add a file containing information about NetBSD iSCSI target compatibility
with various different initiators.

Any more information gratefully received (either positive or negative).
2007-10-14 11:01:21 +00:00
agc 7bc5694f64 Fix an off-by-511 error, pointed out by Andrey Yakovlev 2007-09-26 12:01:49 +00:00
agc 7dcbb17115 Bump version of the NetBSD iSCSI target to 20070925.
+ fix a reported problem with newer versions of FreeBSD which require
a block of data to be read and written, rather than a single byte.

+ add support for Extended Inquiry Data VPD Page (0x86), reported to be
necessary to interoperate with the AIX initiator.

+ add preliminary support for the Write and Verify SCSI operation (0x2e).
2007-09-25 22:16:58 +00:00
agc 91566c8774 As part of the initial checks to se ethat a writable disk really is
writable, do the touch(1) dance with 512 bytes of information, rather
than just a single byte - the single byte read and write causes
problems on newer versions of FreeBSD, I am informed.  Patch from
Andrey Yakovlev, cleaned up to compile by myself.

Add support for Extended Inquiry Data VPD Page (0x86), reported to be
necessary to interoperate with the AIX initiator.

Add preliminary support for the Write and Verify SCSI operation (0x2e).
2007-09-25 22:15:00 +00:00
agc f22b6d776c Add a utility function to copy the target information to the caller - used
in the initiator functionality to keep a track of the target details.
2007-09-25 22:09:51 +00:00
agc bfe5c01baa fix formatting in a comment 2007-09-25 22:08:10 +00:00
agc 4e1fbeb934 Might as well define MODE_SELECT_6 and MODE_SELECT_10 too before too
many people get violent.
2007-09-19 23:28:15 +00:00
agc 6a20fc2b13 Preliminary support for MODE_SELECT_{6,10} and MODE_SENSE_10.
Committed now because some high priority fixes are about to come down
the line.
2007-09-19 19:54:09 +00:00
agc e0ef0e5000 Welcome to version 20070908 - multiple targets bug fix. 2007-09-08 09:52:20 +00:00
agc c11d4df578 Resurrect the port number argument to the iSCSI test harness. 2007-09-08 09:44:24 +00:00
agc b35bda38e1 Cosmetic change to a long line
Don't reset the target session's idea of the disk id whenever input is received.
2007-09-02 18:50:49 +00:00
agc 028ef264bb Only give the AI_NUMERICSERV hint to getaddrinfo() if it's defined. 2007-09-02 18:48:45 +00:00
agc 4b38cf6082 Use AI_NUMERICSERV as a flag to getaddrinfo() when trying to find the
correct service - allows us to bind to the correct port, and not the
iSCSI control port.

Update version to 20070815, and re-run autoconf and autoheader.
2007-08-16 06:25:16 +00:00
agc 6396470148 + re-activate code to set port number in the iSCSI target
+ if the attempt to getaddrinfo() on (host,port) fails, try various
	combinations of (host,service)
+ clean up lint
+ set sess->d when we get traffic in, rather than just at iSCSI login
2007-08-14 18:52:48 +00:00
agc ad9b63f6fb Move my own code from a 4 clause to a 3 clause licence. 2007-06-16 23:13:25 +00:00
agc bcf774971d Re-generate autoconf parts.
No change to NetBSD distribution, since it is made using reachover Makefiles.
2007-06-16 10:02:23 +00:00
agc e6bf177ae1 Apply the fix from PR 36354, from yamt.
yamt's reading of RFC 3720 is correct (see section 12.10, InitialR2T).

The desired transfer length in the initial ready to transmit
negotiation should not include any immediate data.
2007-06-15 19:57:30 +00:00
agc b734ab10f3 Use the proper tracing functionality 2007-01-11 22:59:53 +00:00
agc 766d3d66b8 Get rid of some magic constants. 2007-01-11 19:57:23 +00:00
agc 977a3071b2 Explain what's happening when a target is not exporting any iSCSI
targets to the initiator rather than a cryptic message about a portal
group tag not being present.
2007-01-11 19:14:32 +00:00
agc 9f740696e2 Pass the target hostname to the iscsi_sock_connect() call, so that it's
available for getaddrinfo.

Use the correct IQN name for the NetBSD iSCSI initiator.
2007-01-11 18:56:57 +00:00
agc 0b68869633 Use getaddrinfo(3) to get the required information about the host. Use this
explicitly in iscsi_socket_connect(), and ignore the port argument to this
function for just now.
2007-01-11 18:54:58 +00:00
agc 524517b593 Make the code a bit smarter, and dynamically allocate the buffers that are
used to cache the data for the read and write operations. This will reduce the
resident set size down from 80+ MB to something much more manageable.
2007-01-10 22:40:31 +00:00
agc f980d4284c Move away from magic constants for the SCSI return codes.
Give the appropriate size bound when filling in data for the extended
INQUIRY command.
2007-01-10 18:04:31 +00:00
agc b0ab3a15b9 Return the correct length of the T10 identifier and uuid in the VPD page 83
response.

Found by the embryonic NetBSD initiator.
2007-01-09 19:08:08 +00:00
agc e1d88c5d14 read the values of max_lba and blocklen, and byte swap them if necessary,
before printing out their values.
2007-01-08 22:05:47 +00:00
agc c0040e78f5 various enhancements to make this compile with WARNS=4 2007-01-08 21:46:00 +00:00
agc eaf1b66230 Export the function to split a config file entry up into parts,
conffile_split(), and make it work in the presence of a NULL conffile
descriptor (i.e. from stdin).
2007-01-08 21:44:47 +00:00
agc a43651f235 Modify netmask calculation so that /0 is fast-tracked, and so that network
addresses with bit 31 set are processed properly.

Fix from Hiroshi Nakamoto in PR 34578.

	[22:09:17] agc@inspiron1300 ...dist/iscsi/src 26 > ./n 10.4/16 10.4.0.29 10.4/16 10.5.0.29 10.4/0 10.4.0.19 10.4 10.4.0.19 10.4.3/8 10.4.3.7 10.4.3/24 10.4.3.7
	addr 10.4.0.29 00000a04, mask 10.4.0.0 00000a04, slash 16
	mask 10.4/16 matches addr 10.4.0.29

	addr 10.5.0.29 00000a05, mask 10.4.0.0 00000a04, slash 16
	No match for mask 10.4/16 from addr 10.5.0.29

	mask 10.4/0 matches addr 10.4.0.19

	addr 10.4.0.19 0a040013, mask 10.4.0.0 0a040000, slash 32
	No match for mask 10.4 from addr 10.4.0.19

	addr 10.4.3.7 0000000a, mask 10.4.3.0 0000000a, slash 8
	mask 10.4.3/8 matches addr 10.4.3.7

	addr 10.4.3.7 000a0403, mask 10.4.3.0 000a0403, slash 24
	mask 10.4.3/24 matches addr 10.4.3.7

	[22:09:20] agc@inspiron1300 ...dist/iscsi/src 27 > ./n any 192.168.0.1
	mask any matches addr 192.168.0.1
2006-11-27 22:24:27 +00:00
christos 7631e65b9f fix an incomplete initializer. 2006-10-15 19:52:40 +00:00
agc 9410ca204b mark VPD 0x80 (Unit Serial Number VPD Page) as being done 2006-08-03 20:50:45 +00:00
agc 72a3c3e7b9 Add support for Vital Product Data 0x80, Unit Serial Number, reported to be
used by the beta FreeBSD initiator by Paul Dekkers.
2006-08-03 20:49:11 +00:00
agc 66644e0749 + add support for IPv6 in the target (CIDR scoping has still to be
implemented for IPv6, but works fine for IPv4)

+ now poll any connections opened in the target.  select is used if
poll is not available

+ remove ramdisk type of backing store, since it was never used, and
is of no use for our needs

+ bump version to 20060727
2006-08-03 20:21:59 +00:00
agc 2b1d5a0345 :g/%i/s//%d/gc
Also make a first stab at implementing persistent reserve in SCSI command.
2006-05-31 19:53:13 +00:00
agc c52b27c275 Bump version number for the portability fix, and the dynamic number of
sessions.
2006-05-27 21:29:32 +00:00
agc 36fad19155 Rather than hardcoding the maximum number of sessions that a target can
serve simultaneously to DEFAULT_TARGET_MAX_SESSIONS, add a -s argument to
iscsi-target(8) to specify the maximum number of sessions.

Also bump default from 4 to 16.
2006-05-27 21:21:04 +00:00
agc 6dff2af424 Include another header file - should make this compile on platforms where
arpa/inet.h does not include netinet/in.h automatically.

Some people do just make life harder for themselves.
2006-05-27 16:00:05 +00:00
agc 2fa516b2eb Rewrite the way report_luns() works, after suspicion by Matt Green, and
following Dan Carosone's suggestion of the uint64_t array.

Abstract a bit more from the HTOBE64() macro intrigue, for platforms
like Solaris/x86 which have fun in this part.

Tested only with little-endian initiators for now.

Bump version to 20060526.
2006-05-26 16:34:43 +00:00
agc 8a1a8b8c5c Include compat.h for the definition of uuid_t, in the case where we don't
have it from <uuid.h>
2006-05-25 19:41:06 +00:00
he c6974f26a9 Use the value-returning variants of the 64-bit endian macros instead
of the argument-tweaking variants (e.g. htobe64 instead of HTOBE64).
2006-05-22 20:48:08 +00:00
agc e32a776a5a Adjust the data VPD returns, to work around a problem in the Cisco
initiator (used on Solaris 10 Update 1) - the initiator demands that a
UUID is returned, so give it one.

Add autoconf glue for that, and a compat uuid_create(3) and
uuid_to_string(3).

This still spews a lot of output via the target's syslog, but persevere,
since it does actually make the target work with the Solaris initiator:

	solaris10# format
	Searching for disks...done


	AVAILABLE DISK SELECTIONS:
	       0. c1d0 <DEFAULT cyl 29728 alt 2 hd 64 sec 63>
		  /pci@0,0/pci-ide@1f,1/ide@0/cmdk@0,0
	       1. c2t5d0 <DEFAULT cyl 96 alt 2 hd 64 sec 32>
		  /iscsi/disk@0000iqn.1994-04.org.netbsd.iscsi-target%3Atarget00001,0
	Specify disk (enter its number): ^D
	solaris10# df -k /mnt
	Filesystem            kbytes    used   avail capacity  Mounted on
	/dev/dsk/c2t5d0s0      91407    1041   81226     2%    /mnt
	solaris10# uname -a
	SunOS solaris10 5.10 Generic_118844-26 i86pc i386 i86pc
	solaris10#
2006-05-21 09:26:37 +00:00
christos 19a2d0dbea Coverity CID 3197: Don't leak fp. 2006-05-13 22:50:24 +00:00
uwe ee952d9fc0 Use be64toh/htobe64 instead of upper-case versions.
Thanks to lint that caught this on big-endian arches.  Little-endian
compiled, but I guess that converting your loop counter into
big-endian inside the loop is not exactly what you want to do.
2006-04-30 01:07:59 +00:00
agc 62b10a5c9c Rather than hardcoding 8 LUNs per disk, use the number for the disc. 2006-04-26 20:31:43 +00:00
agc 84fba20a22 Use the correct opcode for the WRITE6 SCSI command 2006-04-26 20:29:56 +00:00
agc 000a68021a + Some minor formatting cleanup in the header files.
+ Properly pad the names with spaces (with thanks to Bill Studenmund)
+ Use the official T10 vendor name, "NetBSD".
+ Minor cleanup in the INQUIRY command
+ Rather than just punting on the REPORT LUNs SCSI command, emulate it
properly.  This change makes the target work with the Solaris initiator:

	AVAILABLE DISK SELECTIONS:
	       0. c1d0 <DEFAULT cyl 29728 alt 2 hd 64 sec 63>
		  /pci@0,0/pci-ide@1f,1/ide@0/cmdk@0,0
	       1. c2t5d0 <DEFAULT cyl 97 alt 2 hd 64 sec 32>
		  /iscsi/disk@0000iqn.1994-04.org.netbsd.iscsi-target%3Atarget00001,0
	Specify disk (enter its number): 1
2006-04-24 21:59:03 +00:00