Both the kernel netlink socket and the user space netlink socket will call the following function to create a sock
/*
调用流程:
0xffffff80089c7790 : __netlink_create+0x0/0xe4 [kernel]
0xffffff80089c7d70 : netlink_create+0x1ec/0x26c [kernel]
0xffffff8008989d50 : __sock_create+0x11c/0x180 [kernel]
0xffffff8008989e00 : sock_create+0x4c/0x5c [kernel]
0xffffff800898ad6c : SyS_socket+0x48/0xd0 [kernel]
0xffffff8008082f30 : el0_svc_naked+0x24/0x28 [kernel]
0x0 (inexact)
*/
static int __netlink_create(struct net *net,
struct socket *sock,
struct mutex *cb_mutex,
int protocol,
int kern)
{
....
/*
用户空间调用 bind() connect() .....
会在这里进行响应:
static const struct proto_ops netlink_ops = {
.family = PF_NETLINK,
.owner = THIS_MODULE,
.release = netlink_release,
.bind = netlink_bind,
...
.shutdown = sock_no_shutdown,
.setsockopt = netlink_setsockopt,
};
*/
sock->ops = &netlink_ops;
}