Commit Graph

77 Commits

Author SHA1 Message Date
Richard Scheffenegger
bd6bb49397 iscsi: per-session timeouts and rapid teardown of session on reconnect
Add per-Session configurable ping (SCSI NOP) and login timeouts.

Remove the torn down, old iSCSI session quickly, when performing a reconnect.

Reviewed By: trasz
Sponsored by:        NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D34198
2022-02-25 10:35:47 +01:00
John Baldwin
b406897911 iscsi: Handle large Text responses.
Text requests and responses can span multiple PDUs.  In that case, the
sender sets the Continue bit in non-final PDUs and the Final bit in
the last PDU.  The receiver responds to non-final PDUs with an empty
text PDU.

To support this, add a more abstract API in libiscsi which accepts and
receives key sets rather than PDUs.  These routines internally send or
receive one or more PDUs.  Use these new functions to replace the
handling of TextRequest and TextResponse PDUs in discovery sessions in
both ctld and iscsid.

Note that there is not currently a use case for large Text requests
and those are still always sent as a single PDU.  However, discovery
sessions can return a text response listing targets that spans
multiple PDUs, so the new API supports sending and receiving multi-PDU
responses.

Reported by:	Jithesh Arakkan @ Chelsio
Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D33548
2021-12-29 14:36:04 -08:00
John Baldwin
c74ab5ce6f iscsid: Always free the duplicated address in resolve_addr().
If a "raw" IPv6 address (denoted by a leading '[') is used as a target
address, then 'arg' is incremented by one to skip over the '['.
However, this meant that at the end of the function the wrong address
was passed to free().  With malloc junking enabled and given suitably
small strings, malloc() would happily overwrite the correct number of
bytes with junk, but off by one byte overwriting the byte after the
allocation.

This manifested as the first byte of the 'HeaderDigest' key being
overwritten causing the key name on the wire to be sent as
'\x5eaderDigest' which the target rejected.

Reported by:	Jithesh Arakkan @ Chelsio
Found with:	ASAN (via WITH_ASAN=yes)
Sponsored by:	Chelsio Communications
2021-12-28 16:49:46 -08:00
John Baldwin
25700db366 libiscsiutil: Change keys_load/save to operate on data buffers.
This will be used in future changes to support large text requests
spanning multiple PDUs.

Provide wrapper functions keys_load/save_pdu that operate use a PDU's
data buffer.

Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D33547
2021-12-22 10:43:24 -08:00
John Baldwin
6378393308 Add an internal libiscsiutil library.
Move some of the code duplicated between ctld(8) and iscsid(8) into a
libiscsiutil library.

Sharing the low-level PDU code did require having a
'struct connection' base class with a method table to permit separate
initiator vs target behavior (e.g. in handling proxy PDUs).

Reviewed by:	mav, emaste
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D33544
2021-12-22 10:43:11 -08:00
Ed Maste
fc79cf4fea iscsid: set max_recv_data_segment_length to what we advertise
Previously we updated the conection's conn_max_recv_data_segment_length
only when we received a response containing MaxRecvDataSegmentLength
from the target.  If the target did not send MaxRecvDataSegmentLength
then we left conn_max_recv_data_segment_length at the default (i.e.,
8192).  A target could then send more data than that defult (up to our
advertised maximum), and we would drop the connection.

RFC 7143 specifies that MaxRecvDataSegmentLength is Declarative, not
negotiated.  Just set conn_max_recv_data_segment_length to our
advertised value in login_negotiate().

PR:		259355
Reviewed by:	mav
MFC after:	1 week
Fixes:		a15fbc904a ("Alike to r312190 decouple iSCSI...")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32605
2021-10-25 16:25:15 -04:00
John Baldwin
91c62d626d iscsid: Disable TCP DDP for connection sockets.
cxgbei is not able to offload PDU processing for a socket using TCP
DDP offload.

Sponsored by:	Chelsio Communications
2021-09-13 09:57:54 -07:00
Edward Tomasz Napierala
a7972b4904 iscsid(8): fix memory leak by freeing the 'addr'
Reviewed By:	mav
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27328
2020-12-29 14:53:06 +00:00
Edward Tomasz Napierala
7db3d97e0f iscsid(8): free data allocated by getaddrinfo(3)
Reviewed By:	mav
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27329
2020-12-29 14:52:23 +00:00
Edward Tomasz Napierala
bce7ee9d41 Drop "All rights reserved" from all my stuff. This includes
Foundation copyrights, approved by emaste@.  It does not include
files which carry other people's copyrights; if you're one
of those people, feel free to make similar change.

Reviewed by:	emaste, imp, gbe (manpages)
Differential Revision:	https://reviews.freebsd.org/D26980
2020-10-28 13:46:11 +00:00
Richard Scheffenegger
4dfbcffbb9 Add network QoS support for PCP to iscsi initiator.
Make the Ethernet PCP codepoint configurable
for L2 local traffic, to allow lower latency for
iSCSI block IO. This addresses the initiator
side only.

Reviewed by:	mav, trasz, bcr
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D26739
2020-10-24 21:07:13 +00:00
Alexander Motin
7dbbd1aeae Negotiate iSCSIProtocolLevel of 2 (RFC 7144) in initiator.
It does not change anything immediately, but allows further support of
Command Priority, Status Qualifier and new task management functions.

MFC after:	1 month
Sponsored by:	iXsystems, Inc.
2020-10-22 20:26:27 +00:00
Richard Scheffenegger
bfabdade5c Add DSCP support for network QoS to iscsi initiator.
Allow the DSCP codepoint also to be configurable
for the traffic in the direction from the initiator
to the target, such that writes and any requests
are also treated in the appropriate QoS class.

Reviewed by:	mav
MFC after:	2 weeks
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D26714
2020-10-09 14:33:09 +00:00
Edward Tomasz Napierala
5d9b05ac30 Fix string overflow that could occur during redirection due to passing
the wrong length to strlcpy(3). It looks like it could overflow into
the next field, isc_user, which is properly long to accomodate for it;
I don't think it could cause any harm other than breaking the connection.

Reviewed by:	mav
MFC after:	2 weeks
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D26247
2020-09-01 14:52:35 +00:00
Edward Tomasz Napierala
1e89ef5dc1 Stop hardcoding WARNS in iscsid(8).
MFC after:	2 weeks
Sponsored by:	DARPA
2020-04-01 15:09:52 +00:00
Mariusz Zaborski
1489776d43 iscsi: simplify the capsicumization
Approved by:	trasz
Differential Revision:	https://reviews.freebsd.org/D17962
2018-11-30 19:40:16 +00:00
Edward Tomasz Napierala
827904b134 Add missing SPDX identifier in iscsid(8).
MFC after:	2 weeks
2018-01-24 16:34:37 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Edward Tomasz Napierala
aa21218504 Minor tweaks to iscsi(4) and iscsid(8).
MFC after:	2 weeks
2017-05-28 17:02:29 +00:00
Marcelo Araujo
56eeadd845 Use nitems() from sys/param.h.
MFC after:	3 weeks.
2017-03-11 04:03:13 +00:00
Enji Cooper
64a0982bee usr.sbin: normalize paths using SRCTOP-relative paths or :H when possible
This simplifies make logic/output

MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-03-04 11:38:03 +00:00
Alexander Motin
625571de20 Remove ISCSI_MAX_DATA_SEGMENT_LENGTH, using negotiated value.
MFC after:	2 weeks
2017-01-20 17:14:10 +00:00
Alexander Motin
a15fbc904a Alike to r312190 decouple iSCSI connection limits from defaults.
Connection parameters should remain at defaults until negotiated.

While there, remove sythetic limits, applied if kernel provided none.
iscsid has no own limitations, no configuration and no any idea what
values are good.  Assume kernel knows what it requests.
2017-01-14 20:41:44 +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
Marcelo Araujo
f3ccb446d2 Fix calloc(3) argument order.
Reviewed by:	trasz
MFC after:	4 weeks.
Differential Revision:	https://reviews.freebsd.org/D7532
2016-08-22 15:01:39 +00:00
Edward Tomasz Napierala
03b521d4dc Decouple MaxBurstLength and FirstBurstLength from MaxRecvDataSegmentLength
reported by the ICL module in iscsid(8).  This harmed performance and was
just wrong.

MFC after:	1 month
2016-06-09 07:49:20 +00:00
Edward Tomasz Napierala
a863d33413 Build iscsid(8) with ICL_KERNEL_PROXY defined by default, as required
for iSER.

Obtained from:	Mellanox Technologies
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-23 12:58:24 +00:00
Edward Tomasz Napierala
b7af91d012 When iscsid(8) is running in ICL proxy mode, don't try to send Logout PDUs.
The kernel already does this for us when we ask it to terminate the session.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-19 14:59:21 +00:00
Edward Tomasz Napierala
5abae79af4 Add initial support for negotiating iSER parameters to iscsid(8). Some
rework might be needed to support asymetrical limits, but this should be
ok for now.

Obtained from:	Mellanox Technologies (earlier version)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-17 07:54:53 +00:00
Glen Barber
d60840138f MFH
Sponsored by:	The FreeBSD Foundation
2016-04-04 23:55:32 +00:00
Edward Tomasz Napierala
535bd9beaf Make fail() preserve the errno.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-03-15 11:10:08 +00:00
Edward Tomasz Napierala
e19462c33b Use the log_errno value passed to the function instead of the errno global
variable.

Suggested by:	Daniel Braniss
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-03-15 11:03:45 +00:00
Glen Barber
7de1daeb93 Create packages for atm, ccdconfig, devd, ipf, ipfw,
iscsi, natd, nandfs, pf, quotacheck, and routed.

Add ping6 and rtsol to the runtime package.

Sponsored by:	The FreeBSD Foundation
2016-02-09 19:30:31 +00:00
Edward Tomasz Napierala
7aebc1bce2 Improve reporting of connection problems in iscsid(8).
Obtained from:	Mellanox Technologies
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-01-27 18:12:42 +00:00
Edward Tomasz Napierala
592d6e850a The <libutil.h> is an ordinary header file; should sort just like any other.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-01-24 18:11:36 +00:00
Bryan Drewery
b1f92fa229 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
Edward Tomasz Napierala
f015623182 Remove unneeded includes.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-11-14 16:12:56 +00:00
Xin LI
61fa58e525 Remove a few unused headers.
MFC after:	2 weeks
2015-10-06 22:45:23 +00:00
Edward Tomasz Napierala
23bd2dd4a4 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
Edward Tomasz Napierala
424a3f57a2 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
Edward Tomasz Napierala
c700f14ce5 Remove unused code.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-12 11:57:31 +00:00
Edward Tomasz Napierala
83f375616e The connection_new() routine was taking an absurd number of parameters; fix it.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-05 07:32:24 +00:00
Edward Tomasz Napierala
82babffba9 Make it possible to set (via iscsi.conf(5)) and query (via iscsictl -v)
initiator iSCSI offload.  Pass maximum data segment size supported by
chosen offload module to iscsid(8), and make iscsid(8) not try to negotiate
anything larger than that.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-05 06:37:59 +00:00
Alexander Motin
3f9e1172b7 Slightly polish iSCSI parameters negotiation.
MFC after:	1 week
2014-12-19 01:12:22 +00:00
Alexander Motin
2124e3b07f 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
Baptiste Daroussin
c6db8143ed Convert usr.sbin to LIBADD
Reduce overlinking
2014-11-25 16:57:27 +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
40259c79cd 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
Baptiste Daroussin
160c039d4e iscsid does not need to link to libssl 2014-11-06 10:30:10 +00:00