Merge tag 'renesas-boards-for-v3.13' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6.git] / include / net / netfilter / nf_conntrack_timeout.h
blobd23aceb16d9443a865bc0e789a60089b0d9c40bc
1 #ifndef _NF_CONNTRACK_TIMEOUT_H
2 #define _NF_CONNTRACK_TIMEOUT_H
4 #include <net/net_namespace.h>
5 #include <linux/netfilter/nf_conntrack_common.h>
6 #include <linux/netfilter/nf_conntrack_tuple_common.h>
7 #include <net/netfilter/nf_conntrack.h>
8 #include <net/netfilter/nf_conntrack_extend.h>
10 #define CTNL_TIMEOUT_NAME_MAX 32
12 struct ctnl_timeout {
13 struct list_head head;
14 struct rcu_head rcu_head;
15 atomic_t refcnt;
16 char name[CTNL_TIMEOUT_NAME_MAX];
17 __u16 l3num;
18 struct nf_conntrack_l4proto *l4proto;
19 char data[0];
22 struct nf_conn_timeout {
23 struct ctnl_timeout *timeout;
26 #define NF_CT_TIMEOUT_EXT_DATA(__t) (unsigned int *) &((__t)->timeout->data)
28 static inline
29 struct nf_conn_timeout *nf_ct_timeout_find(const struct nf_conn *ct)
31 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
32 return nf_ct_ext_find(ct, NF_CT_EXT_TIMEOUT);
33 #else
34 return NULL;
35 #endif
38 static inline
39 struct nf_conn_timeout *nf_ct_timeout_ext_add(struct nf_conn *ct,
40 struct ctnl_timeout *timeout,
41 gfp_t gfp)
43 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
44 struct nf_conn_timeout *timeout_ext;
46 timeout_ext = nf_ct_ext_add(ct, NF_CT_EXT_TIMEOUT, gfp);
47 if (timeout_ext == NULL)
48 return NULL;
50 timeout_ext->timeout = timeout;
52 return timeout_ext;
53 #else
54 return NULL;
55 #endif
58 static inline unsigned int *
59 nf_ct_timeout_lookup(struct net *net, struct nf_conn *ct,
60 struct nf_conntrack_l4proto *l4proto)
62 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
63 struct nf_conn_timeout *timeout_ext;
64 unsigned int *timeouts;
66 timeout_ext = nf_ct_timeout_find(ct);
67 if (timeout_ext)
68 timeouts = NF_CT_TIMEOUT_EXT_DATA(timeout_ext);
69 else
70 timeouts = l4proto->get_timeouts(net);
72 return timeouts;
73 #else
74 return l4proto->get_timeouts(net);
75 #endif
78 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
79 extern int nf_conntrack_timeout_init(void);
80 extern void nf_conntrack_timeout_fini(void);
81 #else
82 static inline int nf_conntrack_timeout_init(void)
84 return 0;
87 static inline void nf_conntrack_timeout_fini(void)
89 return;
91 #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
93 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
94 extern struct ctnl_timeout *(*nf_ct_timeout_find_get_hook)(const char *name);
95 extern void (*nf_ct_timeout_put_hook)(struct ctnl_timeout *timeout);
96 #endif
98 #endif /* _NF_CONNTRACK_TIMEOUT_H */