mo...@rodents-montreal.org (Mouse) writes: >- Userland creates an AF_LOCAL SOCK_STREAM socketpair and passes one of > the resulting socket fds to the kernel, which takes over the > referenced socket and uses it, with userland reading from and > writing to the other socket.
That's about how nlmsg_unicast() is used, except that: - userland creates an AF_NETLINK SOCK_RAW or SOCK_DGRAM socket, and binds it to the pid as the address. - userland uses the 'protocol' parameter of the socket() syscall to address different kernel subsystems. - the kernel doesn't use a socket abtraction but has its private API to send messages to or receive from a pid, which references the AF_NETLINK sockets bound to that pid address. - the data is encapsulated as NLMSG_DATA (similar to CMSG_DATA). - there is also the concept of multicasting messages. To some degree it resembles more our PF_ROUTE or PF_KEY sockets and in fact, NETLINK_ROUTE is one of the kernel subsystems that a Linux program can talk to.