1 /* This file contains all the functions required for the standalone
4 These are not required by the compatibility layer.
7 /* (C) 1999-2001 Paul `Rusty' Russell
8 * (C) 2002-2005 Netfilter Core Team <coreteam@netfilter.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/types.h>
17 #include <linux/netfilter.h>
18 #include <linux/netfilter_ipv4.h>
19 #include <linux/module.h>
20 #include <linux/skbuff.h>
21 #include <linux/proc_fs.h>
22 #include <linux/seq_file.h>
23 #include <linux/percpu.h>
25 #include <linux/sysctl.h>
27 #include <net/checksum.h>
29 #include <net/route.h>
31 #include <linux/netfilter_ipv4/ip_conntrack.h>
32 #include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
33 #include <linux/netfilter_ipv4/ip_conntrack_core.h>
34 #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
39 #define DEBUGP(format, args...)
42 MODULE_LICENSE("GPL");
44 extern atomic_t ip_conntrack_count;
45 DECLARE_PER_CPU(struct ip_conntrack_stat, ip_conntrack_stat);
47 static int kill_proto(struct ip_conntrack *i, void *data)
49 return (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum ==
50 *((u_int8_t *) data));
55 print_tuple(struct seq_file *s, const struct ip_conntrack_tuple *tuple,
56 struct ip_conntrack_protocol *proto)
58 seq_printf(s, "src=%u.%u.%u.%u dst=%u.%u.%u.%u ",
59 NIPQUAD(tuple->src.ip), NIPQUAD(tuple->dst.ip));
60 return proto->print_tuple(s, tuple);
63 #ifdef CONFIG_IP_NF_CT_ACCT
65 seq_print_counters(struct seq_file *s,
66 const struct ip_conntrack_counter *counter)
68 return seq_printf(s, "packets=%llu bytes=%llu ",
69 (unsigned long long)counter->packets,
70 (unsigned long long)counter->bytes);
73 #define seq_print_counters(x, y) 0
76 struct ct_iter_state {
80 static struct list_head *ct_get_first(struct seq_file *seq)
82 struct ct_iter_state *st = seq->private;
85 st->bucket < ip_conntrack_htable_size;
87 if (!list_empty(&ip_conntrack_hash[st->bucket]))
88 return ip_conntrack_hash[st->bucket].next;
93 static struct list_head *ct_get_next(struct seq_file *seq, struct list_head *head)
95 struct ct_iter_state *st = seq->private;
98 while (head == &ip_conntrack_hash[st->bucket]) {
99 if (++st->bucket >= ip_conntrack_htable_size)
101 head = ip_conntrack_hash[st->bucket].next;
106 static struct list_head *ct_get_idx(struct seq_file *seq, loff_t pos)
108 struct list_head *head = ct_get_first(seq);
111 while (pos && (head = ct_get_next(seq, head)))
113 return pos ? NULL : head;
116 static void *ct_seq_start(struct seq_file *seq, loff_t *pos)
118 read_lock_bh(&ip_conntrack_lock);
119 return ct_get_idx(seq, *pos);
122 static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos)
125 return ct_get_next(s, v);
128 static void ct_seq_stop(struct seq_file *s, void *v)
130 read_unlock_bh(&ip_conntrack_lock);
133 static int ct_seq_show(struct seq_file *s, void *v)
135 const struct ip_conntrack_tuple_hash *hash = v;
136 const struct ip_conntrack *conntrack = tuplehash_to_ctrack(hash);
137 struct ip_conntrack_protocol *proto;
139 IP_NF_ASSERT(conntrack);
141 /* we only want to print DIR_ORIGINAL */
145 proto = __ip_conntrack_proto_find(conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum);
148 if (seq_printf(s, "%-8s %u %ld ",
150 conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum,
151 timer_pending(&conntrack->timeout)
152 ? (long)(conntrack->timeout.expires - jiffies)/HZ
156 if (proto->print_conntrack(s, conntrack))
159 if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
163 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_ORIGINAL]))
166 if (!(test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)))
167 if (seq_printf(s, "[UNREPLIED] "))
170 if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_REPLY].tuple,
174 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_REPLY]))
177 if (test_bit(IPS_ASSURED_BIT, &conntrack->status))
178 if (seq_printf(s, "[ASSURED] "))
181 #if defined(CONFIG_IP_NF_CONNTRACK_MARK)
182 if (seq_printf(s, "mark=%u ", conntrack->mark))
186 #ifdef CONFIG_IP_NF_CONNTRACK_SECMARK
187 if (seq_printf(s, "secmark=%u ", conntrack->secmark))
191 if (seq_printf(s, "use=%u\n", atomic_read(&conntrack->ct_general.use)))
197 static struct seq_operations ct_seq_ops = {
198 .start = ct_seq_start,
204 static int ct_open(struct inode *inode, struct file *file)
206 struct seq_file *seq;
207 struct ct_iter_state *st;
210 st = kmalloc(sizeof(struct ct_iter_state), GFP_KERNEL);
213 ret = seq_open(file, &ct_seq_ops);
216 seq = file->private_data;
218 memset(st, 0, sizeof(struct ct_iter_state));
225 static const struct file_operations ct_file_ops = {
226 .owner = THIS_MODULE,
230 .release = seq_release_private,
234 static void *exp_seq_start(struct seq_file *s, loff_t *pos)
236 struct list_head *e = &ip_conntrack_expect_list;
239 /* strange seq_file api calls stop even if we fail,
240 * thus we need to grab lock since stop unlocks */
241 read_lock_bh(&ip_conntrack_lock);
246 for (i = 0; i <= *pos; i++) {
248 if (e == &ip_conntrack_expect_list)
254 static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos)
256 struct list_head *e = v;
261 if (e == &ip_conntrack_expect_list)
267 static void exp_seq_stop(struct seq_file *s, void *v)
269 read_unlock_bh(&ip_conntrack_lock);
272 static int exp_seq_show(struct seq_file *s, void *v)
274 struct ip_conntrack_expect *expect = v;
276 if (expect->timeout.function)
277 seq_printf(s, "%ld ", timer_pending(&expect->timeout)
278 ? (long)(expect->timeout.expires - jiffies)/HZ : 0);
282 seq_printf(s, "proto=%u ", expect->tuple.dst.protonum);
284 print_tuple(s, &expect->tuple,
285 __ip_conntrack_proto_find(expect->tuple.dst.protonum));
286 return seq_putc(s, '\n');
289 static struct seq_operations exp_seq_ops = {
290 .start = exp_seq_start,
291 .next = exp_seq_next,
292 .stop = exp_seq_stop,
296 static int exp_open(struct inode *inode, struct file *file)
298 return seq_open(file, &exp_seq_ops);
301 static const struct file_operations exp_file_ops = {
302 .owner = THIS_MODULE,
306 .release = seq_release
309 static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
314 return SEQ_START_TOKEN;
316 for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) {
317 if (!cpu_possible(cpu))
320 return &per_cpu(ip_conntrack_stat, cpu);
326 static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
330 for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
331 if (!cpu_possible(cpu))
334 return &per_cpu(ip_conntrack_stat, cpu);
340 static void ct_cpu_seq_stop(struct seq_file *seq, void *v)
344 static int ct_cpu_seq_show(struct seq_file *seq, void *v)
346 unsigned int nr_conntracks = atomic_read(&ip_conntrack_count);
347 struct ip_conntrack_stat *st = v;
349 if (v == SEQ_START_TOKEN) {
350 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");
354 seq_printf(seq, "%08x %08x %08x %08x %08x %08x %08x %08x "
355 "%08x %08x %08x %08x %08x %08x %08x %08x \n",
377 static struct seq_operations ct_cpu_seq_ops = {
378 .start = ct_cpu_seq_start,
379 .next = ct_cpu_seq_next,
380 .stop = ct_cpu_seq_stop,
381 .show = ct_cpu_seq_show,
384 static int ct_cpu_seq_open(struct inode *inode, struct file *file)
386 return seq_open(file, &ct_cpu_seq_ops);
389 static const struct file_operations ct_cpu_seq_fops = {
390 .owner = THIS_MODULE,
391 .open = ct_cpu_seq_open,
394 .release = seq_release_private,
398 static unsigned int ip_confirm(unsigned int hooknum,
399 struct sk_buff **pskb,
400 const struct net_device *in,
401 const struct net_device *out,
402 int (*okfn)(struct sk_buff *))
404 /* We've seen it coming out the other side: confirm it */
405 return ip_conntrack_confirm(pskb);
408 static unsigned int ip_conntrack_help(unsigned int hooknum,
409 struct sk_buff **pskb,
410 const struct net_device *in,
411 const struct net_device *out,
412 int (*okfn)(struct sk_buff *))
414 struct ip_conntrack *ct;
415 enum ip_conntrack_info ctinfo;
417 /* This is where we call the helper: as the packet goes out. */
418 ct = ip_conntrack_get(*pskb, &ctinfo);
419 if (ct && ct->helper && ctinfo != IP_CT_RELATED + IP_CT_IS_REPLY) {
421 ret = ct->helper->help(pskb, ct, ctinfo);
422 if (ret != NF_ACCEPT)
428 static unsigned int ip_conntrack_defrag(unsigned int hooknum,
429 struct sk_buff **pskb,
430 const struct net_device *in,
431 const struct net_device *out,
432 int (*okfn)(struct sk_buff *))
434 #if !defined(CONFIG_IP_NF_NAT) && !defined(CONFIG_IP_NF_NAT_MODULE)
435 /* Previously seen (loopback)? Ignore. Do this before
441 /* Gather fragments. */
442 if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
443 *pskb = ip_ct_gather_frags(*pskb,
444 hooknum == NF_IP_PRE_ROUTING ?
445 IP_DEFRAG_CONNTRACK_IN :
446 IP_DEFRAG_CONNTRACK_OUT);
453 static unsigned int ip_conntrack_local(unsigned int hooknum,
454 struct sk_buff **pskb,
455 const struct net_device *in,
456 const struct net_device *out,
457 int (*okfn)(struct sk_buff *))
459 /* root is playing with raw sockets. */
460 if ((*pskb)->len < sizeof(struct iphdr)
461 || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) {
463 printk("ipt_hook: happy cracking.\n");
466 return ip_conntrack_in(hooknum, pskb, in, out, okfn);
469 /* Connection tracking may drop packets, but never alters them, so
470 make it the first hook. */
471 static struct nf_hook_ops ip_conntrack_ops[] = {
473 .hook = ip_conntrack_defrag,
474 .owner = THIS_MODULE,
476 .hooknum = NF_IP_PRE_ROUTING,
477 .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
480 .hook = ip_conntrack_in,
481 .owner = THIS_MODULE,
483 .hooknum = NF_IP_PRE_ROUTING,
484 .priority = NF_IP_PRI_CONNTRACK,
487 .hook = ip_conntrack_defrag,
488 .owner = THIS_MODULE,
490 .hooknum = NF_IP_LOCAL_OUT,
491 .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
494 .hook = ip_conntrack_local,
495 .owner = THIS_MODULE,
497 .hooknum = NF_IP_LOCAL_OUT,
498 .priority = NF_IP_PRI_CONNTRACK,
501 .hook = ip_conntrack_help,
502 .owner = THIS_MODULE,
504 .hooknum = NF_IP_POST_ROUTING,
505 .priority = NF_IP_PRI_CONNTRACK_HELPER,
508 .hook = ip_conntrack_help,
509 .owner = THIS_MODULE,
511 .hooknum = NF_IP_LOCAL_IN,
512 .priority = NF_IP_PRI_CONNTRACK_HELPER,
516 .owner = THIS_MODULE,
518 .hooknum = NF_IP_POST_ROUTING,
519 .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
523 .owner = THIS_MODULE,
525 .hooknum = NF_IP_LOCAL_IN,
526 .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
532 int ip_conntrack_checksum __read_mostly = 1;
536 /* From ip_conntrack_core.c */
537 extern int ip_conntrack_max;
538 extern unsigned int ip_conntrack_htable_size;
540 /* From ip_conntrack_proto_tcp.c */
541 extern unsigned int ip_ct_tcp_timeout_syn_sent;
542 extern unsigned int ip_ct_tcp_timeout_syn_recv;
543 extern unsigned int ip_ct_tcp_timeout_established;
544 extern unsigned int ip_ct_tcp_timeout_fin_wait;
545 extern unsigned int ip_ct_tcp_timeout_close_wait;
546 extern unsigned int ip_ct_tcp_timeout_last_ack;
547 extern unsigned int ip_ct_tcp_timeout_time_wait;
548 extern unsigned int ip_ct_tcp_timeout_close;
549 extern unsigned int ip_ct_tcp_timeout_max_retrans;
550 extern int ip_ct_tcp_loose;
551 extern int ip_ct_tcp_be_liberal;
552 extern int ip_ct_tcp_max_retrans;
554 /* From ip_conntrack_proto_udp.c */
555 extern unsigned int ip_ct_udp_timeout;
556 extern unsigned int ip_ct_udp_timeout_stream;
558 /* From ip_conntrack_proto_icmp.c */
559 extern unsigned int ip_ct_icmp_timeout;
561 /* From ip_conntrack_proto_generic.c */
562 extern unsigned int ip_ct_generic_timeout;
564 /* Log invalid packets of a given protocol */
565 static int log_invalid_proto_min = 0;
566 static int log_invalid_proto_max = 255;
568 static struct ctl_table_header *ip_ct_sysctl_header;
570 static ctl_table ip_ct_sysctl_table[] = {
572 .ctl_name = NET_IPV4_NF_CONNTRACK_MAX,
573 .procname = "ip_conntrack_max",
574 .data = &ip_conntrack_max,
575 .maxlen = sizeof(int),
577 .proc_handler = &proc_dointvec,
580 .ctl_name = NET_IPV4_NF_CONNTRACK_COUNT,
581 .procname = "ip_conntrack_count",
582 .data = &ip_conntrack_count,
583 .maxlen = sizeof(int),
585 .proc_handler = &proc_dointvec,
588 .ctl_name = NET_IPV4_NF_CONNTRACK_BUCKETS,
589 .procname = "ip_conntrack_buckets",
590 .data = &ip_conntrack_htable_size,
591 .maxlen = sizeof(unsigned int),
593 .proc_handler = &proc_dointvec,
596 .ctl_name = NET_IPV4_NF_CONNTRACK_CHECKSUM,
597 .procname = "ip_conntrack_checksum",
598 .data = &ip_conntrack_checksum,
599 .maxlen = sizeof(int),
601 .proc_handler = &proc_dointvec,
604 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT,
605 .procname = "ip_conntrack_tcp_timeout_syn_sent",
606 .data = &ip_ct_tcp_timeout_syn_sent,
607 .maxlen = sizeof(unsigned int),
609 .proc_handler = &proc_dointvec_jiffies,
612 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV,
613 .procname = "ip_conntrack_tcp_timeout_syn_recv",
614 .data = &ip_ct_tcp_timeout_syn_recv,
615 .maxlen = sizeof(unsigned int),
617 .proc_handler = &proc_dointvec_jiffies,
620 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED,
621 .procname = "ip_conntrack_tcp_timeout_established",
622 .data = &ip_ct_tcp_timeout_established,
623 .maxlen = sizeof(unsigned int),
625 .proc_handler = &proc_dointvec_jiffies,
628 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT,
629 .procname = "ip_conntrack_tcp_timeout_fin_wait",
630 .data = &ip_ct_tcp_timeout_fin_wait,
631 .maxlen = sizeof(unsigned int),
633 .proc_handler = &proc_dointvec_jiffies,
636 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT,
637 .procname = "ip_conntrack_tcp_timeout_close_wait",
638 .data = &ip_ct_tcp_timeout_close_wait,
639 .maxlen = sizeof(unsigned int),
641 .proc_handler = &proc_dointvec_jiffies,
644 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK,
645 .procname = "ip_conntrack_tcp_timeout_last_ack",
646 .data = &ip_ct_tcp_timeout_last_ack,
647 .maxlen = sizeof(unsigned int),
649 .proc_handler = &proc_dointvec_jiffies,
652 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT,
653 .procname = "ip_conntrack_tcp_timeout_time_wait",
654 .data = &ip_ct_tcp_timeout_time_wait,
655 .maxlen = sizeof(unsigned int),
657 .proc_handler = &proc_dointvec_jiffies,
660 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE,
661 .procname = "ip_conntrack_tcp_timeout_close",
662 .data = &ip_ct_tcp_timeout_close,
663 .maxlen = sizeof(unsigned int),
665 .proc_handler = &proc_dointvec_jiffies,
668 .ctl_name = NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT,
669 .procname = "ip_conntrack_udp_timeout",
670 .data = &ip_ct_udp_timeout,
671 .maxlen = sizeof(unsigned int),
673 .proc_handler = &proc_dointvec_jiffies,
676 .ctl_name = NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT_STREAM,
677 .procname = "ip_conntrack_udp_timeout_stream",
678 .data = &ip_ct_udp_timeout_stream,
679 .maxlen = sizeof(unsigned int),
681 .proc_handler = &proc_dointvec_jiffies,
684 .ctl_name = NET_IPV4_NF_CONNTRACK_ICMP_TIMEOUT,
685 .procname = "ip_conntrack_icmp_timeout",
686 .data = &ip_ct_icmp_timeout,
687 .maxlen = sizeof(unsigned int),
689 .proc_handler = &proc_dointvec_jiffies,
692 .ctl_name = NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT,
693 .procname = "ip_conntrack_generic_timeout",
694 .data = &ip_ct_generic_timeout,
695 .maxlen = sizeof(unsigned int),
697 .proc_handler = &proc_dointvec_jiffies,
700 .ctl_name = NET_IPV4_NF_CONNTRACK_LOG_INVALID,
701 .procname = "ip_conntrack_log_invalid",
702 .data = &ip_ct_log_invalid,
703 .maxlen = sizeof(unsigned int),
705 .proc_handler = &proc_dointvec_minmax,
706 .strategy = &sysctl_intvec,
707 .extra1 = &log_invalid_proto_min,
708 .extra2 = &log_invalid_proto_max,
711 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS,
712 .procname = "ip_conntrack_tcp_timeout_max_retrans",
713 .data = &ip_ct_tcp_timeout_max_retrans,
714 .maxlen = sizeof(unsigned int),
716 .proc_handler = &proc_dointvec_jiffies,
719 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_LOOSE,
720 .procname = "ip_conntrack_tcp_loose",
721 .data = &ip_ct_tcp_loose,
722 .maxlen = sizeof(unsigned int),
724 .proc_handler = &proc_dointvec,
727 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_BE_LIBERAL,
728 .procname = "ip_conntrack_tcp_be_liberal",
729 .data = &ip_ct_tcp_be_liberal,
730 .maxlen = sizeof(unsigned int),
732 .proc_handler = &proc_dointvec,
735 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_MAX_RETRANS,
736 .procname = "ip_conntrack_tcp_max_retrans",
737 .data = &ip_ct_tcp_max_retrans,
738 .maxlen = sizeof(unsigned int),
740 .proc_handler = &proc_dointvec,
745 #define NET_IP_CONNTRACK_MAX 2089
747 static ctl_table ip_ct_netfilter_table[] = {
749 .ctl_name = NET_IPV4_NETFILTER,
750 .procname = "netfilter",
752 .child = ip_ct_sysctl_table,
755 .ctl_name = NET_IP_CONNTRACK_MAX,
756 .procname = "ip_conntrack_max",
757 .data = &ip_conntrack_max,
758 .maxlen = sizeof(int),
760 .proc_handler = &proc_dointvec
765 static ctl_table ip_ct_ipv4_table[] = {
767 .ctl_name = NET_IPV4,
770 .child = ip_ct_netfilter_table,
775 static ctl_table ip_ct_net_table[] = {
780 .child = ip_ct_ipv4_table,
785 EXPORT_SYMBOL(ip_ct_log_invalid);
786 #endif /* CONFIG_SYSCTL */
788 /* FIXME: Allow NULL functions and sub in pointers to generic for
790 int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto)
794 write_lock_bh(&ip_conntrack_lock);
795 if (ip_ct_protos[proto->proto] != &ip_conntrack_generic_protocol) {
799 rcu_assign_pointer(ip_ct_protos[proto->proto], proto);
801 write_unlock_bh(&ip_conntrack_lock);
805 void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto)
807 write_lock_bh(&ip_conntrack_lock);
808 rcu_assign_pointer(ip_ct_protos[proto->proto],
809 &ip_conntrack_generic_protocol);
810 write_unlock_bh(&ip_conntrack_lock);
813 /* Remove all contrack entries for this protocol */
814 ip_ct_iterate_cleanup(kill_proto, &proto->proto);
817 static int __init ip_conntrack_standalone_init(void)
819 #ifdef CONFIG_PROC_FS
820 struct proc_dir_entry *proc, *proc_exp, *proc_stat;
824 ret = ip_conntrack_init();
828 #ifdef CONFIG_PROC_FS
830 proc = proc_net_fops_create("ip_conntrack", 0440, &ct_file_ops);
831 if (!proc) goto cleanup_init;
833 proc_exp = proc_net_fops_create("ip_conntrack_expect", 0440,
835 if (!proc_exp) goto cleanup_proc;
837 proc_stat = create_proc_entry("ip_conntrack", S_IRUGO, proc_net_stat);
839 goto cleanup_proc_exp;
841 proc_stat->proc_fops = &ct_cpu_seq_fops;
842 proc_stat->owner = THIS_MODULE;
845 ret = nf_register_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
847 printk("ip_conntrack: can't register hooks.\n");
848 goto cleanup_proc_stat;
851 ip_ct_sysctl_header = register_sysctl_table(ip_ct_net_table);
852 if (ip_ct_sysctl_header == NULL) {
853 printk("ip_conntrack: can't register to sysctl.\n");
862 nf_unregister_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
865 #ifdef CONFIG_PROC_FS
866 remove_proc_entry("ip_conntrack", proc_net_stat);
868 proc_net_remove("ip_conntrack_expect");
870 proc_net_remove("ip_conntrack");
872 #endif /* CONFIG_PROC_FS */
873 ip_conntrack_cleanup();
877 static void __exit ip_conntrack_standalone_fini(void)
881 unregister_sysctl_table(ip_ct_sysctl_header);
883 nf_unregister_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
884 #ifdef CONFIG_PROC_FS
885 remove_proc_entry("ip_conntrack", proc_net_stat);
886 proc_net_remove("ip_conntrack_expect");
887 proc_net_remove("ip_conntrack");
888 #endif /* CONFIG_PROC_FS */
889 ip_conntrack_cleanup();
892 module_init(ip_conntrack_standalone_init);
893 module_exit(ip_conntrack_standalone_fini);
895 /* Some modules need us, but don't depend directly on any symbol.
896 They should call this. */
897 void need_conntrack(void)
901 #ifdef CONFIG_IP_NF_CONNTRACK_EVENTS
902 EXPORT_SYMBOL_GPL(ip_conntrack_chain);
903 EXPORT_SYMBOL_GPL(ip_conntrack_expect_chain);
904 EXPORT_SYMBOL_GPL(ip_conntrack_register_notifier);
905 EXPORT_SYMBOL_GPL(ip_conntrack_unregister_notifier);
906 EXPORT_SYMBOL_GPL(__ip_ct_event_cache_init);
907 EXPORT_PER_CPU_SYMBOL_GPL(ip_conntrack_ecache);
909 EXPORT_SYMBOL(ip_conntrack_protocol_register);
910 EXPORT_SYMBOL(ip_conntrack_protocol_unregister);
911 EXPORT_SYMBOL(ip_ct_get_tuple);
912 EXPORT_SYMBOL(invert_tuplepr);
913 EXPORT_SYMBOL(ip_conntrack_alter_reply);
914 EXPORT_SYMBOL(ip_conntrack_destroyed);
915 EXPORT_SYMBOL(need_conntrack);
916 EXPORT_SYMBOL(ip_conntrack_helper_register);
917 EXPORT_SYMBOL(ip_conntrack_helper_unregister);
918 EXPORT_SYMBOL(ip_ct_iterate_cleanup);
919 EXPORT_SYMBOL(__ip_ct_refresh_acct);
921 EXPORT_SYMBOL(ip_conntrack_expect_alloc);
922 EXPORT_SYMBOL(ip_conntrack_expect_put);
923 EXPORT_SYMBOL_GPL(__ip_conntrack_expect_find);
924 EXPORT_SYMBOL_GPL(ip_conntrack_expect_find_get);
925 EXPORT_SYMBOL(ip_conntrack_expect_related);
926 EXPORT_SYMBOL(ip_conntrack_unexpect_related);
927 EXPORT_SYMBOL_GPL(ip_conntrack_expect_list);
928 EXPORT_SYMBOL_GPL(ip_ct_unlink_expect);
930 EXPORT_SYMBOL(ip_conntrack_tuple_taken);
931 EXPORT_SYMBOL(ip_ct_gather_frags);
932 EXPORT_SYMBOL(ip_conntrack_htable_size);
933 EXPORT_SYMBOL(ip_conntrack_lock);
934 EXPORT_SYMBOL(ip_conntrack_hash);
935 EXPORT_SYMBOL(ip_conntrack_untracked);
936 EXPORT_SYMBOL_GPL(ip_conntrack_find_get);
937 #ifdef CONFIG_IP_NF_NAT_NEEDED
938 EXPORT_SYMBOL(ip_conntrack_tcp_update);
941 EXPORT_SYMBOL_GPL(ip_conntrack_flush);
942 EXPORT_SYMBOL_GPL(__ip_conntrack_find);
944 EXPORT_SYMBOL_GPL(ip_conntrack_alloc);
945 EXPORT_SYMBOL_GPL(ip_conntrack_free);
946 EXPORT_SYMBOL_GPL(ip_conntrack_hash_insert);
948 EXPORT_SYMBOL_GPL(ip_ct_remove_expectations);
950 EXPORT_SYMBOL_GPL(ip_conntrack_helper_find_get);
951 EXPORT_SYMBOL_GPL(ip_conntrack_helper_put);
952 EXPORT_SYMBOL_GPL(__ip_conntrack_helper_find_byname);
954 EXPORT_SYMBOL_GPL(ip_conntrack_proto_find_get);
955 EXPORT_SYMBOL_GPL(ip_conntrack_proto_put);
956 EXPORT_SYMBOL_GPL(__ip_conntrack_proto_find);
957 EXPORT_SYMBOL_GPL(ip_conntrack_checksum);
958 #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
959 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
960 EXPORT_SYMBOL_GPL(ip_ct_port_tuple_to_nfattr);
961 EXPORT_SYMBOL_GPL(ip_ct_port_nfattr_to_tuple);