blob: 8509db14670b7683772aabf53420d9d355ab44e1 [file] [log] [blame]
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -08001/* (C) 1999-2001 Paul `Rusty' Russell
2 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -08007 */
8
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -08009#include <linux/types.h>
10#include <linux/netfilter.h>
11#include <linux/module.h>
12#include <linux/skbuff.h>
13#include <linux/proc_fs.h>
14#include <linux/seq_file.h>
15#include <linux/percpu.h>
16#include <linux/netdevice.h>
Eric W. Biederman457c4cb2007-09-12 12:01:34 +020017#include <net/net_namespace.h>
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080018#ifdef CONFIG_SYSCTL
19#include <linux/sysctl.h>
20#endif
21
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080022#include <net/netfilter/nf_conntrack.h>
Martin Josefssonf6180122006-11-29 02:35:01 +010023#include <net/netfilter/nf_conntrack_core.h>
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080024#include <net/netfilter/nf_conntrack_l3proto.h>
Martin Josefsson605dcad2006-11-29 02:35:06 +010025#include <net/netfilter/nf_conntrack_l4proto.h>
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010026#include <net/netfilter/nf_conntrack_expect.h>
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080027#include <net/netfilter/nf_conntrack_helper.h>
Krzysztof Piotr Oledzki58401572008-07-21 10:01:34 -070028#include <net/netfilter/nf_conntrack_acct.h>
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080029
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080030MODULE_LICENSE("GPL");
31
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080032#ifdef CONFIG_PROC_FS
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010033int
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080034print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
Jan Engelhardt32948582008-01-31 04:53:24 -080035 const struct nf_conntrack_l3proto *l3proto,
36 const struct nf_conntrack_l4proto *l4proto)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080037{
Martin Josefsson605dcad2006-11-29 02:35:06 +010038 return l3proto->print_tuple(s, tuple) || l4proto->print_tuple(s, tuple);
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080039}
Patrick McHardye4bd8bc2006-11-29 02:35:22 +010040EXPORT_SYMBOL_GPL(print_tuple);
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080041
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080042struct ct_iter_state {
43 unsigned int bucket;
44};
45
Patrick McHardyf205c5e2007-07-07 22:28:14 -070046static struct hlist_node *ct_get_first(struct seq_file *seq)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080047{
48 struct ct_iter_state *st = seq->private;
Patrick McHardy76507f62008-01-31 04:38:38 -080049 struct hlist_node *n;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080050
51 for (st->bucket = 0;
52 st->bucket < nf_conntrack_htable_size;
53 st->bucket++) {
Patrick McHardy76507f62008-01-31 04:38:38 -080054 n = rcu_dereference(nf_conntrack_hash[st->bucket].first);
55 if (n)
56 return n;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080057 }
58 return NULL;
59}
60
Patrick McHardyf205c5e2007-07-07 22:28:14 -070061static struct hlist_node *ct_get_next(struct seq_file *seq,
62 struct hlist_node *head)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080063{
64 struct ct_iter_state *st = seq->private;
65
Patrick McHardy76507f62008-01-31 04:38:38 -080066 head = rcu_dereference(head->next);
Patrick McHardyf205c5e2007-07-07 22:28:14 -070067 while (head == NULL) {
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080068 if (++st->bucket >= nf_conntrack_htable_size)
69 return NULL;
Patrick McHardy76507f62008-01-31 04:38:38 -080070 head = rcu_dereference(nf_conntrack_hash[st->bucket].first);
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080071 }
72 return head;
73}
74
Patrick McHardyf205c5e2007-07-07 22:28:14 -070075static struct hlist_node *ct_get_idx(struct seq_file *seq, loff_t pos)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080076{
Patrick McHardyf205c5e2007-07-07 22:28:14 -070077 struct hlist_node *head = ct_get_first(seq);
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080078
79 if (head)
80 while (pos && (head = ct_get_next(seq, head)))
81 pos--;
82 return pos ? NULL : head;
83}
84
85static void *ct_seq_start(struct seq_file *seq, loff_t *pos)
Patrick McHardy76507f62008-01-31 04:38:38 -080086 __acquires(RCU)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080087{
Patrick McHardy76507f62008-01-31 04:38:38 -080088 rcu_read_lock();
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080089 return ct_get_idx(seq, *pos);
90}
91
92static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos)
93{
94 (*pos)++;
95 return ct_get_next(s, v);
96}
97
98static void ct_seq_stop(struct seq_file *s, void *v)
Patrick McHardy76507f62008-01-31 04:38:38 -080099 __releases(RCU)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800100{
Patrick McHardy76507f62008-01-31 04:38:38 -0800101 rcu_read_unlock();
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800102}
103
104/* return 0 on success, 1 in case of error */
105static int ct_seq_show(struct seq_file *s, void *v)
106{
107 const struct nf_conntrack_tuple_hash *hash = v;
Patrick McHardyc88130b2008-01-31 04:42:11 -0800108 const struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(hash);
Jan Engelhardt32948582008-01-31 04:53:24 -0800109 const struct nf_conntrack_l3proto *l3proto;
110 const struct nf_conntrack_l4proto *l4proto;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800111
Patrick McHardyc88130b2008-01-31 04:42:11 -0800112 NF_CT_ASSERT(ct);
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800113
114 /* we only want to print DIR_ORIGINAL */
115 if (NF_CT_DIRECTION(hash))
116 return 0;
117
Patrick McHardy5e8fbe22008-04-14 11:15:52 +0200118 l3proto = __nf_ct_l3proto_find(nf_ct_l3num(ct));
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800119 NF_CT_ASSERT(l3proto);
Patrick McHardy5e8fbe22008-04-14 11:15:52 +0200120 l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct));
Martin Josefsson605dcad2006-11-29 02:35:06 +0100121 NF_CT_ASSERT(l4proto);
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800122
123 if (seq_printf(s, "%-8s %u %-8s %u %ld ",
Patrick McHardy5e8fbe22008-04-14 11:15:52 +0200124 l3proto->name, nf_ct_l3num(ct),
125 l4proto->name, nf_ct_protonum(ct),
Patrick McHardyc88130b2008-01-31 04:42:11 -0800126 timer_pending(&ct->timeout)
127 ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800128 return -ENOSPC;
129
Patrick McHardyc88130b2008-01-31 04:42:11 -0800130 if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800131 return -ENOSPC;
132
Patrick McHardyc88130b2008-01-31 04:42:11 -0800133 if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
Martin Josefsson605dcad2006-11-29 02:35:06 +0100134 l3proto, l4proto))
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800135 return -ENOSPC;
136
Krzysztof Piotr Oledzki58401572008-07-21 10:01:34 -0700137 if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800138 return -ENOSPC;
139
Patrick McHardyc88130b2008-01-31 04:42:11 -0800140 if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status)))
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800141 if (seq_printf(s, "[UNREPLIED] "))
142 return -ENOSPC;
143
Patrick McHardyc88130b2008-01-31 04:42:11 -0800144 if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
Martin Josefsson605dcad2006-11-29 02:35:06 +0100145 l3proto, l4proto))
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800146 return -ENOSPC;
147
Krzysztof Piotr Oledzki58401572008-07-21 10:01:34 -0700148 if (seq_print_acct(s, ct, IP_CT_DIR_REPLY))
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800149 return -ENOSPC;
150
Patrick McHardyc88130b2008-01-31 04:42:11 -0800151 if (test_bit(IPS_ASSURED_BIT, &ct->status))
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800152 if (seq_printf(s, "[ASSURED] "))
153 return -ENOSPC;
154
155#if defined(CONFIG_NF_CONNTRACK_MARK)
Patrick McHardyc88130b2008-01-31 04:42:11 -0800156 if (seq_printf(s, "mark=%u ", ct->mark))
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800157 return -ENOSPC;
158#endif
159
James Morris7c9728c2006-06-09 00:31:46 -0700160#ifdef CONFIG_NF_CONNTRACK_SECMARK
Patrick McHardyc88130b2008-01-31 04:42:11 -0800161 if (seq_printf(s, "secmark=%u ", ct->secmark))
James Morris7c9728c2006-06-09 00:31:46 -0700162 return -ENOSPC;
163#endif
164
Patrick McHardyc88130b2008-01-31 04:42:11 -0800165 if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use)))
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800166 return -ENOSPC;
YOSHIFUJI Hideakia5d29262007-07-19 10:44:21 +0900167
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800168 return 0;
169}
170
Philippe De Muyter56b3d972007-07-10 23:07:31 -0700171static const struct seq_operations ct_seq_ops = {
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800172 .start = ct_seq_start,
173 .next = ct_seq_next,
174 .stop = ct_seq_stop,
175 .show = ct_seq_show
176};
177
178static int ct_open(struct inode *inode, struct file *file)
179{
Pavel Emelyanove2da5912007-10-10 02:29:58 -0700180 return seq_open_private(file, &ct_seq_ops,
181 sizeof(struct ct_iter_state));
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800182}
183
Arjan van de Venda7071d2007-02-12 00:55:36 -0800184static const struct file_operations ct_file_ops = {
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800185 .owner = THIS_MODULE,
186 .open = ct_open,
187 .read = seq_read,
188 .llseek = seq_lseek,
189 .release = seq_release_private,
190};
191
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800192static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
193{
194 int cpu;
195
196 if (*pos == 0)
197 return SEQ_START_TOKEN;
198
199 for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) {
200 if (!cpu_possible(cpu))
201 continue;
202 *pos = cpu + 1;
203 return &per_cpu(nf_conntrack_stat, cpu);
204 }
205
206 return NULL;
207}
208
209static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
210{
211 int cpu;
212
213 for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
214 if (!cpu_possible(cpu))
215 continue;
216 *pos = cpu + 1;
217 return &per_cpu(nf_conntrack_stat, cpu);
218 }
219
220 return NULL;
221}
222
223static void ct_cpu_seq_stop(struct seq_file *seq, void *v)
224{
225}
226
227static int ct_cpu_seq_show(struct seq_file *seq, void *v)
228{
229 unsigned int nr_conntracks = atomic_read(&nf_conntrack_count);
Jan Engelhardt32948582008-01-31 04:53:24 -0800230 const struct ip_conntrack_stat *st = v;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800231
232 if (v == SEQ_START_TOKEN) {
233 seq_printf(seq, "entries searched found new invalid ignore delete delete_list insert insert_failed drop early_drop icmp_error expect_new expect_create expect_delete\n");
234 return 0;
235 }
236
237 seq_printf(seq, "%08x %08x %08x %08x %08x %08x %08x %08x "
238 "%08x %08x %08x %08x %08x %08x %08x %08x \n",
239 nr_conntracks,
240 st->searched,
241 st->found,
242 st->new,
243 st->invalid,
244 st->ignore,
245 st->delete,
246 st->delete_list,
247 st->insert,
248 st->insert_failed,
249 st->drop,
250 st->early_drop,
251 st->error,
252
253 st->expect_new,
254 st->expect_create,
255 st->expect_delete
256 );
257 return 0;
258}
259
Philippe De Muyter56b3d972007-07-10 23:07:31 -0700260static const struct seq_operations ct_cpu_seq_ops = {
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800261 .start = ct_cpu_seq_start,
262 .next = ct_cpu_seq_next,
263 .stop = ct_cpu_seq_stop,
264 .show = ct_cpu_seq_show,
265};
266
267static int ct_cpu_seq_open(struct inode *inode, struct file *file)
268{
269 return seq_open(file, &ct_cpu_seq_ops);
270}
271
Arjan van de Venda7071d2007-02-12 00:55:36 -0800272static const struct file_operations ct_cpu_seq_fops = {
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800273 .owner = THIS_MODULE,
274 .open = ct_cpu_seq_open,
275 .read = seq_read,
276 .llseek = seq_lseek,
Pavel Emelyanov665bba12008-02-29 11:39:17 -0800277 .release = seq_release,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800278};
Alexey Dobriyanb916f7d2008-03-20 15:15:43 +0100279
280static int nf_conntrack_standalone_init_proc(void)
281{
282 struct proc_dir_entry *pde;
283
284 pde = proc_net_fops_create(&init_net, "nf_conntrack", 0440, &ct_file_ops);
285 if (!pde)
286 goto out_nf_conntrack;
Denis V. Lunev52c0e112008-05-02 04:10:57 -0700287
288 pde = proc_create("nf_conntrack", S_IRUGO, init_net.proc_net_stat,
289 &ct_cpu_seq_fops);
Alexey Dobriyanb916f7d2008-03-20 15:15:43 +0100290 if (!pde)
291 goto out_stat_nf_conntrack;
Alexey Dobriyanb916f7d2008-03-20 15:15:43 +0100292 return 0;
293
294out_stat_nf_conntrack:
295 proc_net_remove(&init_net, "nf_conntrack");
296out_nf_conntrack:
297 return -ENOMEM;
298}
299
300static void nf_conntrack_standalone_fini_proc(void)
301{
302 remove_proc_entry("nf_conntrack", init_net.proc_net_stat);
303 proc_net_remove(&init_net, "nf_conntrack");
304}
305#else
306static int nf_conntrack_standalone_init_proc(void)
307{
308 return 0;
309}
310
311static void nf_conntrack_standalone_fini_proc(void)
312{
313}
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800314#endif /* CONFIG_PROC_FS */
315
316/* Sysctl support */
317
Brian Haley94aec082006-09-18 00:05:22 -0700318int nf_conntrack_checksum __read_mostly = 1;
Patrick McHardy13b18332006-12-02 22:11:25 -0800319EXPORT_SYMBOL_GPL(nf_conntrack_checksum);
Adrian Bunk72b55822006-07-24 22:53:12 -0700320
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800321#ifdef CONFIG_SYSCTL
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800322/* Log invalid packets of a given protocol */
323static int log_invalid_proto_min = 0;
324static int log_invalid_proto_max = 255;
325
326static struct ctl_table_header *nf_ct_sysctl_header;
Krzysztof Piotr Oledzki9714be72008-08-06 02:35:44 -0700327static struct ctl_table_header *nf_ct_netfilter_header;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800328
329static ctl_table nf_ct_sysctl_table[] = {
330 {
331 .ctl_name = NET_NF_CONNTRACK_MAX,
332 .procname = "nf_conntrack_max",
333 .data = &nf_conntrack_max,
334 .maxlen = sizeof(int),
335 .mode = 0644,
336 .proc_handler = &proc_dointvec,
337 },
338 {
339 .ctl_name = NET_NF_CONNTRACK_COUNT,
340 .procname = "nf_conntrack_count",
341 .data = &nf_conntrack_count,
342 .maxlen = sizeof(int),
343 .mode = 0444,
344 .proc_handler = &proc_dointvec,
345 },
346 {
347 .ctl_name = NET_NF_CONNTRACK_BUCKETS,
348 .procname = "nf_conntrack_buckets",
349 .data = &nf_conntrack_htable_size,
350 .maxlen = sizeof(unsigned int),
351 .mode = 0444,
352 .proc_handler = &proc_dointvec,
353 },
354 {
Patrick McHardy39a27a32006-05-29 18:23:54 -0700355 .ctl_name = NET_NF_CONNTRACK_CHECKSUM,
356 .procname = "nf_conntrack_checksum",
357 .data = &nf_conntrack_checksum,
358 .maxlen = sizeof(unsigned int),
359 .mode = 0644,
360 .proc_handler = &proc_dointvec,
361 },
362 {
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800363 .ctl_name = NET_NF_CONNTRACK_LOG_INVALID,
364 .procname = "nf_conntrack_log_invalid",
365 .data = &nf_ct_log_invalid,
366 .maxlen = sizeof(unsigned int),
367 .mode = 0644,
368 .proc_handler = &proc_dointvec_minmax,
369 .strategy = &sysctl_intvec,
370 .extra1 = &log_invalid_proto_min,
371 .extra2 = &log_invalid_proto_max,
372 },
Patrick McHardyf264a7d2007-07-07 22:36:24 -0700373 {
374 .ctl_name = CTL_UNNUMBERED,
375 .procname = "nf_conntrack_expect_max",
376 .data = &nf_ct_expect_max,
377 .maxlen = sizeof(int),
378 .mode = 0644,
379 .proc_handler = &proc_dointvec,
380 },
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800381 { .ctl_name = 0 }
382};
383
384#define NET_NF_CONNTRACK_MAX 2089
385
386static ctl_table nf_ct_netfilter_table[] = {
387 {
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800388 .ctl_name = NET_NF_CONNTRACK_MAX,
389 .procname = "nf_conntrack_max",
390 .data = &nf_conntrack_max,
391 .maxlen = sizeof(int),
392 .mode = 0644,
393 .proc_handler = &proc_dointvec,
394 },
395 { .ctl_name = 0 }
396};
397
Patrick McHardy9e232492008-01-31 04:54:45 -0800398static struct ctl_path nf_ct_path[] = {
Pavel Emelyanov3d7cc2b2008-01-09 00:33:11 -0800399 { .procname = "net", .ctl_name = CTL_NET, },
400 { }
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800401};
Pavel Emelyanov3d7cc2b2008-01-09 00:33:11 -0800402
Patrick McHardy13b18332006-12-02 22:11:25 -0800403EXPORT_SYMBOL_GPL(nf_ct_log_invalid);
Alexey Dobriyanb916f7d2008-03-20 15:15:43 +0100404
405static int nf_conntrack_standalone_init_sysctl(void)
406{
Krzysztof Piotr Oledzki9714be72008-08-06 02:35:44 -0700407 nf_ct_netfilter_header =
Alexey Dobriyanb916f7d2008-03-20 15:15:43 +0100408 register_sysctl_paths(nf_ct_path, nf_ct_netfilter_table);
Krzysztof Piotr Oledzki9714be72008-08-06 02:35:44 -0700409 if (!nf_ct_netfilter_header)
410 goto out;
411
412 nf_ct_sysctl_header =
413 register_sysctl_paths(nf_net_netfilter_sysctl_path,
414 nf_ct_sysctl_table);
415 if (!nf_ct_sysctl_header)
416 goto out_unregister_netfilter;
417
Alexey Dobriyanb916f7d2008-03-20 15:15:43 +0100418 return 0;
419
Krzysztof Piotr Oledzki9714be72008-08-06 02:35:44 -0700420out_unregister_netfilter:
421 unregister_sysctl_table(nf_ct_netfilter_header);
422out:
423 printk("nf_conntrack: can't register to sysctl.\n");
424 return -ENOMEM;
Alexey Dobriyanb916f7d2008-03-20 15:15:43 +0100425}
426
427static void nf_conntrack_standalone_fini_sysctl(void)
428{
Krzysztof Piotr Oledzki9714be72008-08-06 02:35:44 -0700429 unregister_sysctl_table(nf_ct_netfilter_header);
Alexey Dobriyanb916f7d2008-03-20 15:15:43 +0100430 unregister_sysctl_table(nf_ct_sysctl_header);
431}
432#else
433static int nf_conntrack_standalone_init_sysctl(void)
434{
435 return 0;
436}
437
438static void nf_conntrack_standalone_fini_sysctl(void)
439{
440}
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800441#endif /* CONFIG_SYSCTL */
442
Andrew Morton65b4b4e2006-03-28 16:37:06 -0800443static int __init nf_conntrack_standalone_init(void)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800444{
Alexey Dobriyanb916f7d2008-03-20 15:15:43 +0100445 int ret;
Patrick McHardy32292a72006-04-06 14:11:30 -0700446
447 ret = nf_conntrack_init();
448 if (ret < 0)
Alexey Dobriyanb916f7d2008-03-20 15:15:43 +0100449 goto out;
450 ret = nf_conntrack_standalone_init_proc();
451 if (ret < 0)
452 goto out_proc;
453 ret = nf_conntrack_standalone_init_sysctl();
454 if (ret < 0)
455 goto out_sysctl;
456 return 0;
Patrick McHardy32292a72006-04-06 14:11:30 -0700457
Alexey Dobriyanb916f7d2008-03-20 15:15:43 +0100458out_sysctl:
459 nf_conntrack_standalone_fini_proc();
460out_proc:
Patrick McHardy32292a72006-04-06 14:11:30 -0700461 nf_conntrack_cleanup();
Alexey Dobriyanb916f7d2008-03-20 15:15:43 +0100462out:
Patrick McHardy32292a72006-04-06 14:11:30 -0700463 return ret;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800464}
465
Andrew Morton65b4b4e2006-03-28 16:37:06 -0800466static void __exit nf_conntrack_standalone_fini(void)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800467{
Alexey Dobriyanb916f7d2008-03-20 15:15:43 +0100468 nf_conntrack_standalone_fini_sysctl();
469 nf_conntrack_standalone_fini_proc();
Patrick McHardy32292a72006-04-06 14:11:30 -0700470 nf_conntrack_cleanup();
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800471}
472
Andrew Morton65b4b4e2006-03-28 16:37:06 -0800473module_init(nf_conntrack_standalone_init);
474module_exit(nf_conntrack_standalone_fini);
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800475
476/* Some modules need us, but don't depend directly on any symbol.
477 They should call this. */
Harald Welte2e4e6a12006-01-12 13:30:04 -0800478void need_conntrack(void)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800479{
480}
Patrick McHardy13b18332006-12-02 22:11:25 -0800481EXPORT_SYMBOL_GPL(need_conntrack);