int rtnl_notify(struct sk_buff *skb, u32 pid, u32 group, struct nlmsghdr *nlh, gfp_t flags) { int report = 0; if (nlh) report = nlmsg_report(nlh); return nlmsg_notify(rtnl, skb, pid, group, report, flags); }
/* This is analogous to rtnl_notify() but uses genl_sock instead of rtnl. * * This is not (yet) in any upstream kernel. */ void genl_notify(struct sk_buff *skb, struct net *net, u32 portid, u32 group, struct nlmsghdr *nlh, gfp_t flags) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) struct sock *sk = net->genl_sock; #else struct sock *sk = genl_sock; #endif int report = 0; if (nlh) report = nlmsg_report(nlh); nlmsg_notify(sk, skb, portid, group, report, flags); }
static int sockev_client_cb(struct notifier_block *nb, unsigned long event, void *data) { struct sk_buff *skb; struct nlmsghdr *nlh; struct sknlsockevmsg *smsg; struct socket *sock; sock = (struct socket *)data; if (socknlmsgsk == 0) goto done; if ((socknlmsgsk == NULL) || (sock == NULL) || (sock->sk == NULL)) goto done; if (sock->sk->sk_family != AF_INET && sock->sk->sk_family != AF_INET6) goto done; if (event != SOCKEV_BIND && event != SOCKEV_LISTEN) goto done; skb = nlmsg_new(sizeof(struct sknlsockevmsg), GFP_KERNEL); if (skb == NULL) goto done; nlh = nlmsg_put(skb, 0, 0, event, sizeof(struct sknlsockevmsg), 0); if (nlh == NULL) { kfree_skb(skb); goto done; } NETLINK_CB(skb).dst_group = SKNLGRP_SOCKEV; smsg = nlmsg_data(nlh); smsg->pid = current->pid; _sockev_event(event, smsg->event, sizeof(smsg->event)); smsg->skfamily = sock->sk->sk_family; smsg->skstate = sock->sk->sk_state; smsg->skprotocol = sock->sk->sk_protocol; smsg->sktype = sock->sk->sk_type; smsg->skflags = sock->sk->sk_flags; nlmsg_notify(socknlmsgsk, skb, 0, SKNLGRP_SOCKEV, 0, GFP_KERNEL); done: return 0; }
int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 portid, unsigned int group, int echo, gfp_t flags) { return nlmsg_notify(net->nfnl, skb, portid, group, echo, flags); }
int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo, gfp_t flags) { return nlmsg_notify(nfnl, skb, pid, group, echo, flags); }