Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
a992ca2a PNA |
2 | #ifndef _NF_CONNTRACK_TSTAMP_H |
3 | #define _NF_CONNTRACK_TSTAMP_H | |
4 | ||
5 | #include <net/net_namespace.h> | |
6 | #include <linux/netfilter/nf_conntrack_common.h> | |
7 | #include <linux/netfilter/nf_conntrack_tuple_common.h> | |
8 | #include <net/netfilter/nf_conntrack.h> | |
9 | #include <net/netfilter/nf_conntrack_extend.h> | |
10 | ||
11 | struct nf_conn_tstamp { | |
12 | u_int64_t start; | |
13 | u_int64_t stop; | |
14 | }; | |
15 | ||
16 | static inline | |
17 | struct nf_conn_tstamp *nf_conn_tstamp_find(const struct nf_conn *ct) | |
18 | { | |
19 | #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP | |
20 | return nf_ct_ext_find(ct, NF_CT_EXT_TSTAMP); | |
21 | #else | |
22 | return NULL; | |
23 | #endif | |
24 | } | |
25 | ||
26 | static inline | |
27 | struct nf_conn_tstamp *nf_ct_tstamp_ext_add(struct nf_conn *ct, gfp_t gfp) | |
28 | { | |
29 | #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP | |
30 | struct net *net = nf_ct_net(ct); | |
31 | ||
32 | if (!net->ct.sysctl_tstamp) | |
33 | return NULL; | |
34 | ||
35 | return nf_ct_ext_add(ct, NF_CT_EXT_TSTAMP, gfp); | |
36 | #else | |
37 | return NULL; | |
38 | #endif | |
39 | }; | |
40 | ||
41 | static inline bool nf_ct_tstamp_enabled(struct net *net) | |
42 | { | |
43 | return net->ct.sysctl_tstamp != 0; | |
44 | } | |
45 | ||
46 | static inline void nf_ct_set_tstamp(struct net *net, bool enable) | |
47 | { | |
48 | net->ct.sysctl_tstamp = enable; | |
49 | } | |
50 | ||
2f1e3176 | 51 | #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP |
4e77be46 JP |
52 | int nf_conntrack_tstamp_pernet_init(struct net *net); |
53 | void nf_conntrack_tstamp_pernet_fini(struct net *net); | |
73f4001a | 54 | |
4e77be46 JP |
55 | int nf_conntrack_tstamp_init(void); |
56 | void nf_conntrack_tstamp_fini(void); | |
2f1e3176 | 57 | #else |
73f4001a G |
58 | static inline int nf_conntrack_tstamp_pernet_init(struct net *net) |
59 | { | |
60 | return 0; | |
61 | } | |
62 | ||
63 | static inline void nf_conntrack_tstamp_pernet_fini(struct net *net) | |
64 | { | |
65 | return; | |
66 | } | |
67 | ||
68 | static inline int nf_conntrack_tstamp_init(void) | |
2f1e3176 PM |
69 | { |
70 | return 0; | |
71 | } | |
72 | ||
73f4001a | 73 | static inline void nf_conntrack_tstamp_fini(void) |
2f1e3176 PM |
74 | { |
75 | return; | |
76 | } | |
77 | #endif /* CONFIG_NF_CONNTRACK_TIMESTAMP */ | |
a992ca2a PNA |
78 | |
79 | #endif /* _NF_CONNTRACK_TSTAMP_H */ |