freebsd-dev/sys/netlink
Alexander V. Chernikov 30d7e724db route: show originator PID in netlink monitor
Replacing rtsock with netlink also means providing similar tracing facilities,
rtsock provides `route -n monitor` interface, where each message can be traced
to the originating PID.
This diff closes the feature gap between rtsock and netlink in that regard.

Netlink works slightly differently from rtsock, as it is a generic message
"broker". It calls some kernel KPIs and returns the result to the caller.
Other Netlink consumers gets notified on the changed kernel state using the
relevant subsystem callbacks. Typically, it is close to impossible to pass
some data through these KPIs to enhance the notification.

This diff approaches the problem by using osd(9) to assign the relevant
socket pointer (`'nlp`) to the per-socket taskqueue execution thread.
This change allows to recover the pointer in the aforementioned notification
callbacks and extract some additional data.
Using `osd(9)` (and adding additional metadata) to the notification receiver
comes with some additional cost attached, so this interface needs to be
enabled explicitly by using a newly-created `NETLINK_MSG_INFO` `SOL_NETLINK`
socket option.

The actual medatadata (which includes the originator PID) is provided via
control messages. To enable extensibility, the control message data is
encoded in the standard netlink(TLV-based) fashion. The list of the
currently-provided properties can be found in `nlmsginfo_attrs`.
snl(3) is extended to enable decoding of netlink messages with metadata
(`snl_read_message_dbg()` stores the parsed structure in the provided buffer).

Differential Revision: https://reviews.freebsd.org/D39391
2023-04-28 13:54:54 +00:00
..
route netlink: fix netlink interface operations when netlink is loaded as a module. 2023-04-28 13:35:58 +00:00
netlink_ctl.h route: show originator PID in netlink monitor 2023-04-28 13:54:54 +00:00
netlink_debug.h
netlink_domain.c route: show originator PID in netlink monitor 2023-04-28 13:54:54 +00:00
netlink_generic_kpi.c netlink: add netlink KPI to the kernel by default 2023-03-27 13:55:44 +00:00
netlink_generic.c netlink: add netlink KPI to the kernel by default 2023-03-27 13:55:44 +00:00
netlink_generic.h netlink: fix genetlink CTRL_ATTR_MCAST_GRP_MAX define. 2022-10-31 15:03:27 +00:00
netlink_glue.c route: show originator PID in netlink monitor 2023-04-28 13:54:54 +00:00
netlink_io.c route: show originator PID in netlink monitor 2023-04-28 13:54:54 +00:00
netlink_linux.h
netlink_message_parser.c netlink: add nlattr_get_uint8() function to pack u8 attributes. 2023-04-25 10:56:42 +00:00
netlink_message_parser.h netlink: add nlattr_get_uint8() function to pack u8 attributes. 2023-04-25 10:56:42 +00:00
netlink_message_writer.c netlink: make netlink work correctly on CHERI. 2023-04-14 16:33:43 +00:00
netlink_message_writer.h netlink: make netlink work correctly on CHERI. 2023-04-14 16:33:43 +00:00
netlink_module.c route: show originator PID in netlink monitor 2023-04-28 13:54:54 +00:00
netlink_route.c netlink: allow netlink sockets in non-vnet jails. 2023-03-26 08:44:09 +00:00
netlink_route.h
netlink_snl_generic.h netlink: improve snl(3) 2023-03-15 20:53:20 +00:00
netlink_snl_route_compat.h fix buildworld after 595d23f777. 2023-03-09 15:45:57 +00:00
netlink_snl_route_parsers.h netlink: add snl(3) support for dumping nexthops and neighbors 2023-04-25 11:14:12 +00:00
netlink_snl_route.h carp: support unicast 2023-03-20 14:37:09 +01:00
netlink_snl.h route: show originator PID in netlink monitor 2023-04-28 13:54:54 +00:00
netlink_var.h route: show originator PID in netlink monitor 2023-04-28 13:54:54 +00:00
netlink.h route: show originator PID in netlink monitor 2023-04-28 13:54:54 +00:00