Commit Graph

73 Commits

Author SHA1 Message Date
Alexander Motin
9215e501b9 Do not register in CTL portal groups without portals.
From config synthax point of view such portal groups are not incorrect,
but they are useless since can not receive any connection.  And since
CTL port resource is very limited, it is good to save it.

MFC after:	2 weeks
2017-04-10 10:38:12 +00:00
Alexander Motin
59c6e3a58f Decouple iSCSI connection limits from defaults.
If initiator does not negotiate some parameter, it expects one to get
default value, not some unknown remote hardware limit.  On the side side,
if some parameter is negotiated, its default value from RFC should not
be used for anything.
2017-01-14 18:04:12 +00:00
Xin LI
9a913ec291 Plug another leak with malformed IPv6 address.
MFC after:	2 weeks
2016-11-28 07:41:01 +00:00
Xin LI
203632f263 Don't leak 'str' when we see a malformed IPv6 address.
MFC after:	2 weeks
2016-11-28 07:33:26 +00:00
Alexander Motin
2668ec0761 There appeared to be even more copy/pastes. :)
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks
2016-10-31 16:06:57 +00:00
Alexander Motin
42f97fac5d Fix wrong copy/paste in error message.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks
2016-10-31 16:01:22 +00:00
Navdeep Parhar
97b84d344d Make the iSCSI parameter negotiation more flexible.
Decouple the send and receive limits on the amount of data in a single
iSCSI PDU.  MaxRecvDataSegmentLength is declarative, not negotiated, and
is direction-specific so there is no reason for both ends to limit
themselves to the same min(initiator, target) value in both directions.

Allow iSCSI drivers to report their send, receive, first burst, and max
burst limits explicitly instead of using hardcoded values or trying to
derive all of them from the receive limit (which was the only limit
reported by the drivers prior to this change).

Display the send and receive limits separately in the userspace iSCSI
utilities.

Reviewed by:	jpaetzel@ (earlier version), trasz@
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D7279
2016-08-25 05:22:53 +00:00
Edward Tomasz Napierala
f9a2051818 Fix ctld(8) to not exit when reloading configuration with invalid
initiator-portal clause.

MFC after:	3 days
2016-07-09 20:01:07 +00:00
Edward Tomasz Napierala
e321146fc5 Make the usage() mention the -u option added in r295212.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-04-12 16:07:41 +00:00
Jakub Wojciech Klama
5c734b0410 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
Alexander Motin
398290f29a 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
Eitan Adler
463a577b27 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
Alexander Motin
6f2f92a5bf Set default block size for CD to expected 2048 bytes. 2015-10-02 11:16:46 +00:00
Alexander Motin
91be33dc78 Add to CTL initial support for CDROMs and removable devices.
Relnotes:	yes
2015-09-27 13:47:28 +00:00
Josh Paetzel
d7b87b89b7 Fix typo.
Sponsored by:	iXsystems
2015-09-25 03:46:06 +00:00
Alexander Motin
3933f7b112 Add ctl-lun config option for consistency in HA setups. 2015-09-15 13:37:48 +00:00
Alexander Motin
828524c137 When updating port, apply only change of LUN map, not whole. 2015-09-13 15:08:06 +00:00
Alexander Motin
db7bf2baae 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
Alexander Motin
a3977bea20 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
Alexander Motin
83dd77c3c1 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
Josh Paetzel
7c924aae61 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
Edward Tomasz Napierala
a9d7821075 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
Alexander Motin
678b68798f 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
Alexander Motin
55e4579ef2 Add missing asprintf() status checks.
MFC after:	2 weeks
2015-02-11 19:57:38 +00:00
Alexander Motin
057abcb004 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
Edward Tomasz Napierala
07b49a3eed 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
Alexander Motin
92847ee1f3 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
Alexander Motin
6b31e1302f 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
Alexander Motin
920c6cbadc 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
Alexander Motin
1606ad8c42 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
Edward Tomasz Napierala
0dd2bee428 Fix null pointer dereference.
MFC after:	2 weeks
Coverity CID:	1256497
Sponsored by:	The FreeBSD Foundation
2014-12-02 07:42:25 +00:00
Alexander Motin
8b94b5836c 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
Alexander Motin
6de78f9f24 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
Edward Tomasz Napierala
e48bb73a2a 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
Edward Tomasz Napierala
6dbdbf825d 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
Alexander Motin
d5cc4a4a61 Remove unused assignments, noticed by Clang analyzer.
MFC after:	1 week
2014-11-07 19:32:10 +00:00
Edward Tomasz Napierala
bd833b11c2 Simplify code; no functional changes.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-29 09:36:02 +00:00
Edward Tomasz Napierala
0537488353 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
Alexander Motin
829603e21f 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
Edward Tomasz Napierala
e867e16225 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
Edward Tomasz Napierala
4e5c38f8b7 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
Edward Tomasz Napierala
2bd282696a Whitespace fixes.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-22 09:17:17 +00:00
Alexander Motin
8cf98331b0 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
Edward Tomasz Napierala
44a5953aa1 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
Edward Tomasz Napierala
0488e848d9 Turn two errors, which are possible to trigger only by bugs,
into assertions.

Discussed with:	mav@
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2014-09-05 14:48:06 +00:00
Edward Tomasz Napierala
b7a65e3936 Make the iSCSI stack use __FBSDID() properly.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2014-08-21 15:32:38 +00:00
Alexander Motin
5e46a0660e Fix r269183 build woth GCC.
MFC after:	2 weeks
2014-07-28 14:32:20 +00:00
Alexander Motin
073edb1c91 Add netmasks support to initiator-portal option.
MFC after:	2 weeks
2014-07-28 12:47:09 +00:00
Alexander Motin
917d38fb99 Create separate CTL port for every iSCSI target (and maybe portal group).
Having single port for all iSCSI connections makes problematic implementing
some more advanced SCSI functionality in CTL, that require proper ports
enumeration and identification.

This change extends CTL iSCSI API, making ctld daemon to control list of
iSCSI ports in CTL.  When new target is defined in config fine, ctld will
create respective port in CTL.  When target is removed -- port will be
also removed after all active commands through that port properly aborted.
This change require ctld to be rebuilt to match the kernel.

As a minor side effect, this allows to have iSCSI targets without LUNs.
While that may look odd and not very useful, that is not incorrect.
2014-07-05 18:15:00 +00:00
Edward Tomasz Napierala
61a2a354f8 English.
Sponsored by:	The FreeBSD Foundation
2014-04-16 11:07:29 +00:00