Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nf_conntrack_timeout.h
Go to the documentation of this file.
1 #ifndef _NF_CONNTRACK_TIMEOUT_H
2 #define _NF_CONNTRACK_TIMEOUT_H
3 
4 #include <net/net_namespace.h>
5 #include <linux/netfilter/nf_conntrack_common.h>
9 
10 #define CTNL_TIMEOUT_NAME_MAX 32
11 
12 struct ctnl_timeout {
13  struct list_head head;
19  char data[0];
20 };
21 
24 };
25 
26 #define NF_CT_TIMEOUT_EXT_DATA(__t) (unsigned int *) &((__t)->timeout->data)
27 
28 static inline
29 struct nf_conn_timeout *nf_ct_timeout_find(const struct nf_conn *ct)
30 {
31 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
32  return nf_ct_ext_find(ct, NF_CT_EXT_TIMEOUT);
33 #else
34  return NULL;
35 #endif
36 }
37 
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)
42 {
43 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
44  struct nf_conn_timeout *timeout_ext;
45 
46  timeout_ext = nf_ct_ext_add(ct, NF_CT_EXT_TIMEOUT, gfp);
47  if (timeout_ext == NULL)
48  return NULL;
49 
50  timeout_ext->timeout = timeout;
51 
52  return timeout_ext;
53 #else
54  return NULL;
55 #endif
56 };
57 
58 static inline unsigned int *
59 nf_ct_timeout_lookup(struct net *net, struct nf_conn *ct,
60  struct nf_conntrack_l4proto *l4proto)
61 {
62 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
63  struct nf_conn_timeout *timeout_ext;
64  unsigned int *timeouts;
65 
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);
71 
72  return timeouts;
73 #else
74  return l4proto->get_timeouts(net);
75 #endif
76 }
77 
78 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
79 extern int nf_conntrack_timeout_init(struct net *net);
80 extern void nf_conntrack_timeout_fini(struct net *net);
81 #else
82 static inline int nf_conntrack_timeout_init(struct net *net)
83 {
84  return 0;
85 }
86 
87 static inline void nf_conntrack_timeout_fini(struct net *net)
88 {
89  return;
90 }
91 #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
92 
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
97 
98 #endif /* _NF_CONNTRACK_TIMEOUT_H */