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/config.h>
16 #include <linux/types.h>
18 #include <linux/netfilter.h>
19 #include <linux/netfilter_ipv4.h>
20 #include <linux/module.h>
21 #include <linux/skbuff.h>
22 #include <linux/proc_fs.h>
23 #include <linux/seq_file.h>
24 #include <linux/percpu.h>
26 #include <linux/sysctl.h>
28 #include <net/checksum.h>
30 #include <net/route.h>
32 #define ASSERT_READ_LOCK(x)
33 #define ASSERT_WRITE_LOCK(x)
35 #include <linux/netfilter_ipv4/ip_conntrack.h>
36 #include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
37 #include <linux/netfilter_ipv4/ip_conntrack_core.h>
38 #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
39 #include <linux/netfilter_ipv4/listhelp.h>
44 #define DEBUGP(format, args...)
47 MODULE_LICENSE("GPL");
49 extern atomic_t ip_conntrack_count;
50 DECLARE_PER_CPU(struct ip_conntrack_stat, ip_conntrack_stat);
52 static int kill_proto(struct ip_conntrack *i, void *data)
54 return (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum ==
55 *((u_int8_t *) data));
60 print_tuple(struct seq_file *s, const struct ip_conntrack_tuple *tuple,
61 struct ip_conntrack_protocol *proto)
63 seq_printf(s, "src=%u.%u.%u.%u dst=%u.%u.%u.%u ",
64 NIPQUAD(tuple->src.ip), NIPQUAD(tuple->dst.ip));
65 return proto->print_tuple(s, tuple);
68 #ifdef CONFIG_IP_NF_CT_ACCT
70 seq_print_counters(struct seq_file *s,
71 const struct ip_conntrack_counter *counter)
73 return seq_printf(s, "packets=%llu bytes=%llu ",
74 (unsigned long long)counter->packets,
75 (unsigned long long)counter->bytes);
78 #define seq_print_counters(x, y) 0
81 struct ct_iter_state {
85 static struct list_head *ct_get_first(struct seq_file *seq)
87 struct ct_iter_state *st = seq->private;
90 st->bucket < ip_conntrack_htable_size;
92 if (!list_empty(&ip_conntrack_hash[st->bucket]))
93 return ip_conntrack_hash[st->bucket].next;
98 static struct list_head *ct_get_next(struct seq_file *seq, struct list_head *head)
100 struct ct_iter_state *st = seq->private;
103 while (head == &ip_conntrack_hash[st->bucket]) {
104 if (++st->bucket >= ip_conntrack_htable_size)
106 head = ip_conntrack_hash[st->bucket].next;
111 static struct list_head *ct_get_idx(struct seq_file *seq, loff_t pos)
113 struct list_head *head = ct_get_first(seq);
116 while (pos && (head = ct_get_next(seq, head)))
118 return pos ? NULL : head;
121 static void *ct_seq_start(struct seq_file *seq, loff_t *pos)
123 read_lock_bh(&ip_conntrack_lock);
124 return ct_get_idx(seq, *pos);
127 static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos)
130 return ct_get_next(s, v);
133 static void ct_seq_stop(struct seq_file *s, void *v)
135 read_unlock_bh(&ip_conntrack_lock);
138 static int ct_seq_show(struct seq_file *s, void *v)
140 const struct ip_conntrack_tuple_hash *hash = v;
141 const struct ip_conntrack *conntrack = tuplehash_to_ctrack(hash);
142 struct ip_conntrack_protocol *proto;
144 ASSERT_READ_LOCK(&ip_conntrack_lock);
145 IP_NF_ASSERT(conntrack);
147 /* we only want to print DIR_ORIGINAL */
151 proto = __ip_conntrack_proto_find(conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum);
154 if (seq_printf(s, "%-8s %u %ld ",
156 conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum,
157 timer_pending(&conntrack->timeout)
158 ? (long)(conntrack->timeout.expires - jiffies)/HZ
162 if (proto->print_conntrack(s, conntrack))
165 if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
169 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_ORIGINAL]))
172 if (!(test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)))
173 if (seq_printf(s, "[UNREPLIED] "))
176 if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_REPLY].tuple,
180 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_REPLY]))
183 if (test_bit(IPS_ASSURED_BIT, &conntrack->status))
184 if (seq_printf(s, "[ASSURED] "))
187 #if defined(CONFIG_IP_NF_CONNTRACK_MARK)
188 if (seq_printf(s, "mark=%u ", conntrack->mark))
192 #ifdef CONFIG_IP_NF_CONNTRACK_SECMARK
193 if (seq_printf(s, "secmark=%u ", conntrack->secmark))
197 if (seq_printf(s, "use=%u\n", atomic_read(&conntrack->ct_general.use)))
203 static struct seq_operations ct_seq_ops = {
204 .start = ct_seq_start,
210 static int ct_open(struct inode *inode, struct file *file)
212 struct seq_file *seq;
213 struct ct_iter_state *st;
216 st = kmalloc(sizeof(struct ct_iter_state), GFP_KERNEL);
219 ret = seq_open(file, &ct_seq_ops);
222 seq = file->private_data;
224 memset(st, 0, sizeof(struct ct_iter_state));
231 static struct file_operations ct_file_ops = {
232 .owner = THIS_MODULE,
236 .release = seq_release_private,
240 static void *exp_seq_start(struct seq_file *s, loff_t *pos)
242 struct list_head *e = &ip_conntrack_expect_list;
245 /* strange seq_file api calls stop even if we fail,
246 * thus we need to grab lock since stop unlocks */
247 read_lock_bh(&ip_conntrack_lock);
252 for (i = 0; i <= *pos; i++) {
254 if (e == &ip_conntrack_expect_list)
260 static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos)
262 struct list_head *e = v;
267 if (e == &ip_conntrack_expect_list)
273 static void exp_seq_stop(struct seq_file *s, void *v)
275 read_unlock_bh(&ip_conntrack_lock);
278 static int exp_seq_show(struct seq_file *s, void *v)
280 struct ip_conntrack_expect *expect = v;
282 if (expect->timeout.function)
283 seq_printf(s, "%ld ", timer_pending(&expect->timeout)
284 ? (long)(expect->timeout.expires - jiffies)/HZ : 0);
288 seq_printf(s, "proto=%u ", expect->tuple.dst.protonum);
290 print_tuple(s, &expect->tuple,
291 __ip_conntrack_proto_find(expect->tuple.dst.protonum));
292 return seq_putc(s, '\n');
295 static struct seq_operations exp_seq_ops = {
296 .start = exp_seq_start,
297 .next = exp_seq_next,
298 .stop = exp_seq_stop,
302 static int exp_open(struct inode *inode, struct file *file)
304 return seq_open(file, &exp_seq_ops);
307 static struct file_operations exp_file_ops = {
308 .owner = THIS_MODULE,
312 .release = seq_release
315 static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
320 return SEQ_START_TOKEN;
322 for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) {
323 if (!cpu_possible(cpu))
326 return &per_cpu(ip_conntrack_stat, cpu);
332 static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
336 for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
337 if (!cpu_possible(cpu))
340 return &per_cpu(ip_conntrack_stat, cpu);
346 static void ct_cpu_seq_stop(struct seq_file *seq, void *v)
350 static int ct_cpu_seq_show(struct seq_file *seq, void *v)
352 unsigned int nr_conntracks = atomic_read(&ip_conntrack_count);
353 struct ip_conntrack_stat *st = v;
355 if (v == SEQ_START_TOKEN) {
356 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");
360 seq_printf(seq, "%08x %08x %08x %08x %08x %08x %08x %08x "
361 "%08x %08x %08x %08x %08x %08x %08x %08x \n",
383 static struct seq_operations ct_cpu_seq_ops = {
384 .start = ct_cpu_seq_start,
385 .next = ct_cpu_seq_next,
386 .stop = ct_cpu_seq_stop,
387 .show = ct_cpu_seq_show,
390 static int ct_cpu_seq_open(struct inode *inode, struct file *file)
392 return seq_open(file, &ct_cpu_seq_ops);
395 static struct file_operations ct_cpu_seq_fops = {
396 .owner = THIS_MODULE,
397 .open = ct_cpu_seq_open,
400 .release = seq_release_private,
404 static unsigned int ip_confirm(unsigned int hooknum,
405 struct sk_buff **pskb,
406 const struct net_device *in,
407 const struct net_device *out,
408 int (*okfn)(struct sk_buff *))
410 /* We've seen it coming out the other side: confirm it */
411 return ip_conntrack_confirm(pskb);
414 static unsigned int ip_conntrack_help(unsigned int hooknum,
415 struct sk_buff **pskb,
416 const struct net_device *in,
417 const struct net_device *out,
418 int (*okfn)(struct sk_buff *))
420 struct ip_conntrack *ct;
421 enum ip_conntrack_info ctinfo;
423 /* This is where we call the helper: as the packet goes out. */
424 ct = ip_conntrack_get(*pskb, &ctinfo);
425 if (ct && ct->helper && ctinfo != IP_CT_RELATED + IP_CT_IS_REPLY) {
427 ret = ct->helper->help(pskb, ct, ctinfo);
428 if (ret != NF_ACCEPT)
434 static unsigned int ip_conntrack_defrag(unsigned int hooknum,
435 struct sk_buff **pskb,
436 const struct net_device *in,
437 const struct net_device *out,
438 int (*okfn)(struct sk_buff *))
440 #if !defined(CONFIG_IP_NF_NAT) && !defined(CONFIG_IP_NF_NAT_MODULE)
441 /* Previously seen (loopback)? Ignore. Do this before
447 /* Gather fragments. */
448 if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
449 *pskb = ip_ct_gather_frags(*pskb,
450 hooknum == NF_IP_PRE_ROUTING ?
451 IP_DEFRAG_CONNTRACK_IN :
452 IP_DEFRAG_CONNTRACK_OUT);
459 static unsigned int ip_conntrack_local(unsigned int hooknum,
460 struct sk_buff **pskb,
461 const struct net_device *in,
462 const struct net_device *out,
463 int (*okfn)(struct sk_buff *))
465 /* root is playing with raw sockets. */
466 if ((*pskb)->len < sizeof(struct iphdr)
467 || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) {
469 printk("ipt_hook: happy cracking.\n");
472 return ip_conntrack_in(hooknum, pskb, in, out, okfn);
475 /* Connection tracking may drop packets, but never alters them, so
476 make it the first hook. */
477 static struct nf_hook_ops ip_conntrack_ops[] = {
479 .hook = ip_conntrack_defrag,
480 .owner = THIS_MODULE,
482 .hooknum = NF_IP_PRE_ROUTING,
483 .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
486 .hook = ip_conntrack_in,
487 .owner = THIS_MODULE,
489 .hooknum = NF_IP_PRE_ROUTING,
490 .priority = NF_IP_PRI_CONNTRACK,
493 .hook = ip_conntrack_defrag,
494 .owner = THIS_MODULE,
496 .hooknum = NF_IP_LOCAL_OUT,
497 .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
500 .hook = ip_conntrack_local,
501 .owner = THIS_MODULE,
503 .hooknum = NF_IP_LOCAL_OUT,
504 .priority = NF_IP_PRI_CONNTRACK,
507 .hook = ip_conntrack_help,
508 .owner = THIS_MODULE,
510 .hooknum = NF_IP_POST_ROUTING,
511 .priority = NF_IP_PRI_CONNTRACK_HELPER,
514 .hook = ip_conntrack_help,
515 .owner = THIS_MODULE,
517 .hooknum = NF_IP_LOCAL_IN,
518 .priority = NF_IP_PRI_CONNTRACK_HELPER,
522 .owner = THIS_MODULE,
524 .hooknum = NF_IP_POST_ROUTING,
525 .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
529 .owner = THIS_MODULE,
531 .hooknum = NF_IP_LOCAL_IN,
532 .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
540 /* From ip_conntrack_core.c */
541 extern int ip_conntrack_max;
542 extern unsigned int ip_conntrack_htable_size;
544 /* From ip_conntrack_proto_tcp.c */
545 extern unsigned int ip_ct_tcp_timeout_syn_sent;
546 extern unsigned int ip_ct_tcp_timeout_syn_recv;
547 extern unsigned int ip_ct_tcp_timeout_established;
548 extern unsigned int ip_ct_tcp_timeout_fin_wait;
549 extern unsigned int ip_ct_tcp_timeout_close_wait;
550 extern unsigned int ip_ct_tcp_timeout_last_ack;
551 extern unsigned int ip_ct_tcp_timeout_time_wait;
552 extern unsigned int ip_ct_tcp_timeout_close;
553 extern unsigned int ip_ct_tcp_timeout_max_retrans;
554 extern int ip_ct_tcp_loose;
555 extern int ip_ct_tcp_be_liberal;
556 extern int ip_ct_tcp_max_retrans;
558 /* From ip_conntrack_proto_udp.c */
559 extern unsigned int ip_ct_udp_timeout;
560 extern unsigned int ip_ct_udp_timeout_stream;
562 /* From ip_conntrack_proto_icmp.c */
563 extern unsigned int ip_ct_icmp_timeout;
565 /* From ip_conntrack_proto_icmp.c */
566 extern unsigned int ip_ct_generic_timeout;
568 /* Log invalid packets of a given protocol */
569 static int log_invalid_proto_min = 0;
570 static int log_invalid_proto_max = 255;
572 int ip_conntrack_checksum = 1;
574 static struct ctl_table_header *ip_ct_sysctl_header;
576 static ctl_table ip_ct_sysctl_table[] = {
578 .ctl_name = NET_IPV4_NF_CONNTRACK_MAX,
579 .procname = "ip_conntrack_max",
580 .data = &ip_conntrack_max,
581 .maxlen = sizeof(int),
583 .proc_handler = &proc_dointvec,
586 .ctl_name = NET_IPV4_NF_CONNTRACK_COUNT,
587 .procname = "ip_conntrack_count",
588 .data = &ip_conntrack_count,
589 .maxlen = sizeof(int),
591 .proc_handler = &proc_dointvec,
594 .ctl_name = NET_IPV4_NF_CONNTRACK_BUCKETS,
595 .procname = "ip_conntrack_buckets",
596 .data = &ip_conntrack_htable_size,
597 .maxlen = sizeof(unsigned int),
599 .proc_handler = &proc_dointvec,
602 .ctl_name = NET_IPV4_NF_CONNTRACK_CHECKSUM,
603 .procname = "ip_conntrack_checksum",
604 .data = &ip_conntrack_checksum,
605 .maxlen = sizeof(int),
607 .proc_handler = &proc_dointvec,
610 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT,
611 .procname = "ip_conntrack_tcp_timeout_syn_sent",
612 .data = &ip_ct_tcp_timeout_syn_sent,
613 .maxlen = sizeof(unsigned int),
615 .proc_handler = &proc_dointvec_jiffies,
618 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV,
619 .procname = "ip_conntrack_tcp_timeout_syn_recv",
620 .data = &ip_ct_tcp_timeout_syn_recv,
621 .maxlen = sizeof(unsigned int),
623 .proc_handler = &proc_dointvec_jiffies,
626 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED,
627 .procname = "ip_conntrack_tcp_timeout_established",
628 .data = &ip_ct_tcp_timeout_established,
629 .maxlen = sizeof(unsigned int),
631 .proc_handler = &proc_dointvec_jiffies,
634 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT,
635 .procname = "ip_conntrack_tcp_timeout_fin_wait",
636 .data = &ip_ct_tcp_timeout_fin_wait,
637 .maxlen = sizeof(unsigned int),
639 .proc_handler = &proc_dointvec_jiffies,
642 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT,
643 .procname = "ip_conntrack_tcp_timeout_close_wait",
644 .data = &ip_ct_tcp_timeout_close_wait,
645 .maxlen = sizeof(unsigned int),
647 .proc_handler = &proc_dointvec_jiffies,
650 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK,
651 .procname = "ip_conntrack_tcp_timeout_last_ack",
652 .data = &ip_ct_tcp_timeout_last_ack,
653 .maxlen = sizeof(unsigned int),
655 .proc_handler = &proc_dointvec_jiffies,
658 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT,
659 .procname = "ip_conntrack_tcp_timeout_time_wait",
660 .data = &ip_ct_tcp_timeout_time_wait,
661 .maxlen = sizeof(unsigned int),
663 .proc_handler = &proc_dointvec_jiffies,
666 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE,
667 .procname = "ip_conntrack_tcp_timeout_close",
668 .data = &ip_ct_tcp_timeout_close,
669 .maxlen = sizeof(unsigned int),
671 .proc_handler = &proc_dointvec_jiffies,
674 .ctl_name = NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT,
675 .procname = "ip_conntrack_udp_timeout",
676 .data = &ip_ct_udp_timeout,
677 .maxlen = sizeof(unsigned int),
679 .proc_handler = &proc_dointvec_jiffies,
682 .ctl_name = NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT_STREAM,
683 .procname = "ip_conntrack_udp_timeout_stream",
684 .data = &ip_ct_udp_timeout_stream,
685 .maxlen = sizeof(unsigned int),
687 .proc_handler = &proc_dointvec_jiffies,
690 .ctl_name = NET_IPV4_NF_CONNTRACK_ICMP_TIMEOUT,
691 .procname = "ip_conntrack_icmp_timeout",
692 .data = &ip_ct_icmp_timeout,
693 .maxlen = sizeof(unsigned int),
695 .proc_handler = &proc_dointvec_jiffies,
698 .ctl_name = NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT,
699 .procname = "ip_conntrack_generic_timeout",
700 .data = &ip_ct_generic_timeout,
701 .maxlen = sizeof(unsigned int),
703 .proc_handler = &proc_dointvec_jiffies,
706 .ctl_name = NET_IPV4_NF_CONNTRACK_LOG_INVALID,
707 .procname = "ip_conntrack_log_invalid",
708 .data = &ip_ct_log_invalid,
709 .maxlen = sizeof(unsigned int),
711 .proc_handler = &proc_dointvec_minmax,
712 .strategy = &sysctl_intvec,
713 .extra1 = &log_invalid_proto_min,
714 .extra2 = &log_invalid_proto_max,
717 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS,
718 .procname = "ip_conntrack_tcp_timeout_max_retrans",
719 .data = &ip_ct_tcp_timeout_max_retrans,
720 .maxlen = sizeof(unsigned int),
722 .proc_handler = &proc_dointvec_jiffies,
725 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_LOOSE,
726 .procname = "ip_conntrack_tcp_loose",
727 .data = &ip_ct_tcp_loose,
728 .maxlen = sizeof(unsigned int),
730 .proc_handler = &proc_dointvec,
733 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_BE_LIBERAL,
734 .procname = "ip_conntrack_tcp_be_liberal",
735 .data = &ip_ct_tcp_be_liberal,
736 .maxlen = sizeof(unsigned int),
738 .proc_handler = &proc_dointvec,
741 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_MAX_RETRANS,
742 .procname = "ip_conntrack_tcp_max_retrans",
743 .data = &ip_ct_tcp_max_retrans,
744 .maxlen = sizeof(unsigned int),
746 .proc_handler = &proc_dointvec,
751 #define NET_IP_CONNTRACK_MAX 2089
753 static ctl_table ip_ct_netfilter_table[] = {
755 .ctl_name = NET_IPV4_NETFILTER,
756 .procname = "netfilter",
758 .child = ip_ct_sysctl_table,
761 .ctl_name = NET_IP_CONNTRACK_MAX,
762 .procname = "ip_conntrack_max",
763 .data = &ip_conntrack_max,
764 .maxlen = sizeof(int),
766 .proc_handler = &proc_dointvec
771 static ctl_table ip_ct_ipv4_table[] = {
773 .ctl_name = NET_IPV4,
776 .child = ip_ct_netfilter_table,
781 static ctl_table ip_ct_net_table[] = {
786 .child = ip_ct_ipv4_table,
791 EXPORT_SYMBOL(ip_ct_log_invalid);
792 #endif /* CONFIG_SYSCTL */
794 /* FIXME: Allow NULL functions and sub in pointers to generic for
796 int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto)
800 write_lock_bh(&ip_conntrack_lock);
801 if (ip_ct_protos[proto->proto] != &ip_conntrack_generic_protocol) {
805 ip_ct_protos[proto->proto] = proto;
807 write_unlock_bh(&ip_conntrack_lock);
811 void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto)
813 write_lock_bh(&ip_conntrack_lock);
814 ip_ct_protos[proto->proto] = &ip_conntrack_generic_protocol;
815 write_unlock_bh(&ip_conntrack_lock);
817 /* Somebody could be still looking at the proto in bh. */
820 /* Remove all contrack entries for this protocol */
821 ip_ct_iterate_cleanup(kill_proto, &proto->proto);
824 static int __init ip_conntrack_standalone_init(void)
826 #ifdef CONFIG_PROC_FS
827 struct proc_dir_entry *proc, *proc_exp, *proc_stat;
831 ret = ip_conntrack_init();
835 #ifdef CONFIG_PROC_FS
837 proc = proc_net_fops_create("ip_conntrack", 0440, &ct_file_ops);
838 if (!proc) goto cleanup_init;
840 proc_exp = proc_net_fops_create("ip_conntrack_expect", 0440,
842 if (!proc_exp) goto cleanup_proc;
844 proc_stat = create_proc_entry("ip_conntrack", S_IRUGO, proc_net_stat);
846 goto cleanup_proc_exp;
848 proc_stat->proc_fops = &ct_cpu_seq_fops;
849 proc_stat->owner = THIS_MODULE;
852 ret = nf_register_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
854 printk("ip_conntrack: can't register hooks.\n");
855 goto cleanup_proc_stat;
858 ip_ct_sysctl_header = register_sysctl_table(ip_ct_net_table, 0);
859 if (ip_ct_sysctl_header == NULL) {
860 printk("ip_conntrack: can't register to sysctl.\n");
869 nf_unregister_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
872 #ifdef CONFIG_PROC_FS
873 remove_proc_entry("ip_conntrack", proc_net_stat);
875 proc_net_remove("ip_conntrack_expect");
877 proc_net_remove("ip_conntrack");
879 #endif /* CONFIG_PROC_FS */
880 ip_conntrack_cleanup();
884 static void __exit ip_conntrack_standalone_fini(void)
888 unregister_sysctl_table(ip_ct_sysctl_header);
890 nf_unregister_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
891 #ifdef CONFIG_PROC_FS
892 remove_proc_entry("ip_conntrack", proc_net_stat);
893 proc_net_remove("ip_conntrack_expect");
894 proc_net_remove("ip_conntrack");
895 #endif /* CONFIG_PROC_FS */
896 ip_conntrack_cleanup();
899 module_init(ip_conntrack_standalone_init);
900 module_exit(ip_conntrack_standalone_fini);
902 /* Some modules need us, but don't depend directly on any symbol.
903 They should call this. */
904 void need_conntrack(void)
908 #ifdef CONFIG_IP_NF_CONNTRACK_EVENTS
909 EXPORT_SYMBOL_GPL(ip_conntrack_chain);
910 EXPORT_SYMBOL_GPL(ip_conntrack_expect_chain);
911 EXPORT_SYMBOL_GPL(ip_conntrack_register_notifier);
912 EXPORT_SYMBOL_GPL(ip_conntrack_unregister_notifier);
913 EXPORT_SYMBOL_GPL(__ip_ct_event_cache_init);
914 EXPORT_PER_CPU_SYMBOL_GPL(ip_conntrack_ecache);
916 EXPORT_SYMBOL(ip_conntrack_protocol_register);
917 EXPORT_SYMBOL(ip_conntrack_protocol_unregister);
918 EXPORT_SYMBOL(ip_ct_get_tuple);
919 EXPORT_SYMBOL(invert_tuplepr);
920 EXPORT_SYMBOL(ip_conntrack_alter_reply);
921 EXPORT_SYMBOL(ip_conntrack_destroyed);
922 EXPORT_SYMBOL(need_conntrack);
923 EXPORT_SYMBOL(ip_conntrack_helper_register);
924 EXPORT_SYMBOL(ip_conntrack_helper_unregister);
925 EXPORT_SYMBOL(ip_ct_iterate_cleanup);
926 EXPORT_SYMBOL(__ip_ct_refresh_acct);
928 EXPORT_SYMBOL(ip_conntrack_expect_alloc);
929 EXPORT_SYMBOL(ip_conntrack_expect_put);
930 EXPORT_SYMBOL_GPL(__ip_conntrack_expect_find);
931 EXPORT_SYMBOL_GPL(ip_conntrack_expect_find);
932 EXPORT_SYMBOL(ip_conntrack_expect_related);
933 EXPORT_SYMBOL(ip_conntrack_unexpect_related);
934 EXPORT_SYMBOL_GPL(ip_conntrack_expect_list);
935 EXPORT_SYMBOL_GPL(ip_ct_unlink_expect);
937 EXPORT_SYMBOL(ip_conntrack_tuple_taken);
938 EXPORT_SYMBOL(ip_ct_gather_frags);
939 EXPORT_SYMBOL(ip_conntrack_htable_size);
940 EXPORT_SYMBOL(ip_conntrack_lock);
941 EXPORT_SYMBOL(ip_conntrack_hash);
942 EXPORT_SYMBOL(ip_conntrack_untracked);
943 EXPORT_SYMBOL_GPL(ip_conntrack_find_get);
944 #ifdef CONFIG_IP_NF_NAT_NEEDED
945 EXPORT_SYMBOL(ip_conntrack_tcp_update);
948 EXPORT_SYMBOL_GPL(ip_conntrack_flush);
949 EXPORT_SYMBOL_GPL(__ip_conntrack_find);
951 EXPORT_SYMBOL_GPL(ip_conntrack_alloc);
952 EXPORT_SYMBOL_GPL(ip_conntrack_free);
953 EXPORT_SYMBOL_GPL(ip_conntrack_hash_insert);
955 EXPORT_SYMBOL_GPL(ip_ct_remove_expectations);
957 EXPORT_SYMBOL_GPL(ip_conntrack_helper_find_get);
958 EXPORT_SYMBOL_GPL(ip_conntrack_helper_put);
959 EXPORT_SYMBOL_GPL(__ip_conntrack_helper_find_byname);
961 EXPORT_SYMBOL_GPL(ip_conntrack_proto_find_get);
962 EXPORT_SYMBOL_GPL(ip_conntrack_proto_put);
963 EXPORT_SYMBOL_GPL(__ip_conntrack_proto_find);
964 EXPORT_SYMBOL_GPL(ip_conntrack_checksum);
965 #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
966 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
967 EXPORT_SYMBOL_GPL(ip_ct_port_tuple_to_nfattr);
968 EXPORT_SYMBOL_GPL(ip_ct_port_nfattr_to_tuple);