The Netlink socket family is a Linux kernel interface used for inter-process communication (IPC) between both the kernel and userspace processes, and between different userspace processes, in a way similar to the Unix domain sockets. wikipedia.org
It was introduced to primarily replace ioctl.
It's used e.g. by the iproute2 utilities which "are often recommended over
now-obsolete net-tools utilities" wikipedia.org.
To create a socket of AF_NETLINK type one should call socket in the following way:
netlink_socket = socket(AF_NETLINK, socket_type, netlink_family);where:
socketis eitherSOCK_RAWorSOCK_DGRAMas both values are allowednetlink_familyis one of may allowed values like e.g.NETLINK_ROUTEorNETLINK_GENERIC
More extensive documentation on the how to use netlink sockets in C code can
be found at https://linux.die.net/man/7/netlink.
There also exist implementations in many different languages including https://github.com/vishvananda/netlink written in Go.
There's a great lightning talk by Matt Layher from GopherCon 2018
where he describes netlink and its families.