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
13 struct list_head head;
14 struct rcu_head rcu_head;
16 char name[CTNL_TIMEOUT_NAME_MAX];
18 struct nf_conntrack_l4proto *l4proto;
22 struct nf_conn_timeout {
23 struct ctnl_timeout __rcu *timeout;
26 static inline unsigned int *
27 nf_ct_timeout_data(struct nf_conn_timeout *t)
29 struct ctnl_timeout *timeout;
31 timeout = rcu_dereference(t->timeout);
35 return (unsigned int *)timeout->data;
39 struct nf_conn_timeout *nf_ct_timeout_find(const struct nf_conn *ct)
41 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
42 return nf_ct_ext_find(ct, NF_CT_EXT_TIMEOUT);
49 struct nf_conn_timeout *nf_ct_timeout_ext_add(struct nf_conn *ct,
50 struct ctnl_timeout *timeout,
53 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
54 struct nf_conn_timeout *timeout_ext;
56 timeout_ext = nf_ct_ext_add(ct, NF_CT_EXT_TIMEOUT, gfp);
57 if (timeout_ext == NULL)
60 rcu_assign_pointer(timeout_ext->timeout, timeout);
68 static inline unsigned int *
69 nf_ct_timeout_lookup(struct net *net, struct nf_conn *ct,
70 struct nf_conntrack_l4proto *l4proto)
72 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
73 struct nf_conn_timeout *timeout_ext;
74 unsigned int *timeouts;
76 timeout_ext = nf_ct_timeout_find(ct);
78 timeouts = nf_ct_timeout_data(timeout_ext);
79 if (unlikely(!timeouts))
80 timeouts = l4proto->get_timeouts(net);
82 timeouts = l4proto->get_timeouts(net);
87 return l4proto->get_timeouts(net);
91 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
92 int nf_conntrack_timeout_init(void);
93 void nf_conntrack_timeout_fini(void);
95 static inline int nf_conntrack_timeout_init(void)
100 static inline void nf_conntrack_timeout_fini(void)
104 #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
106 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
107 extern struct ctnl_timeout *(*nf_ct_timeout_find_get_hook)(const char *name);
108 extern void (*nf_ct_timeout_put_hook)(struct ctnl_timeout *timeout);
111 #endif /* _NF_CONNTRACK_TIMEOUT_H */