Merge tag 'v5.0-rc5' of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds...
[sfrench/cifs-2.6.git] / net / netfilter / nf_conntrack_acct.c
1 /* Accouting handling for netfilter. */
2
3 /*
4  * (C) 2008 Krzysztof Piotr Oledzki <ole@ans.pl>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10
11 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12
13 #include <linux/netfilter.h>
14 #include <linux/slab.h>
15 #include <linux/kernel.h>
16 #include <linux/moduleparam.h>
17 #include <linux/export.h>
18
19 #include <net/netfilter/nf_conntrack.h>
20 #include <net/netfilter/nf_conntrack_extend.h>
21 #include <net/netfilter/nf_conntrack_acct.h>
22
23 static bool nf_ct_acct __read_mostly;
24
25 module_param_named(acct, nf_ct_acct, bool, 0644);
26 MODULE_PARM_DESC(acct, "Enable connection tracking flow accounting.");
27
28 static const struct nf_ct_ext_type acct_extend = {
29         .len    = sizeof(struct nf_conn_acct),
30         .align  = __alignof__(struct nf_conn_acct),
31         .id     = NF_CT_EXT_ACCT,
32 };
33
34 void nf_conntrack_acct_pernet_init(struct net *net)
35 {
36         net->ct.sysctl_acct = nf_ct_acct;
37 }
38
39 int nf_conntrack_acct_init(void)
40 {
41         int ret = nf_ct_extend_register(&acct_extend);
42         if (ret < 0)
43                 pr_err("Unable to register extension\n");
44         return ret;
45 }
46
47 void nf_conntrack_acct_fini(void)
48 {
49         nf_ct_extend_unregister(&acct_extend);
50 }