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-2004 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>
31 #define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_conntrack_lock)
32 #define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_conntrack_lock)
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>
38 #include <linux/netfilter_ipv4/listhelp.h>
43 #define DEBUGP(format, args...)
46 MODULE_LICENSE("GPL");
48 extern atomic_t ip_conntrack_count;
49 DECLARE_PER_CPU(struct ip_conntrack_stat, ip_conntrack_stat);
51 static int kill_proto(const struct ip_conntrack *i, void *data)
53 return (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum ==
54 *((u_int8_t *) data));
59 print_tuple(struct seq_file *s, const struct ip_conntrack_tuple *tuple,
60 struct ip_conntrack_protocol *proto)
62 seq_printf(s, "src=%u.%u.%u.%u dst=%u.%u.%u.%u ",
63 NIPQUAD(tuple->src.ip), NIPQUAD(tuple->dst.ip));
64 return proto->print_tuple(s, tuple);
67 #ifdef CONFIG_IP_NF_CT_ACCT
69 seq_print_counters(struct seq_file *s, 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 static void *ct_seq_start(struct seq_file *s, loff_t *pos)
81 if (*pos >= ip_conntrack_htable_size)
83 return &ip_conntrack_hash[*pos];
86 static void ct_seq_stop(struct seq_file *s, void *v)
90 static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos)
93 if (*pos >= ip_conntrack_htable_size)
95 return &ip_conntrack_hash[*pos];
98 /* return 0 on success, 1 in case of error */
99 static int ct_seq_real_show(const struct ip_conntrack_tuple_hash *hash,
102 struct ip_conntrack *conntrack = hash->ctrack;
103 struct ip_conntrack_protocol *proto;
105 MUST_BE_READ_LOCKED(&ip_conntrack_lock);
107 IP_NF_ASSERT(conntrack);
109 /* we only want to print DIR_ORIGINAL */
113 proto = ip_ct_find_proto(conntrack->tuplehash[IP_CT_DIR_ORIGINAL]
114 .tuple.dst.protonum);
117 if (seq_printf(s, "%-8s %u %lu ",
119 conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum,
120 timer_pending(&conntrack->timeout)
121 ? (conntrack->timeout.expires - jiffies)/HZ : 0) != 0)
124 if (proto->print_conntrack(s, conntrack))
127 if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
131 #if defined(CONFIG_VNET) || defined(CONFIG_VNET_MODULE)
132 if (seq_printf(s, "xid=%d\n", conntrack->xid[IP_CT_DIR_ORIGINAL]))
136 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_ORIGINAL]))
139 if (!(test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)))
140 if (seq_printf(s, "[UNREPLIED] "))
143 if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_REPLY].tuple,
147 #if defined(CONFIG_VNET) || defined(CONFIG_VNET_MODULE)
148 if (seq_printf(s, "xid=%d\n", conntrack->xid[IP_CT_DIR_REPLY]))
152 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_REPLY]))
155 if (test_bit(IPS_ASSURED_BIT, &conntrack->status))
156 if (seq_printf(s, "[ASSURED] "))
159 if (seq_printf(s, "use=%u\n", atomic_read(&conntrack->ct_general.use)))
165 static int ct_seq_show(struct seq_file *s, void *v)
167 struct list_head *list = v;
170 /* FIXME: Simply truncates if hash chain too long. */
171 READ_LOCK(&ip_conntrack_lock);
172 if (LIST_FIND(list, ct_seq_real_show,
173 struct ip_conntrack_tuple_hash *, s))
175 READ_UNLOCK(&ip_conntrack_lock);
179 static struct seq_operations ct_seq_ops = {
180 .start = ct_seq_start,
186 static int ct_open(struct inode *inode, struct file *file)
188 return seq_open(file, &ct_seq_ops);
191 static struct file_operations ct_file_ops = {
192 .owner = THIS_MODULE,
196 .release = seq_release
200 static void *exp_seq_start(struct seq_file *s, loff_t *pos)
202 struct list_head *e = &ip_conntrack_expect_list;
205 /* strange seq_file api calls stop even if we fail,
206 * thus we need to grab lock since stop unlocks */
207 READ_LOCK(&ip_conntrack_lock);
208 READ_LOCK(&ip_conntrack_expect_tuple_lock);
213 for (i = 0; i <= *pos; i++) {
215 if (e == &ip_conntrack_expect_list)
221 static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos)
223 struct list_head *e = v;
227 if (e == &ip_conntrack_expect_list)
233 static void exp_seq_stop(struct seq_file *s, void *v)
235 READ_UNLOCK(&ip_conntrack_expect_tuple_lock);
236 READ_UNLOCK(&ip_conntrack_lock);
239 static int exp_seq_show(struct seq_file *s, void *v)
241 struct ip_conntrack_expect *expect = v;
243 if (expect->expectant->helper->timeout)
244 seq_printf(s, "%lu ", timer_pending(&expect->timeout)
245 ? (expect->timeout.expires - jiffies)/HZ : 0);
249 seq_printf(s, "use=%u proto=%u ", atomic_read(&expect->use),
250 expect->tuple.dst.protonum);
252 print_tuple(s, &expect->tuple,
253 ip_ct_find_proto(expect->tuple.dst.protonum));
254 return seq_putc(s, '\n');
257 static struct seq_operations exp_seq_ops = {
258 .start = exp_seq_start,
259 .next = exp_seq_next,
260 .stop = exp_seq_stop,
264 static int exp_open(struct inode *inode, struct file *file)
266 return seq_open(file, &exp_seq_ops);
269 static struct file_operations exp_file_ops = {
270 .owner = THIS_MODULE,
274 .release = seq_release
277 static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
282 return SEQ_START_TOKEN;
284 for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) {
285 if (!cpu_possible(cpu))
288 return &per_cpu(ip_conntrack_stat, cpu);
294 static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
298 for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
299 if (!cpu_possible(cpu))
302 return &per_cpu(ip_conntrack_stat, cpu);
308 static void ct_cpu_seq_stop(struct seq_file *seq, void *v)
312 static int ct_cpu_seq_show(struct seq_file *seq, void *v)
314 unsigned int nr_conntracks = atomic_read(&ip_conntrack_count);
315 struct ip_conntrack_stat *st = v;
317 if (v == SEQ_START_TOKEN) {
318 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");
322 seq_printf(seq, "%08x %08x %08x %08x %08x %08x %08x %08x "
323 "%08x %08x %08x %08x %08x %08x %08x %08x \n",
345 static struct seq_operations ct_cpu_seq_ops = {
346 .start = ct_cpu_seq_start,
347 .next = ct_cpu_seq_next,
348 .stop = ct_cpu_seq_stop,
349 .show = ct_cpu_seq_show,
352 static int ct_cpu_seq_open(struct inode *inode, struct file *file)
354 return seq_open(file, &ct_cpu_seq_ops);
357 static struct file_operations ct_cpu_seq_fops = {
358 .owner = THIS_MODULE,
359 .open = ct_cpu_seq_open,
362 .release = seq_release_private,
366 static unsigned int ip_confirm(unsigned int hooknum,
367 struct sk_buff **pskb,
368 const struct net_device *in,
369 const struct net_device *out,
370 int (*okfn)(struct sk_buff *))
372 /* We've seen it coming out the other side: confirm it */
373 return ip_conntrack_confirm(*pskb);
376 static unsigned int ip_conntrack_defrag(unsigned int hooknum,
377 struct sk_buff **pskb,
378 const struct net_device *in,
379 const struct net_device *out,
380 int (*okfn)(struct sk_buff *))
382 /* Previously seen (loopback)? Ignore. Do this before
387 /* Gather fragments. */
388 if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
389 *pskb = ip_ct_gather_frags(*pskb);
396 static unsigned int ip_refrag(unsigned int hooknum,
397 struct sk_buff **pskb,
398 const struct net_device *in,
399 const struct net_device *out,
400 int (*okfn)(struct sk_buff *))
402 struct rtable *rt = (struct rtable *)(*pskb)->dst;
404 /* We've seen it coming out the other side: confirm */
405 if (ip_confirm(hooknum, pskb, in, out, okfn) != NF_ACCEPT)
408 /* Local packets are never produced too large for their
409 interface. We degfragment them at LOCAL_OUT, however,
410 so we have to refragment them here. */
411 if ((*pskb)->len > dst_pmtu(&rt->u.dst) &&
412 !skb_shinfo(*pskb)->tso_size) {
413 /* No hook can be after us, so this should be OK. */
414 ip_fragment(*pskb, okfn);
420 static unsigned int ip_conntrack_local(unsigned int hooknum,
421 struct sk_buff **pskb,
422 const struct net_device *in,
423 const struct net_device *out,
424 int (*okfn)(struct sk_buff *))
426 /* root is playing with raw sockets. */
427 if ((*pskb)->len < sizeof(struct iphdr)
428 || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) {
430 printk("ipt_hook: happy cracking.\n");
433 return ip_conntrack_in(hooknum, pskb, in, out, okfn);
436 /* Connection tracking may drop packets, but never alters them, so
437 make it the first hook. */
438 static struct nf_hook_ops ip_conntrack_defrag_ops = {
439 .hook = ip_conntrack_defrag,
440 .owner = THIS_MODULE,
442 .hooknum = NF_IP_PRE_ROUTING,
443 .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
446 static struct nf_hook_ops ip_conntrack_in_ops = {
447 .hook = ip_conntrack_in,
448 .owner = THIS_MODULE,
450 .hooknum = NF_IP_PRE_ROUTING,
451 .priority = NF_IP_PRI_CONNTRACK,
454 static struct nf_hook_ops ip_conntrack_defrag_local_out_ops = {
455 .hook = ip_conntrack_defrag,
456 .owner = THIS_MODULE,
458 .hooknum = NF_IP_LOCAL_OUT,
459 .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
462 static struct nf_hook_ops ip_conntrack_local_out_ops = {
463 .hook = ip_conntrack_local,
464 .owner = THIS_MODULE,
466 .hooknum = NF_IP_LOCAL_OUT,
467 .priority = NF_IP_PRI_CONNTRACK,
470 /* Refragmenter; last chance. */
471 static struct nf_hook_ops ip_conntrack_out_ops = {
473 .owner = THIS_MODULE,
475 .hooknum = NF_IP_POST_ROUTING,
476 .priority = NF_IP_PRI_LAST,
479 static struct nf_hook_ops ip_conntrack_local_in_ops = {
481 .owner = THIS_MODULE,
483 .hooknum = NF_IP_LOCAL_IN,
484 .priority = NF_IP_PRI_LAST-1,
491 /* From ip_conntrack_core.c */
492 extern int ip_conntrack_max;
493 extern unsigned int ip_conntrack_htable_size;
495 /* From ip_conntrack_proto_tcp.c */
496 extern unsigned long ip_ct_tcp_timeout_syn_sent;
497 extern unsigned long ip_ct_tcp_timeout_syn_recv;
498 extern unsigned long ip_ct_tcp_timeout_established;
499 extern unsigned long ip_ct_tcp_timeout_fin_wait;
500 extern unsigned long ip_ct_tcp_timeout_close_wait;
501 extern unsigned long ip_ct_tcp_timeout_last_ack;
502 extern unsigned long ip_ct_tcp_timeout_time_wait;
503 extern unsigned long ip_ct_tcp_timeout_close;
504 extern unsigned long ip_ct_tcp_timeout_max_retrans;
505 extern int ip_ct_tcp_loose;
506 extern int ip_ct_tcp_be_liberal;
507 extern int ip_ct_tcp_max_retrans;
509 /* From ip_conntrack_proto_udp.c */
510 extern unsigned long ip_ct_udp_timeout;
511 extern unsigned long ip_ct_udp_timeout_stream;
513 /* From ip_conntrack_proto_icmp.c */
514 extern unsigned long ip_ct_icmp_timeout;
516 /* From ip_conntrack_proto_icmp.c */
517 extern unsigned long ip_ct_generic_timeout;
519 /* Log invalid packets of a given protocol */
520 static int log_invalid_proto_min = 0;
521 static int log_invalid_proto_max = 255;
523 static struct ctl_table_header *ip_ct_sysctl_header;
525 static ctl_table ip_ct_sysctl_table[] = {
527 .ctl_name = NET_IPV4_NF_CONNTRACK_MAX,
528 .procname = "ip_conntrack_max",
529 .data = &ip_conntrack_max,
530 .maxlen = sizeof(int),
532 .proc_handler = &proc_dointvec,
535 .ctl_name = NET_IPV4_NF_CONNTRACK_COUNT,
536 .procname = "ip_conntrack_count",
537 .data = &ip_conntrack_count,
538 .maxlen = sizeof(int),
540 .proc_handler = &proc_dointvec,
543 .ctl_name = NET_IPV4_NF_CONNTRACK_BUCKETS,
544 .procname = "ip_conntrack_buckets",
545 .data = &ip_conntrack_htable_size,
546 .maxlen = sizeof(unsigned int),
548 .proc_handler = &proc_dointvec,
551 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT,
552 .procname = "ip_conntrack_tcp_timeout_syn_sent",
553 .data = &ip_ct_tcp_timeout_syn_sent,
554 .maxlen = sizeof(unsigned int),
556 .proc_handler = &proc_dointvec_jiffies,
559 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV,
560 .procname = "ip_conntrack_tcp_timeout_syn_recv",
561 .data = &ip_ct_tcp_timeout_syn_recv,
562 .maxlen = sizeof(unsigned int),
564 .proc_handler = &proc_dointvec_jiffies,
567 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED,
568 .procname = "ip_conntrack_tcp_timeout_established",
569 .data = &ip_ct_tcp_timeout_established,
570 .maxlen = sizeof(unsigned int),
572 .proc_handler = &proc_dointvec_jiffies,
575 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT,
576 .procname = "ip_conntrack_tcp_timeout_fin_wait",
577 .data = &ip_ct_tcp_timeout_fin_wait,
578 .maxlen = sizeof(unsigned int),
580 .proc_handler = &proc_dointvec_jiffies,
583 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT,
584 .procname = "ip_conntrack_tcp_timeout_close_wait",
585 .data = &ip_ct_tcp_timeout_close_wait,
586 .maxlen = sizeof(unsigned int),
588 .proc_handler = &proc_dointvec_jiffies,
591 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK,
592 .procname = "ip_conntrack_tcp_timeout_last_ack",
593 .data = &ip_ct_tcp_timeout_last_ack,
594 .maxlen = sizeof(unsigned int),
596 .proc_handler = &proc_dointvec_jiffies,
599 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT,
600 .procname = "ip_conntrack_tcp_timeout_time_wait",
601 .data = &ip_ct_tcp_timeout_time_wait,
602 .maxlen = sizeof(unsigned int),
604 .proc_handler = &proc_dointvec_jiffies,
607 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE,
608 .procname = "ip_conntrack_tcp_timeout_close",
609 .data = &ip_ct_tcp_timeout_close,
610 .maxlen = sizeof(unsigned int),
612 .proc_handler = &proc_dointvec_jiffies,
615 .ctl_name = NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT,
616 .procname = "ip_conntrack_udp_timeout",
617 .data = &ip_ct_udp_timeout,
618 .maxlen = sizeof(unsigned int),
620 .proc_handler = &proc_dointvec_jiffies,
623 .ctl_name = NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT_STREAM,
624 .procname = "ip_conntrack_udp_timeout_stream",
625 .data = &ip_ct_udp_timeout_stream,
626 .maxlen = sizeof(unsigned int),
628 .proc_handler = &proc_dointvec_jiffies,
631 .ctl_name = NET_IPV4_NF_CONNTRACK_ICMP_TIMEOUT,
632 .procname = "ip_conntrack_icmp_timeout",
633 .data = &ip_ct_icmp_timeout,
634 .maxlen = sizeof(unsigned int),
636 .proc_handler = &proc_dointvec_jiffies,
639 .ctl_name = NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT,
640 .procname = "ip_conntrack_generic_timeout",
641 .data = &ip_ct_generic_timeout,
642 .maxlen = sizeof(unsigned int),
644 .proc_handler = &proc_dointvec_jiffies,
647 .ctl_name = NET_IPV4_NF_CONNTRACK_LOG_INVALID,
648 .procname = "ip_conntrack_log_invalid",
649 .data = &ip_ct_log_invalid,
650 .maxlen = sizeof(unsigned int),
652 .proc_handler = &proc_dointvec_minmax,
653 .strategy = &sysctl_intvec,
654 .extra1 = &log_invalid_proto_min,
655 .extra2 = &log_invalid_proto_max,
658 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS,
659 .procname = "ip_conntrack_tcp_timeout_max_retrans",
660 .data = &ip_ct_tcp_timeout_max_retrans,
661 .maxlen = sizeof(unsigned int),
663 .proc_handler = &proc_dointvec_jiffies,
666 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_LOOSE,
667 .procname = "ip_conntrack_tcp_loose",
668 .data = &ip_ct_tcp_loose,
669 .maxlen = sizeof(unsigned int),
671 .proc_handler = &proc_dointvec,
674 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_BE_LIBERAL,
675 .procname = "ip_conntrack_tcp_be_liberal",
676 .data = &ip_ct_tcp_be_liberal,
677 .maxlen = sizeof(unsigned int),
679 .proc_handler = &proc_dointvec,
682 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_MAX_RETRANS,
683 .procname = "ip_conntrack_tcp_max_retrans",
684 .data = &ip_ct_tcp_max_retrans,
685 .maxlen = sizeof(unsigned int),
687 .proc_handler = &proc_dointvec,
692 #define NET_IP_CONNTRACK_MAX 2089
694 static ctl_table ip_ct_netfilter_table[] = {
696 .ctl_name = NET_IPV4_NETFILTER,
697 .procname = "netfilter",
699 .child = ip_ct_sysctl_table,
702 .ctl_name = NET_IP_CONNTRACK_MAX,
703 .procname = "ip_conntrack_max",
704 .data = &ip_conntrack_max,
705 .maxlen = sizeof(int),
707 .proc_handler = &proc_dointvec
712 static ctl_table ip_ct_ipv4_table[] = {
714 .ctl_name = NET_IPV4,
717 .child = ip_ct_netfilter_table,
722 static ctl_table ip_ct_net_table[] = {
727 .child = ip_ct_ipv4_table,
732 EXPORT_SYMBOL(ip_ct_log_invalid);
733 #endif /* CONFIG_SYSCTL */
735 static int init_or_cleanup(int init)
737 #ifdef CONFIG_PROC_FS
738 struct proc_dir_entry *proc, *proc_exp, *proc_stat;
742 if (!init) goto cleanup;
744 ret = ip_conntrack_init();
746 goto cleanup_nothing;
748 #ifdef CONFIG_PROC_FS
749 proc = proc_net_fops_create("ip_conntrack", 0440, &ct_file_ops);
750 if (!proc) goto cleanup_init;
752 proc_exp = proc_net_fops_create("ip_conntrack_expect", 0440,
754 if (!proc_exp) goto cleanup_proc;
756 proc_stat = create_proc_entry("ip_conntrack", S_IRUGO, proc_net_stat);
758 goto cleanup_proc_exp;
760 proc_stat->proc_fops = &ct_cpu_seq_fops;
761 proc_stat->owner = THIS_MODULE;
764 ret = nf_register_hook(&ip_conntrack_defrag_ops);
766 printk("ip_conntrack: can't register pre-routing defrag hook.\n");
767 goto cleanup_proc_stat;
769 ret = nf_register_hook(&ip_conntrack_defrag_local_out_ops);
771 printk("ip_conntrack: can't register local_out defrag hook.\n");
772 goto cleanup_defragops;
774 ret = nf_register_hook(&ip_conntrack_in_ops);
776 printk("ip_conntrack: can't register pre-routing hook.\n");
777 goto cleanup_defraglocalops;
779 ret = nf_register_hook(&ip_conntrack_local_out_ops);
781 printk("ip_conntrack: can't register local out hook.\n");
784 ret = nf_register_hook(&ip_conntrack_out_ops);
786 printk("ip_conntrack: can't register post-routing hook.\n");
787 goto cleanup_inandlocalops;
789 ret = nf_register_hook(&ip_conntrack_local_in_ops);
791 printk("ip_conntrack: can't register local in hook.\n");
792 goto cleanup_inoutandlocalops;
795 ip_ct_sysctl_header = register_sysctl_table(ip_ct_net_table, 0);
796 if (ip_ct_sysctl_header == NULL) {
797 printk("ip_conntrack: can't register to sysctl.\n");
806 unregister_sysctl_table(ip_ct_sysctl_header);
808 nf_unregister_hook(&ip_conntrack_local_in_ops);
809 cleanup_inoutandlocalops:
810 nf_unregister_hook(&ip_conntrack_out_ops);
811 cleanup_inandlocalops:
812 nf_unregister_hook(&ip_conntrack_local_out_ops);
814 nf_unregister_hook(&ip_conntrack_in_ops);
815 cleanup_defraglocalops:
816 nf_unregister_hook(&ip_conntrack_defrag_local_out_ops);
818 /* Frag queues may hold fragments with skb->dst == NULL */
824 nf_unregister_hook(&ip_conntrack_defrag_ops);
826 #ifdef CONFIG_PROC_FS
827 proc_net_remove("ip_conntrack_stat");
829 proc_net_remove("ip_conntrack_expect");
831 proc_net_remove("ip_conntrack");
833 #endif /* CONFIG_PROC_FS */
834 ip_conntrack_cleanup();
839 /* FIXME: Allow NULL functions and sub in pointers to generic for
841 int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto)
845 WRITE_LOCK(&ip_conntrack_lock);
846 if (ip_ct_protos[proto->proto] != &ip_conntrack_generic_protocol) {
850 ip_ct_protos[proto->proto] = proto;
852 WRITE_UNLOCK(&ip_conntrack_lock);
856 void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto)
858 WRITE_LOCK(&ip_conntrack_lock);
859 ip_ct_protos[proto->proto] = &ip_conntrack_generic_protocol;
860 WRITE_UNLOCK(&ip_conntrack_lock);
862 /* Somebody could be still looking at the proto in bh. */
865 /* Remove all contrack entries for this protocol */
866 ip_ct_selective_cleanup(kill_proto, &proto->proto);
869 static int __init init(void)
871 return init_or_cleanup(1);
874 static void __exit fini(void)
882 /* Some modules need us, but don't depend directly on any symbol.
883 They should call this. */
884 void need_ip_conntrack(void)
888 EXPORT_SYMBOL(ip_conntrack_protocol_register);
889 EXPORT_SYMBOL(ip_conntrack_protocol_unregister);
890 EXPORT_SYMBOL(invert_tuplepr);
891 EXPORT_SYMBOL(ip_conntrack_alter_reply);
892 EXPORT_SYMBOL(ip_conntrack_destroyed);
893 EXPORT_SYMBOL(need_ip_conntrack);
894 EXPORT_SYMBOL(ip_conntrack_helper_register);
895 EXPORT_SYMBOL(ip_conntrack_helper_unregister);
896 EXPORT_SYMBOL(ip_ct_selective_cleanup);
897 EXPORT_SYMBOL(ip_ct_refresh_acct);
898 EXPORT_SYMBOL(ip_ct_protos);
899 EXPORT_SYMBOL(ip_ct_find_proto);
900 EXPORT_SYMBOL(ip_ct_find_helper);
901 EXPORT_SYMBOL(ip_conntrack_expect_alloc);
902 EXPORT_SYMBOL(ip_conntrack_expect_related);
903 EXPORT_SYMBOL(ip_conntrack_change_expect);
904 EXPORT_SYMBOL(ip_conntrack_unexpect_related);
905 EXPORT_SYMBOL_GPL(ip_conntrack_expect_find_get);
906 EXPORT_SYMBOL_GPL(ip_conntrack_expect_put);
907 EXPORT_SYMBOL(ip_conntrack_tuple_taken);
908 EXPORT_SYMBOL(ip_ct_gather_frags);
909 EXPORT_SYMBOL(ip_conntrack_htable_size);
910 EXPORT_SYMBOL(ip_conntrack_expect_list);
911 EXPORT_SYMBOL(ip_conntrack_lock);
912 EXPORT_SYMBOL(ip_conntrack_hash);
913 EXPORT_SYMBOL(ip_conntrack_untracked);
914 EXPORT_SYMBOL_GPL(ip_conntrack_find_get);
915 EXPORT_SYMBOL_GPL(ip_conntrack_put);