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 #define ASSERT_READ_LOCK(x)
32 #define ASSERT_WRITE_LOCK(x)
34 #include <linux/netfilter_ipv4/ip_conntrack.h>
35 #include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
36 #include <linux/netfilter_ipv4/ip_conntrack_core.h>
37 #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
42 #define DEBUGP(format, args...)
45 MODULE_LICENSE("GPL");
47 extern atomic_t ip_conntrack_count;
48 DECLARE_PER_CPU(struct ip_conntrack_stat, ip_conntrack_stat);
50 static int kill_proto(struct ip_conntrack *i, void *data)
52 return (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum ==
53 *((u_int8_t *) data));
58 print_tuple(struct seq_file *s, const struct ip_conntrack_tuple *tuple,
59 struct ip_conntrack_protocol *proto)
61 seq_printf(s, "src=%u.%u.%u.%u dst=%u.%u.%u.%u ",
62 NIPQUAD(tuple->src.ip), NIPQUAD(tuple->dst.ip));
63 return proto->print_tuple(s, tuple);
66 #ifdef CONFIG_IP_NF_CT_ACCT
68 seq_print_counters(struct seq_file *s,
69 const struct ip_conntrack_counter *counter)
71 return seq_printf(s, "packets=%llu bytes=%llu ",
72 (unsigned long long)counter->packets,
73 (unsigned long long)counter->bytes);
76 #define seq_print_counters(x, y) 0
79 struct ct_iter_state {
83 static struct list_head *ct_get_first(struct seq_file *seq)
85 struct ct_iter_state *st = seq->private;
88 st->bucket < ip_conntrack_htable_size;
90 if (!list_empty(&ip_conntrack_hash[st->bucket]))
91 return ip_conntrack_hash[st->bucket].next;
96 static struct list_head *ct_get_next(struct seq_file *seq, struct list_head *head)
98 struct ct_iter_state *st = seq->private;
101 while (head == &ip_conntrack_hash[st->bucket]) {
102 if (++st->bucket >= ip_conntrack_htable_size)
104 head = ip_conntrack_hash[st->bucket].next;
109 static struct list_head *ct_get_idx(struct seq_file *seq, loff_t pos)
111 struct list_head *head = ct_get_first(seq);
114 while (pos && (head = ct_get_next(seq, head)))
116 return pos ? NULL : head;
119 static void *ct_seq_start(struct seq_file *seq, loff_t *pos)
121 read_lock_bh(&ip_conntrack_lock);
122 return ct_get_idx(seq, *pos);
125 static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos)
128 return ct_get_next(s, v);
131 static void ct_seq_stop(struct seq_file *s, void *v)
133 read_unlock_bh(&ip_conntrack_lock);
136 static int ct_seq_show(struct seq_file *s, void *v)
138 const struct ip_conntrack_tuple_hash *hash = v;
139 const struct ip_conntrack *conntrack = tuplehash_to_ctrack(hash);
140 struct ip_conntrack_protocol *proto;
142 ASSERT_READ_LOCK(&ip_conntrack_lock);
143 IP_NF_ASSERT(conntrack);
145 /* we only want to print DIR_ORIGINAL */
149 proto = __ip_conntrack_proto_find(conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum);
152 if (seq_printf(s, "%-8s %u %ld ",
154 conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum,
155 timer_pending(&conntrack->timeout)
156 ? (long)(conntrack->timeout.expires - jiffies)/HZ
160 if (proto->print_conntrack(s, conntrack))
163 if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
167 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_ORIGINAL]))
170 if (!(test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)))
171 if (seq_printf(s, "[UNREPLIED] "))
174 if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_REPLY].tuple,
178 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_REPLY]))
181 if (test_bit(IPS_ASSURED_BIT, &conntrack->status))
182 if (seq_printf(s, "[ASSURED] "))
185 #if defined(CONFIG_IP_NF_CONNTRACK_MARK)
186 if (seq_printf(s, "mark=%u ", conntrack->mark))
190 #ifdef CONFIG_IP_NF_CONNTRACK_SECMARK
191 if (seq_printf(s, "secmark=%u ", conntrack->secmark))
195 if (seq_printf(s, "use=%u\n", atomic_read(&conntrack->ct_general.use)))
201 static struct seq_operations ct_seq_ops = {
202 .start = ct_seq_start,
208 static int ct_open(struct inode *inode, struct file *file)
210 struct seq_file *seq;
211 struct ct_iter_state *st;
214 st = kmalloc(sizeof(struct ct_iter_state), GFP_KERNEL);
217 ret = seq_open(file, &ct_seq_ops);
220 seq = file->private_data;
222 memset(st, 0, sizeof(struct ct_iter_state));
229 static struct file_operations ct_file_ops = {
230 .owner = THIS_MODULE,
234 .release = seq_release_private,
238 static void *exp_seq_start(struct seq_file *s, loff_t *pos)
240 struct list_head *e = &ip_conntrack_expect_list;
243 /* strange seq_file api calls stop even if we fail,
244 * thus we need to grab lock since stop unlocks */
245 read_lock_bh(&ip_conntrack_lock);
250 for (i = 0; i <= *pos; i++) {
252 if (e == &ip_conntrack_expect_list)
258 static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos)
260 struct list_head *e = v;
265 if (e == &ip_conntrack_expect_list)
271 static void exp_seq_stop(struct seq_file *s, void *v)
273 read_unlock_bh(&ip_conntrack_lock);
276 static int exp_seq_show(struct seq_file *s, void *v)
278 struct ip_conntrack_expect *expect = v;
280 if (expect->timeout.function)
281 seq_printf(s, "%ld ", timer_pending(&expect->timeout)
282 ? (long)(expect->timeout.expires - jiffies)/HZ : 0);
286 seq_printf(s, "proto=%u ", expect->tuple.dst.protonum);
288 print_tuple(s, &expect->tuple,
289 __ip_conntrack_proto_find(expect->tuple.dst.protonum));
290 return seq_putc(s, '\n');
293 static struct seq_operations exp_seq_ops = {
294 .start = exp_seq_start,
295 .next = exp_seq_next,
296 .stop = exp_seq_stop,
300 static int exp_open(struct inode *inode, struct file *file)
302 return seq_open(file, &exp_seq_ops);
305 static struct file_operations exp_file_ops = {
306 .owner = THIS_MODULE,
310 .release = seq_release
313 static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
318 return SEQ_START_TOKEN;
320 for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) {
321 if (!cpu_possible(cpu))
324 return &per_cpu(ip_conntrack_stat, cpu);
330 static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
334 for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
335 if (!cpu_possible(cpu))
338 return &per_cpu(ip_conntrack_stat, cpu);
344 static void ct_cpu_seq_stop(struct seq_file *seq, void *v)
348 static int ct_cpu_seq_show(struct seq_file *seq, void *v)
350 unsigned int nr_conntracks = atomic_read(&ip_conntrack_count);
351 struct ip_conntrack_stat *st = v;
353 if (v == SEQ_START_TOKEN) {
354 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");
358 seq_printf(seq, "%08x %08x %08x %08x %08x %08x %08x %08x "
359 "%08x %08x %08x %08x %08x %08x %08x %08x \n",
381 static struct seq_operations ct_cpu_seq_ops = {
382 .start = ct_cpu_seq_start,
383 .next = ct_cpu_seq_next,
384 .stop = ct_cpu_seq_stop,
385 .show = ct_cpu_seq_show,
388 static int ct_cpu_seq_open(struct inode *inode, struct file *file)
390 return seq_open(file, &ct_cpu_seq_ops);
393 static struct file_operations ct_cpu_seq_fops = {
394 .owner = THIS_MODULE,
395 .open = ct_cpu_seq_open,
398 .release = seq_release_private,
402 static unsigned int ip_confirm(unsigned int hooknum,
403 struct sk_buff **pskb,
404 const struct net_device *in,
405 const struct net_device *out,
406 int (*okfn)(struct sk_buff *))
408 /* We've seen it coming out the other side: confirm it */
409 return ip_conntrack_confirm(pskb);
412 static unsigned int ip_conntrack_help(unsigned int hooknum,
413 struct sk_buff **pskb,
414 const struct net_device *in,
415 const struct net_device *out,
416 int (*okfn)(struct sk_buff *))
418 struct ip_conntrack *ct;
419 enum ip_conntrack_info ctinfo;
421 /* This is where we call the helper: as the packet goes out. */
422 ct = ip_conntrack_get(*pskb, &ctinfo);
423 if (ct && ct->helper && ctinfo != IP_CT_RELATED + IP_CT_IS_REPLY) {
425 ret = ct->helper->help(pskb, ct, ctinfo);
426 if (ret != NF_ACCEPT)
432 static unsigned int ip_conntrack_defrag(unsigned int hooknum,
433 struct sk_buff **pskb,
434 const struct net_device *in,
435 const struct net_device *out,
436 int (*okfn)(struct sk_buff *))
438 #if !defined(CONFIG_IP_NF_NAT) && !defined(CONFIG_IP_NF_NAT_MODULE)
439 /* Previously seen (loopback)? Ignore. Do this before
445 /* Gather fragments. */
446 if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
447 *pskb = ip_ct_gather_frags(*pskb,
448 hooknum == NF_IP_PRE_ROUTING ?
449 IP_DEFRAG_CONNTRACK_IN :
450 IP_DEFRAG_CONNTRACK_OUT);
457 static unsigned int ip_conntrack_local(unsigned int hooknum,
458 struct sk_buff **pskb,
459 const struct net_device *in,
460 const struct net_device *out,
461 int (*okfn)(struct sk_buff *))
463 /* root is playing with raw sockets. */
464 if ((*pskb)->len < sizeof(struct iphdr)
465 || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) {
467 printk("ipt_hook: happy cracking.\n");
470 return ip_conntrack_in(hooknum, pskb, in, out, okfn);
473 /* Connection tracking may drop packets, but never alters them, so
474 make it the first hook. */
475 static struct nf_hook_ops ip_conntrack_ops[] = {
477 .hook = ip_conntrack_defrag,
478 .owner = THIS_MODULE,
480 .hooknum = NF_IP_PRE_ROUTING,
481 .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
484 .hook = ip_conntrack_in,
485 .owner = THIS_MODULE,
487 .hooknum = NF_IP_PRE_ROUTING,
488 .priority = NF_IP_PRI_CONNTRACK,
491 .hook = ip_conntrack_defrag,
492 .owner = THIS_MODULE,
494 .hooknum = NF_IP_LOCAL_OUT,
495 .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
498 .hook = ip_conntrack_local,
499 .owner = THIS_MODULE,
501 .hooknum = NF_IP_LOCAL_OUT,
502 .priority = NF_IP_PRI_CONNTRACK,
505 .hook = ip_conntrack_help,
506 .owner = THIS_MODULE,
508 .hooknum = NF_IP_POST_ROUTING,
509 .priority = NF_IP_PRI_CONNTRACK_HELPER,
512 .hook = ip_conntrack_help,
513 .owner = THIS_MODULE,
515 .hooknum = NF_IP_LOCAL_IN,
516 .priority = NF_IP_PRI_CONNTRACK_HELPER,
520 .owner = THIS_MODULE,
522 .hooknum = NF_IP_POST_ROUTING,
523 .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
527 .owner = THIS_MODULE,
529 .hooknum = NF_IP_LOCAL_IN,
530 .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
536 int ip_conntrack_checksum __read_mostly = 1;
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_generic.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 static struct ctl_table_header *ip_ct_sysctl_header;
574 static ctl_table ip_ct_sysctl_table[] = {
576 .ctl_name = NET_IPV4_NF_CONNTRACK_MAX,
577 .procname = "ip_conntrack_max",
578 .data = &ip_conntrack_max,
579 .maxlen = sizeof(int),
581 .proc_handler = &proc_dointvec,
584 .ctl_name = NET_IPV4_NF_CONNTRACK_COUNT,
585 .procname = "ip_conntrack_count",
586 .data = &ip_conntrack_count,
587 .maxlen = sizeof(int),
589 .proc_handler = &proc_dointvec,
592 .ctl_name = NET_IPV4_NF_CONNTRACK_BUCKETS,
593 .procname = "ip_conntrack_buckets",
594 .data = &ip_conntrack_htable_size,
595 .maxlen = sizeof(unsigned int),
597 .proc_handler = &proc_dointvec,
600 .ctl_name = NET_IPV4_NF_CONNTRACK_CHECKSUM,
601 .procname = "ip_conntrack_checksum",
602 .data = &ip_conntrack_checksum,
603 .maxlen = sizeof(int),
605 .proc_handler = &proc_dointvec,
608 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT,
609 .procname = "ip_conntrack_tcp_timeout_syn_sent",
610 .data = &ip_ct_tcp_timeout_syn_sent,
611 .maxlen = sizeof(unsigned int),
613 .proc_handler = &proc_dointvec_jiffies,
616 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV,
617 .procname = "ip_conntrack_tcp_timeout_syn_recv",
618 .data = &ip_ct_tcp_timeout_syn_recv,
619 .maxlen = sizeof(unsigned int),
621 .proc_handler = &proc_dointvec_jiffies,
624 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED,
625 .procname = "ip_conntrack_tcp_timeout_established",
626 .data = &ip_ct_tcp_timeout_established,
627 .maxlen = sizeof(unsigned int),
629 .proc_handler = &proc_dointvec_jiffies,
632 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT,
633 .procname = "ip_conntrack_tcp_timeout_fin_wait",
634 .data = &ip_ct_tcp_timeout_fin_wait,
635 .maxlen = sizeof(unsigned int),
637 .proc_handler = &proc_dointvec_jiffies,
640 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT,
641 .procname = "ip_conntrack_tcp_timeout_close_wait",
642 .data = &ip_ct_tcp_timeout_close_wait,
643 .maxlen = sizeof(unsigned int),
645 .proc_handler = &proc_dointvec_jiffies,
648 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK,
649 .procname = "ip_conntrack_tcp_timeout_last_ack",
650 .data = &ip_ct_tcp_timeout_last_ack,
651 .maxlen = sizeof(unsigned int),
653 .proc_handler = &proc_dointvec_jiffies,
656 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT,
657 .procname = "ip_conntrack_tcp_timeout_time_wait",
658 .data = &ip_ct_tcp_timeout_time_wait,
659 .maxlen = sizeof(unsigned int),
661 .proc_handler = &proc_dointvec_jiffies,
664 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE,
665 .procname = "ip_conntrack_tcp_timeout_close",
666 .data = &ip_ct_tcp_timeout_close,
667 .maxlen = sizeof(unsigned int),
669 .proc_handler = &proc_dointvec_jiffies,
672 .ctl_name = NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT,
673 .procname = "ip_conntrack_udp_timeout",
674 .data = &ip_ct_udp_timeout,
675 .maxlen = sizeof(unsigned int),
677 .proc_handler = &proc_dointvec_jiffies,
680 .ctl_name = NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT_STREAM,
681 .procname = "ip_conntrack_udp_timeout_stream",
682 .data = &ip_ct_udp_timeout_stream,
683 .maxlen = sizeof(unsigned int),
685 .proc_handler = &proc_dointvec_jiffies,
688 .ctl_name = NET_IPV4_NF_CONNTRACK_ICMP_TIMEOUT,
689 .procname = "ip_conntrack_icmp_timeout",
690 .data = &ip_ct_icmp_timeout,
691 .maxlen = sizeof(unsigned int),
693 .proc_handler = &proc_dointvec_jiffies,
696 .ctl_name = NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT,
697 .procname = "ip_conntrack_generic_timeout",
698 .data = &ip_ct_generic_timeout,
699 .maxlen = sizeof(unsigned int),
701 .proc_handler = &proc_dointvec_jiffies,
704 .ctl_name = NET_IPV4_NF_CONNTRACK_LOG_INVALID,
705 .procname = "ip_conntrack_log_invalid",
706 .data = &ip_ct_log_invalid,
707 .maxlen = sizeof(unsigned int),
709 .proc_handler = &proc_dointvec_minmax,
710 .strategy = &sysctl_intvec,
711 .extra1 = &log_invalid_proto_min,
712 .extra2 = &log_invalid_proto_max,
715 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS,
716 .procname = "ip_conntrack_tcp_timeout_max_retrans",
717 .data = &ip_ct_tcp_timeout_max_retrans,
718 .maxlen = sizeof(unsigned int),
720 .proc_handler = &proc_dointvec_jiffies,
723 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_LOOSE,
724 .procname = "ip_conntrack_tcp_loose",
725 .data = &ip_ct_tcp_loose,
726 .maxlen = sizeof(unsigned int),
728 .proc_handler = &proc_dointvec,
731 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_BE_LIBERAL,
732 .procname = "ip_conntrack_tcp_be_liberal",
733 .data = &ip_ct_tcp_be_liberal,
734 .maxlen = sizeof(unsigned int),
736 .proc_handler = &proc_dointvec,
739 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_MAX_RETRANS,
740 .procname = "ip_conntrack_tcp_max_retrans",
741 .data = &ip_ct_tcp_max_retrans,
742 .maxlen = sizeof(unsigned int),
744 .proc_handler = &proc_dointvec,
749 #define NET_IP_CONNTRACK_MAX 2089
751 static ctl_table ip_ct_netfilter_table[] = {
753 .ctl_name = NET_IPV4_NETFILTER,
754 .procname = "netfilter",
756 .child = ip_ct_sysctl_table,
759 .ctl_name = NET_IP_CONNTRACK_MAX,
760 .procname = "ip_conntrack_max",
761 .data = &ip_conntrack_max,
762 .maxlen = sizeof(int),
764 .proc_handler = &proc_dointvec
769 static ctl_table ip_ct_ipv4_table[] = {
771 .ctl_name = NET_IPV4,
774 .child = ip_ct_netfilter_table,
779 static ctl_table ip_ct_net_table[] = {
784 .child = ip_ct_ipv4_table,
789 EXPORT_SYMBOL(ip_ct_log_invalid);
790 #endif /* CONFIG_SYSCTL */
792 /* FIXME: Allow NULL functions and sub in pointers to generic for
794 int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto)
798 write_lock_bh(&ip_conntrack_lock);
799 if (ip_ct_protos[proto->proto] != &ip_conntrack_generic_protocol) {
803 ip_ct_protos[proto->proto] = proto;
805 write_unlock_bh(&ip_conntrack_lock);
809 void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto)
811 write_lock_bh(&ip_conntrack_lock);
812 ip_ct_protos[proto->proto] = &ip_conntrack_generic_protocol;
813 write_unlock_bh(&ip_conntrack_lock);
815 /* Somebody could be still looking at the proto in bh. */
818 /* Remove all contrack entries for this protocol */
819 ip_ct_iterate_cleanup(kill_proto, &proto->proto);
822 static int __init ip_conntrack_standalone_init(void)
824 #ifdef CONFIG_PROC_FS
825 struct proc_dir_entry *proc, *proc_exp, *proc_stat;
829 ret = ip_conntrack_init();
833 #ifdef CONFIG_PROC_FS
835 proc = proc_net_fops_create("ip_conntrack", 0440, &ct_file_ops);
836 if (!proc) goto cleanup_init;
838 proc_exp = proc_net_fops_create("ip_conntrack_expect", 0440,
840 if (!proc_exp) goto cleanup_proc;
842 proc_stat = create_proc_entry("ip_conntrack", S_IRUGO, proc_net_stat);
844 goto cleanup_proc_exp;
846 proc_stat->proc_fops = &ct_cpu_seq_fops;
847 proc_stat->owner = THIS_MODULE;
850 ret = nf_register_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
852 printk("ip_conntrack: can't register hooks.\n");
853 goto cleanup_proc_stat;
856 ip_ct_sysctl_header = register_sysctl_table(ip_ct_net_table, 0);
857 if (ip_ct_sysctl_header == NULL) {
858 printk("ip_conntrack: can't register to sysctl.\n");
867 nf_unregister_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
870 #ifdef CONFIG_PROC_FS
871 remove_proc_entry("ip_conntrack", proc_net_stat);
873 proc_net_remove("ip_conntrack_expect");
875 proc_net_remove("ip_conntrack");
877 #endif /* CONFIG_PROC_FS */
878 ip_conntrack_cleanup();
882 static void __exit ip_conntrack_standalone_fini(void)
886 unregister_sysctl_table(ip_ct_sysctl_header);
888 nf_unregister_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
889 #ifdef CONFIG_PROC_FS
890 remove_proc_entry("ip_conntrack", proc_net_stat);
891 proc_net_remove("ip_conntrack_expect");
892 proc_net_remove("ip_conntrack");
893 #endif /* CONFIG_PROC_FS */
894 ip_conntrack_cleanup();
897 module_init(ip_conntrack_standalone_init);
898 module_exit(ip_conntrack_standalone_fini);
900 /* Some modules need us, but don't depend directly on any symbol.
901 They should call this. */
902 void need_conntrack(void)
906 #ifdef CONFIG_IP_NF_CONNTRACK_EVENTS
907 EXPORT_SYMBOL_GPL(ip_conntrack_chain);
908 EXPORT_SYMBOL_GPL(ip_conntrack_expect_chain);
909 EXPORT_SYMBOL_GPL(ip_conntrack_register_notifier);
910 EXPORT_SYMBOL_GPL(ip_conntrack_unregister_notifier);
911 EXPORT_SYMBOL_GPL(__ip_ct_event_cache_init);
912 EXPORT_PER_CPU_SYMBOL_GPL(ip_conntrack_ecache);
914 EXPORT_SYMBOL(ip_conntrack_protocol_register);
915 EXPORT_SYMBOL(ip_conntrack_protocol_unregister);
916 EXPORT_SYMBOL(ip_ct_get_tuple);
917 EXPORT_SYMBOL(invert_tuplepr);
918 EXPORT_SYMBOL(ip_conntrack_alter_reply);
919 EXPORT_SYMBOL(ip_conntrack_destroyed);
920 EXPORT_SYMBOL(need_conntrack);
921 EXPORT_SYMBOL(ip_conntrack_helper_register);
922 EXPORT_SYMBOL(ip_conntrack_helper_unregister);
923 EXPORT_SYMBOL(ip_ct_iterate_cleanup);
924 EXPORT_SYMBOL(__ip_ct_refresh_acct);
926 EXPORT_SYMBOL(ip_conntrack_expect_alloc);
927 EXPORT_SYMBOL(ip_conntrack_expect_put);
928 EXPORT_SYMBOL_GPL(__ip_conntrack_expect_find);
929 EXPORT_SYMBOL_GPL(ip_conntrack_expect_find);
930 EXPORT_SYMBOL(ip_conntrack_expect_related);
931 EXPORT_SYMBOL(ip_conntrack_unexpect_related);
932 EXPORT_SYMBOL_GPL(ip_conntrack_expect_list);
933 EXPORT_SYMBOL_GPL(ip_ct_unlink_expect);
935 EXPORT_SYMBOL(ip_conntrack_tuple_taken);
936 EXPORT_SYMBOL(ip_ct_gather_frags);
937 EXPORT_SYMBOL(ip_conntrack_htable_size);
938 EXPORT_SYMBOL(ip_conntrack_lock);
939 EXPORT_SYMBOL(ip_conntrack_hash);
940 EXPORT_SYMBOL(ip_conntrack_untracked);
941 EXPORT_SYMBOL_GPL(ip_conntrack_find_get);
942 #ifdef CONFIG_IP_NF_NAT_NEEDED
943 EXPORT_SYMBOL(ip_conntrack_tcp_update);
946 EXPORT_SYMBOL_GPL(ip_conntrack_flush);
947 EXPORT_SYMBOL_GPL(__ip_conntrack_find);
949 EXPORT_SYMBOL_GPL(ip_conntrack_alloc);
950 EXPORT_SYMBOL_GPL(ip_conntrack_free);
951 EXPORT_SYMBOL_GPL(ip_conntrack_hash_insert);
953 EXPORT_SYMBOL_GPL(ip_ct_remove_expectations);
955 EXPORT_SYMBOL_GPL(ip_conntrack_helper_find_get);
956 EXPORT_SYMBOL_GPL(ip_conntrack_helper_put);
957 EXPORT_SYMBOL_GPL(__ip_conntrack_helper_find_byname);
959 EXPORT_SYMBOL_GPL(ip_conntrack_proto_find_get);
960 EXPORT_SYMBOL_GPL(ip_conntrack_proto_put);
961 EXPORT_SYMBOL_GPL(__ip_conntrack_proto_find);
962 EXPORT_SYMBOL_GPL(ip_conntrack_checksum);
963 #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
964 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
965 EXPORT_SYMBOL_GPL(ip_ct_port_tuple_to_nfattr);
966 EXPORT_SYMBOL_GPL(ip_ct_port_nfattr_to_tuple);