History log of /freebsd/usr.sbin/ctld/kernel.cc (Results 1 – 19 of 19)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 95fc64cc 28-May-2026 Dag-Erling Smørgrav <des@FreeBSD.org>

ctld: More consistent error messages

The error messages ctld emits when it finds a port or LUN it did not
create were inconsistent with each other as well as with ctld's other
error messages.

MFC a

ctld: More consistent error messages

The error messages ctld emits when it finds a port or LUN it did not
create were inconsistent with each other as well as with ctld's other
error messages.

MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D57270

show more ...


# caef3c50 27-May-2026 John Baldwin <jhb@FreeBSD.org>

ctld: Refactor ioctl port handling

- Normalize ioctl port names when the port name is first added to
the configuration. This can catch potential duplicate port names
sooner and helps with other

ctld: Refactor ioctl port handling

- Normalize ioctl port names when the port name is first added to
the configuration. This can catch potential duplicate port names
sooner and helps with other parts of this change.

- When recognizing existing ioctl ports, always expand the name to
include the physical and virtual port numbers. This permits binding
ioctl/0/0 or ioctl/1/0 to a target, for example.

- When adding physical ports to a target, first check for an existing
kernel port to reuse. This handles both ioctl and non-ioctl ports
and removes the need for the conf::add_port method for ioctl ports
to check in kports.

- If an existing kport isn't found when adding physical ports, check
to see if the port name is an ioctl port. If so, call conf::add_port
to add an ioctl port. This add_port method overload is now simpler
as it always creates a new port.

NB: The kernel_port class handles CTL ports that already existed
before ctld started including existing ioctl ports, whereas the
ioctl_port class handles ioctl ports that are created and completely
managed by ctld. This was true before this change but is perhaps more
obvious after this change.

Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D57092

show more ...


# 7a436d37 27-May-2026 John Baldwin <jhb@FreeBSD.org>

ctld: Don't ignore pp/vp values of kernel ports with pp == 0 but vp != 0

Fixes: c6f1e9b8a412 ("ctld: Simplify XML parsing memory management")
Sponsored by: Chelsio Communications


Revision tags: release/14.4.0-p5, release/14.3.0-p14, release/15.0.0-p9, release/14.4.0-p4, release/14.3.0-p13, release/13.5.0-p14, release/15.0.0-p8
# d9c05941 28-Apr-2026 Kyle Evans <kevans@FreeBSD.org>

ctld: kernel-sourced portal groups are not dummies

The current and historical versions of ctld would flag our initial set
of kernel ports as dummies, because their portal groups were empty since
por

ctld: kernel-sourced portal groups are not dummies

The current and historical versions of ctld would flag our initial set
of kernel ports as dummies, because their portal groups were empty since
portals come from the configuration on-disk.

As a result, we would never try to remove a kernel port at startup that
didn't exist in the configuration (possibly a feature if you wanted
concurrent ctld(8)), and we would always try to port->kernel_add() on
ports in the configuration (even if they actually did have an existing
kernel port).

Flag these portal groups as kernel groups so that we avoid trying to add
ports that already exist. It may be the case that the kernel_remove()
loop in conf::apply() needs to do something other than the current
`oldport->is_dummy()` to avoid removing ports that it isn't supposed to
be managing, but that wuld also seem to apply to LUNs that would be
removed today.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D51782

show more ...


Revision tags: release/14.4.0-p3, release/14.3.0-p12, release/13.5.0-p13, release/15.0.0-p7, release/13.5.0-p12, release/14.3.0-p11, release/14.4.0-p2, release/15.0.0-p6, release/13.5.0-p11, release/14.3.0-p10, release/14.4.0-p1, release/15.0.0-p5, release/14.4.0, release/13.5.0-p10, release/14.3.0-p9, release/15.0.0-p4, release/15.0.0-p3, release/13.5.0-p9, release/15.0.0-p2, release/14.3.0-p8, release/15.0.0-p1, release/13.5.0-p8, release/14.3.0-p7, release/15.0.0, release/14.3.0-p6, release/13.5.0-p7, release/13.5.0-p6, release/14.3.0-p5, release/13.5.0-p5, release/14.2.0-p7, release/14.3.0-p4, release/14.3.0-p3, release/14.2.0-p6, release/13.5.0-p4, release/13.5.0-p3, release/14.2.0-p5, release/14.3.0-p2
# 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 ...


Revision tags: release/14.3.0-p1, release/14.2.0-p4, release/13.5.0-p2, release/14.3.0
# 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 ...


Revision tags: release/13.4.0-p5, release/13.5.0-p1, release/14.2.0-p3
# 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 ...