Commit Graph

210 Commits

Author SHA1 Message Date
bdrewery
ed99ba5f08 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2016-02-16 02:14:30 +00:00
mav
1ca3ca2fd3 Don't check CmdSN for initial login request.
This fixes connection errors for some initiators not starting CmdSN
from zero.

While there, fix wrong status details reported for couple errors.

MFC after:	3 days
2016-02-12 10:58:13 +00:00
jceel
dac55bd53a Add an additional, libucl-based configuration file parser to ctld.
Default ctld behavior remains unchanged - libucl parser can be selected
explicitly by adding -u switch to ctld command line.

Reviewed by:	trasz
Approved by:	trasz (mentor)
MFC after:	1 month
Relnotes:	yes
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D4534
2016-02-03 15:45:13 +00:00
bdrewery
fe1ef27d4a META MODE: Update dependencies with 'the-lot' and add missing directories.
This is not properly respecting WITHOUT or ARCH dependencies in target/.
Doing so requires a massive effort to rework targets/ to do so.  A
better approach will be to either include the SUBDIR Makefiles directly
and map to DIRDEPS or just dynamically lookup the SUBDIR.  These lose
the benefit of having a userland/lib, userland/libexec, etc, though and
results in a massive package.  The current implementation of targets/ is
very unmaintainable.

Currently rescue/rescue and sys/modules are still not connected.

Sponsored by:	EMC / Isilon Storage Division
2015-12-01 05:23:19 +00:00
trasz
9ecfe4bb8b Add missing error checks.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-11-14 16:18:22 +00:00
trasz
e8f533f709 Cosmetics; no functional changes.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-11-14 16:15:38 +00:00
trasz
b1195936c3 Don't try to avoid calling free(3) with NULL argument.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-11-14 16:06:01 +00:00
mav
63ed08e595 Introduce portal group options in ctl.conf.
While CTL has concept of port options, used at least for iSCSI ports now,
before this change it was impossible to set them manually.  There still
no user-configurable port options now, but I am planning to change that.
2015-11-09 18:33:36 +00:00
eadler
21a3003f8f Fix a ton of speelling errors
arc lint is helpful

Reviewed By: allanjude, wblock, #manpages, chris@bsdjunk.com
Differential Revision: https://reviews.freebsd.org/D3337
2015-10-21 05:37:09 +00:00
mav
8e6a38c94e Document CD block size of 2048. 2015-10-02 11:27:34 +00:00
mav
011d697052 Set default block size for CD to expected 2048 bytes. 2015-10-02 11:16:46 +00:00
mav
ba6084f689 Add to CTL initial support for CDROMs and removable devices.
Relnotes:	yes
2015-09-27 13:47:28 +00:00
mav
70f018005e Remove some duplicate, legacy, dead and questionable code. 2015-09-26 11:28:45 +00:00
jpaetzel
003e64c1ef Fix typo.
Sponsored by:	iXsystems
2015-09-25 03:46:06 +00:00
mav
e968ae531f Make cltd ignore HA ports. 2015-09-21 10:27:30 +00:00
mav
6e36742bfe Add ctl-lun config option for consistency in HA setups. 2015-09-15 13:37:48 +00:00
mav
7b4b3f9d39 Add negotiation of iSCSIProtocolLevel to 2 (RFC7144).
We may need to pass negotiated value to kernel level, but so far it is
not necessary, since it does not use any new features without request.
2015-09-13 20:58:22 +00:00
mav
7e1bc451f0 When updating port, apply only change of LUN map, not whole. 2015-09-13 15:08:06 +00:00
mav
0bc1e39132 Add two new portal group options "tag" and "foreign".
They are going to be useful in clustered setups.
2015-09-07 13:43:05 +00:00
mav
037d401b2c Allow LUN options modification via CTL_LUNREQ_MODIFY.
Not all changes take effect, but that is a different question.
2015-09-06 11:23:01 +00:00
mav
57f927630c Another addition to r287455. 2015-09-04 10:16:21 +00:00
trasz
7a19b70f33 Use proper term in the ctld(8) and iscsid(8) man pages.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-09-03 11:43:56 +00:00
trasz
6534f807e4 Simplify the introductory example in ctl.conf(5) down to absolute
basics.  The more complicated cases - like how to use physical
ports - are explained later, in the "EXAMPLES" section.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-09-03 11:42:59 +00:00
trasz
4b25d224c2 Some random tweaks to ctl.conf(5).
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-08-24 09:33:12 +00:00
mav
c9d448ea79 Drop "internal" CTL frontend.
Its idea was to be a simple initiator and execute several commands from
kernel level, but FreeBSD never had consumer for that functionality,
while its implementation polluted many unrelated places..
2015-08-15 13:34:38 +00:00
mav
35adb2b287 Refactor early stages of security negotiation.
MFC after:	2 weeks
2015-08-08 19:04:37 +00:00
mav
2039dd9ad4 Remove some code duplication.
MFC after:	1 week
2015-08-08 16:39:28 +00:00
trasz
277f7a37a2 Remove OpenSSL dependency from iscsid(8) and ctld(8).
Differential Revision:	https://reviews.freebsd.org/D2866
Submitted by:	Tony Morlan <tony at scroner.com> (earlier version)
Reviewed by:	bapt@, delphij@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-07-03 10:08:10 +00:00
mav
7fae2fa74e Plug minor memory leak at r284765.
Reported by:	Coverity
CID:		1308401
MFC after:	3 days
2015-06-26 16:14:00 +00:00
mav
fe2cd6ba68 Teach ctld about CTL's physical_port and virtual_port fields.
This allows ctld to work with isp(4) virtual ports, specifying them as
isp0/1, isp0/2, etc.  There are still problems on isp(4) layer with
disabling those ports after enabling, but hopefully they can be fixed.

MFC after:	3 days
Sponsored by:	iXsystems, Inc.
2015-06-24 15:13:27 +00:00
trasz
54d292681c Allow '@' in unquoted strings, such as with the "path" statement. Note
that one can use any character they like by using double quotes.

PR:		200895
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2015-06-18 10:17:47 +00:00
mav
3fa2da5f08 Fix bug in r278331: unlike some other options MaxRecvDataSegmentLength
is not negotiated as minimum, but only reported by sides to each other.

MFC after:	1 week
2015-06-02 01:47:12 +00:00
trasz
38f5a1dde7 Advertise ctlstat(8) a little better.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2015-05-22 11:59:37 +00:00
trasz
b02ea1ffbd Make setproctitle(3) work in Capsicum capability mode. This makes
ctld(8) child processes to indicate initiator address and name in
their titles, similar to what iscsid(8) child processes do.

PR:		181352
Differential Revision:	https://reviews.freebsd.org/D2363
Reviewed by:	rwatson@, mjg@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-04-27 11:18:16 +00:00
trasz
9eaaafc5b6 Add hint about "volmode=dev" to ctl.conf(5).
Differential Revision:	https://reviews.freebsd.org/D2328
Reviewed by:	allanjude@, bcr@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-04-21 09:11:28 +00:00
delphij
8c6f9cd4e5 Eliminate unused headers. 2015-04-14 18:13:55 +00:00
mav
bda694b503 Make ctld to not exit on ECONNABORTED on accept().
That is not really an error for the main process.

MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2015-04-06 18:56:02 +00:00
jpaetzel
4e7da03796 Fix thinko/copypaste error.
When checking the length of the mutual secret password the variable for
the secret password was used by mistake.  This resulted in ctld never
warning about the length of the mutual secret being wrong even if it was.

MFC after:	3 days
Sponsored by:	iXsystems
2015-04-04 20:55:47 +00:00
mav
2a15661be2 Add example configuration for FibreChannel ports.
MFC after:	1 week
2015-03-04 14:30:09 +00:00
mav
88b2acde96 If target name starts with "naa.", set it as WWNN for CTL port.
MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2015-03-04 14:12:38 +00:00
mav
9f7eac47b3 Fix handling of queued text and logout requests.
While it may have little sense, text and logout requests can be queued.
If they are, they consume cmdsn, so we should increment our conn_cmdsn.

MFC after:	1 week
2015-03-04 12:12:46 +00:00
trasz
8f6e16a682 Move the "offload" clause from the target section to portal-group
section; it makes more sense there.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-28 12:02:32 +00:00
trasz
aaa1b9d644 Add missing error check.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-26 09:08:48 +00:00
mav
d68c33b6c0 Fix memory leak on incorrect initiator portal.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	3 days
2015-02-25 10:10:40 +00:00
mav
0e35eb1dd3 Add checks for malloc() failures.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	3 days
2015-02-25 10:07:39 +00:00
trasz
a4c9135bbf Remove unused code.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-12 11:57:31 +00:00
mav
3b46dbba59 Add missing asprintf() status checks.
MFC after:	2 weeks
2015-02-11 19:57:38 +00:00
trasz
3461fbe326 Fix formatting.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-11 17:00:32 +00:00
mav
43853f6915 Teach ctld(8) to control non-iSCSI CTL ports.
This change introduces new target option "port", that assigns current target
to specified CTL port.  On config application ctld(8) will apply LUN mapping
according to target configuration to specified port and bring the port up.
On shutdown cltd(8) will remove the mapping and put the port down.

This change allows to configure both iSCSI and FibreChannel targets in the
same configuration file in alike way.

Kernel side support was added earlier at r278037.

MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	iXsystems, Inc.
2015-02-07 13:19:04 +00:00
trasz
ba70dc0f4d Make it possible to set (via ctl.conf(5)) and query (via ctladm islist -v)
target iSCSI offload.  Add mechanism to query maximum receive data segment
size supported by chosen hardware offload module, and use it in ctld(8)
to determine the value to advertise to the other side.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-06 21:03:25 +00:00
mav
7bd92dacb8 Add support for multiple portal groups per target.
This change allows multiple "portal-group" options to be specified per
target.  Each of them may include new optional auth-group name parameter
to override per-target auth parameters for specific portal group.

Kernel side support was added earlier at r278161.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2015-02-06 17:43:13 +00:00
mav
4bbf5a53e0 Bring some more order into iSCSI portal group tags support.
While ctld(8) still does not allow multiple portal groups per target
to be configured, kernel should now be able to handle it.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2015-02-03 16:17:54 +00:00
mav
8adb86862b CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports.  By default all ports are created without LUN mapping, exposing all
CTL LUNs as before.  But, if needed, LUN mapping can be manually set on
per-port basis via ctladm.  For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.

Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition.  LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed.  It
allows same LUN to be exposed several times via multiple targets.

While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.

Discussed with:	trasz
MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	iXsystems, Inc.
2015-02-01 21:50:28 +00:00
mav
ad2edff826 Slightly polish iSCSI parameters negotiation.
MFC after:	1 week
2014-12-19 01:12:22 +00:00
mav
fe9781bb78 Make sequence numbers checks more strict.
While we don't support MCS, hole in received sequence numbers may mean
only PDU loss.  While we don't support lost PDU recovery, terminate the
connection to avoid stuck commands.

While there, improve handling of sequence numbers wrap after 2^32 PDUs.

MFC after:	2 weeks
2014-12-17 15:13:21 +00:00
mav
a0aca4af78 Do not corrupt the listen string when parsing it.
This fixes problem with ctld reload when it is configured to listen on two
portals with same IP, but different ports.

MFC after:	1 week
2014-12-03 09:32:51 +00:00
trasz
84e2f9fb80 Fix null pointer dereference.
MFC after:	2 weeks
Coverity CID:	1256497
Sponsored by:	The FreeBSD Foundation
2014-12-02 07:42:25 +00:00
bapt
a191ba5195 Convert usr.sbin to LIBADD
Reduce overlinking
2014-11-25 16:57:27 +00:00
trasz
bf894082e1 Remove the pidfile clause from the ctl.conf example. Why do everyone
just copy/paste this line into their configs, it's beyond me.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-11-24 08:13:44 +00:00
mav
2efae2e6b1 For both iSCSI initiator and target increase socket buffer sizes before
establishing connection.

This is a workaround for Chelsio TOE driver, that does not update socket
buffer size in hardware after connection established, and unless that is
done beforehand, kernel code will stuck, attempting to send/receive full
PDU at once.

MFC after:	1 week
2014-11-22 15:09:18 +00:00
mav
69cdfe7aaa In conf_apply() remove iSCSI ports from kernel before removing LUNs.
Previous order confused initiators with messages about "removed" LUNs
during simple ctld restart without any real config change.  After this
commit initiators only reestablish lost connection, receive "Power on
occurred" UNIT ATTENTION status and continue normal operation.

MFC after:	1 month
2014-11-21 18:00:00 +00:00
trasz
e46d09e9b4 Fix error handling.
MFC after:	1 month
Coverity CID:	1249768
Sponsored by:	The FreeBSD Foundation
2014-11-21 16:14:32 +00:00
trasz
a2fcd43154 Add missing error checking for kernel_port_{add,remove}(). Both can fail
for reasons yet unknown; don't make it increment cumulated_error as a kind
of temporary workaround.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-11-21 12:35:18 +00:00
mav
4fd3a4b49d Make both iSCSI initiator and target support base64 encoded CHAP data.
While all tested initiators and targets use hex-encoded CHAP data, RFC also
allows base64 encoding there, and Microsoft certificaition tool uses it.

Reviewed by:	trasz (earlier version)
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2014-11-09 20:39:08 +00:00
trasz
efd809dc2c Add HISTORY section to ctld(8).
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-11-09 13:45:35 +00:00
trasz
add2b53fb7 Fix several nits in redirection handling - don't use wrong CSG,
and avoid use-after-free.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-11-09 13:30:02 +00:00
trasz
4eec651ec3 Add support for sending redirections to iSCSI target.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-11-09 13:01:09 +00:00
trasz
e03debee49 Improve wording in ctl.conf(5).
Differential Revision:	https://reviews.freebsd.org/D1020
Reviewed by:	bcr@ (earlier version), wblock@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-11-08 07:54:34 +00:00
trasz
ccd386cc51 ctld(8) doesn't require -lcam or -lssl; remove those from DPADD and LDADD.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-11-08 07:50:57 +00:00
mav
05828b159d Remove unused assignments, noticed by Clang analyzer.
MFC after:	1 week
2014-11-07 19:32:10 +00:00
trasz
3af53d3840 Fix iscsictl(8) and ctld(8) to correctly handle Windows newlines
(CRLF) in iscsi.conf and ctl.conf.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-29 12:22:32 +00:00
trasz
a0b8eaf0d7 Keep the token list sorted.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-29 12:12:27 +00:00
trasz
904bb3735c Make it possible to optionally use semicolon to separate statements.
This makes it possible to format stuff like this:

target xxx {
	lun 0 { path /foo/bar; size 4G; }
}

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-29 12:10:39 +00:00
trasz
a68c33061f Simplify code; no functional changes.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-29 09:36:02 +00:00
trasz
b73c1cc9fd Add discovery-filter. This makes it possible to restrict which targets
are returned during discovery based on initiator portal, name, and CHAP
credentials.

Reviewed by:	mav@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-29 09:26:55 +00:00
trasz
df22f3557c Document iSNS defaults.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-28 17:11:51 +00:00
trasz
c5fce01b6c Fix build after previous commit. While here, improve error messages.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-28 10:39:29 +00:00
trasz
962052e82a Remove the distinction between strings and numbers from ctld(8) yacc parser.
This fixes problems with passing strings that look like numbers to clauses
that expect strings; previously it caused syntax errors and had to be worked
by user, using quotes.  The workaround introduced in r267833 is no longer
neccessary.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-28 10:25:59 +00:00
mav
b91222fa4f Add basic iSNS client to the iSCSI target.
This makes ctld(8) register its iSCSI targets and portals on configured
iSNS servers to allow initiators find them without active discovery.

Fetching of allowed initiators from iSNS is not implemented now, so target
ACLs still should be configured manually.

Reviewed by:	trasz@
MFC after:	1 month
Sponsored by:	iXsystems, Inc.
2014-10-25 12:50:26 +00:00
trasz
cbbca2de4d Improve ctld.conf example.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-24 12:30:43 +00:00
trasz
904ee8f937 Make the initiator-name and initiator-portal checks a little nicer.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-24 11:40:09 +00:00
trasz
e2e58f80cc Tidy up the login code; no functional changes.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-24 11:34:55 +00:00
trasz
c0426e480a Clean up (refactor) discovery a little; no functional changes.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-23 12:02:27 +00:00
trasz
79512487f6 Fix ctl.conf example to use proper paths to ZVOLs.
Sponsored by:	The FreeBSD Foundation
2014-10-22 11:30:56 +00:00
trasz
d7bc948e22 Remove misleading statement. Bump date.
MFC after:	1 month
Sponsored by:	FreeBSD Foundation
2014-10-22 11:09:03 +00:00
trasz
6699434523 Comment out parts about iSER; it's not implemented.
Sponsored by:	The FreeBSD Foundation
2014-10-22 11:06:05 +00:00
trasz
8ba411fe7f Remove spurious empty line.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-22 10:53:25 +00:00
trasz
2ea90ce174 Fix ctld(8) to not show the "auth-group <name> not assigned to any target"
warning for auth-groups assigned to a portal-group.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-22 09:40:46 +00:00
trasz
853fc00c2a Whitespace fixes.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-22 09:17:17 +00:00
trasz
1bb0800b27 Untangle iSCSI authentication code by splitting off the CHAP
implementation.

Reviewed by:	mav@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-22 08:59:23 +00:00
mav
96aaf8224f Make ctld start even if some LUNs are unable to open backing storage.
Such LUNs will be visible to initiators, but return "not ready" status
on media access commands.  If backing storage become available later,
`ctladm modify ...` or `service ctld reload` can trigger its reopen.
2014-10-10 19:41:09 +00:00
mav
1ebae729f6 Make kernel to update LUN size from the backing storage on configuration
reload also if that size was not specified in the new configuration.

Previously it happened only if size was explicitly changed in config.

MFC after:	3 days
2014-09-18 17:39:04 +00:00
trasz
db159e8ff5 Fix two small nits in ctl.conf(5).
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2014-09-14 08:35:44 +00:00
allanjude
5f36980b65 Resolve an ambiguity with the definition of a new auth-group
Resolve a markup mistake

Reviewed by:	trasz
Approved by:	bcr (mentor), wblock (mentor)
Sponsored by:	ScaleEngine Inc.
CR:		https://reviews.freebsd.org/D735
2014-09-13 23:50:51 +00:00
allanjude
b118acaf2c Fix minor syntax error
Submitted by:	bjk
Approved by:	bcr (mentor)
Sponsored by:	ScaleEngine Inc.
2014-09-12 00:55:42 +00:00
allanjude
b298d28b8d Improve markup and language throughout the ctl.conf man page
Reviewed by:	trasz
Approved by:	bcr (mentor)
Sponsored by:	ScaleEngine Inc.
2014-09-12 00:08:19 +00:00
trasz
b7774f528d Use keys_add_int() where appropriate. No functional changes.
Sponsored by:	The FreeBSD Foundation
2014-09-09 16:57:02 +00:00
trasz
7fd1fb1a76 Fix ctld(8) to not forget to send TargetPortalGroupTag and TargetAlias
when the initiator skips security negotiation.  This fixes interoperability
with Xtend SAN initiator.

PR:		193021
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2014-09-09 16:45:36 +00:00
trasz
730358ef21 Avoid ctld(8) crash on getaddrinfo(3) failure.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2014-09-06 09:03:13 +00:00
trasz
ca6e877354 Document initiator-portal netmask support.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2014-09-05 14:58:24 +00:00