10 #include <linux/module.h>
11 #include <linux/kernel.h>
14 #include <linux/netlink.h>
16 #include <linux/slab.h>
17 #include <linux/types.h>
18 #include <linux/errno.h>
22 #include <linux/netfilter.h>
23 #include <linux/netfilter/nfnetlink.h>
24 #include <linux/netfilter/nfnetlink_acct.h>
51 acct_name = nla_data(tb[NFACCT_NAME]);
89 list_add_tail_rcu(&nfacct->
head, &nfnl_acct_list);
103 nlh = nlmsg_put(skb, portid, seq, event,
sizeof(*nfmsg), flags);
107 nfmsg = nlmsg_data(nlh);
112 if (nla_put_string(skb, NFACCT_NAME, acct->
name))
113 goto nla_put_failure;
122 if (nla_put_be64(skb, NFACCT_PKTS,
cpu_to_be64(pkts)) ||
123 nla_put_be64(skb, NFACCT_BYTES,
cpu_to_be64(bytes)) ||
125 goto nla_put_failure;
132 nlmsg_cancel(skb, nlh);
149 list_for_each_entry_rcu(cur, &nfnl_acct_list,
head) {
150 if (last && cur != last)
168 nfnl_acct_get(
struct sock *nfnl,
struct sk_buff *skb,
177 .dump = nfnl_acct_dump,
179 return netlink_dump_start(nfnl, skb, nlh, &c);
182 if (!tb[NFACCT_NAME])
184 acct_name = nla_data(tb[NFACCT_NAME]);
198 ret = nfnl_acct_fill_info(skb2,
NETLINK_CB(skb).portid,
218 static int nfnl_acct_try_del(
struct nf_acct *cur)
225 list_del_rcu(&cur->
head);
236 nfnl_acct_del(
struct sock *nfnl,
struct sk_buff *skb,
243 if (!tb[NFACCT_NAME]) {
245 nfnl_acct_try_del(cur);
249 acct_name = nla_data(tb[NFACCT_NAME]);
255 ret = nfnl_acct_try_del(cur);
273 .policy = nfnl_acct_policy },
276 .policy = nfnl_acct_policy },
279 .policy = nfnl_acct_policy },
282 .policy = nfnl_acct_policy },
299 list_for_each_entry_rcu(cur, &nfnl_acct_list, head) {
334 static int __init nfnl_acct_init(
void)
338 pr_info(
"nfnl_acct: registering with nfnetlink.\n");
341 pr_err(
"nfnl_acct_init: cannot register with nfnetlink.\n");
349 static void __exit nfnl_acct_exit(
void)
353 pr_info(
"nfnl_acct: unregistering from nfnetlink.\n");
357 list_del_rcu(&cur->
head);