| #
d21b5139
|
| 07-Aug-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Be more explicit in a few uses of types to avoid potential ambiguity
This appeases -Wchanges-meaning warnings from GCC.
Sponsored by: Chelsio Communications
|
| #
66b5296f
|
| 06-Aug-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Add support for NVMe over Fabrics
While the overall structure is similar for NVMeoF controllers and iSCSI targets, there are sufficient differences that NVMe support uses an alternate configur
ctld: Add support for NVMe over Fabrics
While the overall structure is similar for NVMeoF controllers and iSCSI targets, there are sufficient differences that NVMe support uses an alternate configuration syntax.
- In authentication groups, permitted NVMeoF hosts can be allowed by names (NQNs) via "host-nqn" values (similar to "initiator-name" for iSCSI). Similarly, "host-address" accepts permitted host addresses similar to "initiator-portal" for iSCSI.
- A new "transport-group" context enumerates transports that can be used by a group of NVMeoF controllers similar to the "portal-group" context for iSCSI. In this section, the "listen" keyword accepts a transport as well as an address to permit other types of transports besides TCP in the future. The "foreign", "offload", and "redirect" keywords are also not meaningful and thus not supported.
- A new "controller" context describes an NVMeoF I/O controller similar to the "target" context for iSCSI. One key difference here is that "lun" objects are replaced by "namespace" objects. However, a "namespace" can reference a named global lun permitting LUNs to be shared between iSCSI targets and NVMeoF controllers.
NB: Authentication via CHAP is not implemented for NVMeoF.
Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48773
show more ...
|
| #
7e844dca
|
| 06-Aug-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Add abstractions to support multiple target protocols
This is a prerequisite for adding NVMe over Fabrics support.
Convert portal_group, portal_group_port, and target into abstract classes wi
ctld: Add abstractions to support multiple target protocols
This is a prerequisite for adding NVMe over Fabrics support.
Convert portal_group, portal_group_port, and target into abstract classes with virtual methods to support protocol-specific methods.
Add new iscsi_portal_group, iscsi_port, iscsi_portal and iscsi_target subclasses in a new iscsi.cc file and move some iSCSI-specific logic there. Rename ctld_connection to iscsi_connection and move it to a new iscsi.hh header. Move iscsi_connection methods out of ctld.cc and kernel.cc into iscsi.cc.
Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48772
show more ...
|
| #
ed076901
|
| 04-Aug-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Convert struct ctld_connection to a C++ class
Note that some of the functions for handling iSCSI login, discovery, and kernel handoff are now functions of this class as they are logical operat
ctld: Convert struct ctld_connection to a C++ class
Note that some of the functions for handling iSCSI login, discovery, and kernel handoff are now functions of this class as they are logical operations on an iSCSI connection and need access to various members of this class.
This also fixes some memory leaks as ctld_connection wasn't properly torn down once a connection finishes. These leaks were harmless in practice since the ctld process exits after handling each connection.
Sponsored by: Chelsio Communications Pull Request: https://github.com/freebsd/freebsd-src/pull/1794
show more ...
|
| #
c6f1e9b8
|
| 04-Aug-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Simplify XML parsing memory management
Use C++ STL containers (std::string, std::list) for the data structure holding the parsed output of the XML configuration obtained from the kernel. This
ctld: Simplify XML parsing memory management
Use C++ STL containers (std::string, std::list) for the data structure holding the parsed output of the XML configuration obtained from the kernel. This simplifies the code in various places and removes the need for manual memory freeing (which was incomplete).
Use a std::list of pairs of std::string objects for the port and LUN attribute lists instead of an nvlist.
Use a std::vector<char> for the resizable buffer receiving XML results via ioctl(). Also, reuse the buffer from CTL_LUN_LIST for CTL_PORT_LIST rather than doing a free() only to turn around and malloc() again. While here, split out the code for fetching and parsing the XML into a separate function.
Sponsored by: Chelsio Communications Pull Request: https://github.com/freebsd/freebsd-src/pull/1794
show more ...
|
| #
888ec3a7
|
| 04-Aug-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Convert struct conf to a C++ class
- Various functions to add or lookup configuration objects are now methods of the conf class.
- Use std::string and freebsd::pidfile for various members.
ctld: Convert struct conf to a C++ class
- Various functions to add or lookup configuration objects are now methods of the conf class.
- Use std::string and freebsd::pidfile for various members.
- Rename the global set_timeout() to start_timer() to avoid shadowing conf::set_timeout() and also split out a separate stop_timer().
Sponsored by: Chelsio Communications Pull Request: https://github.com/freebsd/freebsd-src/pull/1794
show more ...
|
| #
2bb9180b
|
| 04-Aug-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Convert struct target to a C++ class
- Use std::string for string members.
- Use std::array for the array of LUN pointers indexed by LUN id.
- Move meat of the target_* functions from conf.c
ctld: Convert struct target to a C++ class
- Use std::string for string members.
- Use std::array for the array of LUN pointers indexed by LUN id.
- Move meat of the target_* functions from conf.cc into class methods.
Sponsored by: Chelsio Communications Pull Request: https://github.com/freebsd/freebsd-src/pull/1794
show more ...
|
| #
afcae14d
|
| 04-Aug-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Convert struct lun to a C++ class
- Use std::string and freebsd::nvlist_up for class members.
- Turn most lun_* and kernel_lun_* functions into class methods.
Sponsored by: Chelsio Communica
ctld: Convert struct lun to a C++ class
- Use std::string and freebsd::nvlist_up for class members.
- Turn most lun_* and kernel_lun_* functions into class methods.
Sponsored by: Chelsio Communications Pull Request: https://github.com/freebsd/freebsd-src/pull/1794
show more ...
|
| #
d6d8a7ba
|
| 04-Aug-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Convert struct portal_group to a C++ class
- Use std::string, freebsd_nvlist_up to manage life cycle of class members.
- Use an unordered_map<> keyed by std::string in struct conf to repl
ctld: Convert struct portal_group to a C++ class
- Use std::string, freebsd_nvlist_up to manage life cycle of class members.
- Use an unordered_map<> keyed by std::string in struct conf to replace the previous TAILQ.
- Replace PG_FILTER_* macros with a scoped enum.
- Provide a variety of accessors as portal groups are widely used while keeping members private.
- The logic to "move" sockets from existing portals to new portals when parsing new configuration is now split into several operations across the conf and portal_group classes to preserve some semblance of data hiding.
Sponsored by: Chelsio Communications Pull Request: https://github.com/freebsd/freebsd-src/pull/1794
show more ...
|
| #
6acc7afa
|
| 04-Aug-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Convert struct port to a hierarchy of C++ classes
The existing C struct port was used to describe three types of ports: iSCSI ports associated with a portal_group, ioctl ports, and "physical"
ctld: Convert struct port to a hierarchy of C++ classes
The existing C struct port was used to describe three types of ports: iSCSI ports associated with a portal_group, ioctl ports, and "physical" ports associated with a kernel device. This change chooses to split these out into separate sub-classes of an abstract port base class. Virtual methods are used in a few places such as sending the class-specific CTL ioctls for creating and removing CTL kernel ports.
For ownership purposes, a struct conf instance "owns" each port via a std::unique_ptr<> in a std::unordered_map<> indexed by name. Other objects such as targets and portal_groups can also contain collections of ports (targets hold a std::list of pointers, portal groups hold a std::unordered_map<> indexed by target names). One not-so-straightforward case is that if a new port fails to register, it is removed from the configuration. In that case, these other references also have to be removed explicitly.
Sponsored by: Chelsio Communications Pull Request: https://github.com/freebsd/freebsd-src/pull/1794
show more ...
|
| #
4b1aac93
|
| 04-Aug-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Convert struct pport and struct kports to C++ classes
- Use an unordered_map<> indexed by std::string to replace the TAILQ of pport objects in struct kports since pport objects are looked up
ctld: Convert struct pport and struct kports to C++ classes
- Use an unordered_map<> indexed by std::string to replace the TAILQ of pport objects in struct kports since pport objects are looked up name. Use a few wrapper methods around the unordered_map<> to simplify consumers.
- Don't store a list of port pointers in pport. Only a single port is ever associated (previously the code failed with an error if the TAILQ wasn't empty when adding a port), so just store a pointer to a single port and replace the empty TAILQ test with checking if the pointer is null.
- Use std::string for the pport name.
- Add accessors (and a setter) for members of pport so that all the fields can be private.
Sponsored by: Chelsio Communications Pull Request: https://github.com/freebsd/freebsd-src/pull/1794
show more ...
|
| #
5b0f1926
|
| 04-Aug-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Convert struct portal to a C++ class
- Convert portal_init_socket and portal_reuse_socket into class methods. Move the logic to handle proxy portal setup into the init_socket method so tha
ctld: Convert struct portal to a C++ class
- Convert portal_init_socket and portal_reuse_socket into class methods. Move the logic to handle proxy portal setup into the init_socket method so that some fields can remain private.
- Add accessors for a few other members (most are const) so that all the fields can be private.
- Use std::string, freebsd::addrinfo_up, and freebsd::fd_up classes to manage fields owned exclusively.
- Add a vector of proxy portal pointers to struct conf and use the index into the vector as the portal ID. This replaces an O(n^2) loop to find the portal for a portal ID returned by kernel_accept with a direct lookup.
Sponsored by: Chelsio Communications Pull Request: https://github.com/freebsd/freebsd-src/pull/1794
show more ...
|
| #
34e8d664
|
| 04-Aug-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Rename {ctld,isns}.h to {ctld,isns}.hh
Subsequent commits will use C++ in these headers rather than only C. conf.h remains as a C-only header since it is intended for use by the C code generat
ctld: Rename {ctld,isns}.h to {ctld,isns}.hh
Subsequent commits will use C++ in these headers rather than only C. conf.h remains as a C-only header since it is intended for use by the C code generated from parse.y.
Sponsored by: Chelsio Communications Pull Request: https://github.com/freebsd/freebsd-src/pull/1794
show more ...
|
| #
30020689
|
| 11-Apr-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Do not remove item from an nvlist while iterating it
While here, make use of cnvlist_* to simplify this code.
Fixes: d42a73fb6a85 ("ctld: Add a dedicated API between parse.y and the rest of
ctld: Do not remove item from an nvlist while iterating it
While here, make use of cnvlist_* to simplify this code.
Fixes: d42a73fb6a85 ("ctld: Add a dedicated API between parse.y and the rest of the program") Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D49650
show more ...
|
| #
839d0755
|
| 02-Apr-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Convert to C++
This is the minimal set of changes need to compile as C++ so git can handle the rename correctly.
Reviewed by: asomers Sponsored by: Chelsio Communications Differential Revisio
ctld: Convert to C++
This is the minimal set of changes need to compile as C++ so git can handle the rename correctly.
Reviewed by: asomers Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D49139
show more ...
|
| #
d42a73fb
|
| 26-Feb-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Add a dedicated API between parse.y and the rest of the program
The primary purpose of this is to permit the rest of ctld to use C++. However, this also has the nice side effect of reducing co
ctld: Add a dedicated API between parse.y and the rest of the program
The primary purpose of this is to permit the rest of ctld to use C++. However, this also has the nice side effect of reducing code duplication with the UCL parser.
As a general rule, setting of options including error handling for invalid values, etc. is moved out of parse.y and into conf.c. The globals for the current configuration, auth group, portal group, lun, and target are also moved into conf.c hiding the types from parse.y. The intention is that all of the functions declared in conf.h will be extern "C" for use by parse.y and that the backing data structures can be reimplemented as C++ classes instead of C structures if desired.
A few other small changes are included with this refactoring:
- Warn and fail a configuration that specifies the same LUN multiple times for a target.
- Use T_* constants for SCSI device types instead of magic numbers.
- Warn and fail for a few UCL properties that aren't the required type including "discovery-auth-group" in a portal group context, "auth-type" and "port" in a target context.
- Fix a bug where chap-mutual in a target in UCL would not auto-create a new auth-group.
Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48934
show more ...
|
| #
ca8a23d6
|
| 12-Feb-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Drop some #if 0'd debugging traces
Suggested by: asomers Reviewed by: asomers Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48927
|
| #
9e425a8a
|
| 05-Feb-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Move kernel_limits into login.c where it is used
Reviewed by: asomers Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48771
|
| #
703b03a8
|
| 30-Jan-2025 |
John Baldwin <jhb@FreeBSD.org> |
ctld: Use nvlist instead of home-rolled name-value lists
Reviewed by: asomers (older version) Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48595
|
| #
969876fc
|
| 10-Jun-2024 |
Alan Somers <asomers@FreeBSD.org> |
ctld: parse config file independently of getting kernel info
Separate the parsing of the config file from the reading of kernel port information. This has three benefits:
* Separation of concerns
ctld: parse config file independently of getting kernel info
Separate the parsing of the config file from the reading of kernel port information. This has three benefits:
* Separation of concerns makes future changes easier. * Allows the config file to be read earlier, which is necessary for fixing PR 271460. * Reduces total line count, by eliminating duplication between parse.y (for traditional config file) and uclparse.c (for UCL config file).
MFC after: 2 weeks Sponsored by: Axcient Reviewed by: mav Pull Request: https://github.com/freebsd/freebsd-src/pull/1287
show more ...
|
| #
2909ddd1
|
| 12-Jun-2024 |
Alan Somers <asomers@FreeBSD.org> |
ctld: plug memory leaks
MFC after: 2 weeks Reviewed by: mav Sponsored by: Axcient Reported by: valgrind Pull Request: https://github.com/freebsd/freebsd-src/pull/1288
|
| #
8f65dcd6
|
| 07-Nov-2023 |
Elyes Haouas <ehaouas@noos.fr> |
ctld: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Pull Request: https://github.com/freebsd/freebsd-src/pull/888 Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
|
| #
4d65a7c6
|
| 24-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
usr.sbin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row.
usr.sbin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row.
Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/
Sponsored by: Netflix
show more ...
|
| #
1d386b48
|
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
| #
4d846d26
|
| 10-May-2023 |
Warner Losh <imp@FreeBSD.org> |
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause.
Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
show more ...
|