netlink_kernel_create內核函數用於創建 內核socket用用戶態通信
static inline struct sock *
netlink_kernel_create(struct net *net, intunit, struct netlink_kernel_cfg *cfg)
/* net: net指向所在的網絡命名空間, 一般默認傳入的是&init_net(不需要定義); 定義在net_namespace.c(extern struct net init_net);
unit:netlink協議類型
cfg: cfg存放的是netlink內核配置參數(如下)
*/
/* optional Netlink kernel configurationparameters */
struct netlink_kernel_cfg {
unsigned int groups;
unsigned int flags;
void (*input)(struct sk_buff *skb); /* input 回調函數 */
struct mutex *cb_mutex;
void (*bind)(int group);
bool (*compare)(struct net *net, struct sock *sk);
};