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