• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * (C) 2010 Pablo Neira Ayuso <pablo@netfilter.org>
4  */
5 
6 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7 
8 #include <linux/netfilter.h>
9 #include <linux/slab.h>
10 #include <linux/kernel.h>
11 #include <linux/moduleparam.h>
12 
13 #include <net/netfilter/nf_conntrack.h>
14 #include <net/netfilter/nf_conntrack_extend.h>
15 #include <net/netfilter/nf_conntrack_timestamp.h>
16 
17 static bool nf_ct_tstamp __read_mostly;
18 
19 module_param_named(tstamp, nf_ct_tstamp, bool, 0644);
20 MODULE_PARM_DESC(tstamp, "Enable connection tracking flow timestamping.");
21 
22 static const struct nf_ct_ext_type tstamp_extend = {
23 	.len	= sizeof(struct nf_conn_tstamp),
24 	.align	= __alignof__(struct nf_conn_tstamp),
25 	.id	= NF_CT_EXT_TSTAMP,
26 };
27 
nf_conntrack_tstamp_pernet_init(struct net * net)28 void nf_conntrack_tstamp_pernet_init(struct net *net)
29 {
30 	net->ct.sysctl_tstamp = nf_ct_tstamp;
31 }
32 
nf_conntrack_tstamp_init(void)33 int nf_conntrack_tstamp_init(void)
34 {
35 	int ret;
36 	ret = nf_ct_extend_register(&tstamp_extend);
37 	if (ret < 0)
38 		pr_err("Unable to register extension\n");
39 	return ret;
40 }
41 
nf_conntrack_tstamp_fini(void)42 void nf_conntrack_tstamp_fini(void)
43 {
44 	nf_ct_extend_unregister(&tstamp_extend);
45 }
46