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 #warning MEF should make this seq_printf conditional on xid support
132 if (seq_printf(s, "xid=%d\n", conntrack->xid[IP_CT_DIR_ORIGINAL]))
135 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_ORIGINAL]))
138 if (!(test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)))
139 if (seq_printf(s, "[UNREPLIED] "))
142 if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_REPLY].tuple,
146 #warning MEF should make this seq_printf conditional on xid support
147 if (seq_printf(s, "xid=%d\n", conntrack->xid[IP_CT_DIR_REPLY]))
150 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_REPLY]))
153 if (test_bit(IPS_ASSURED_BIT, &conntrack->status))
154 if (seq_printf(s, "[ASSURED] "))
157 if (seq_printf(s, "use=%u\n", atomic_read(&conntrack->ct_general.use)))
163 static int ct_seq_show(struct seq_file *s, void *v)
165 struct list_head *list = v;
168 /* FIXME: Simply truncates if hash chain too long. */
169 READ_LOCK(&ip_conntrack_lock);
170 if (LIST_FIND(list, ct_seq_real_show,
171 struct ip_conntrack_tuple_hash *, s))
173 READ_UNLOCK(&ip_conntrack_lock);
177 static struct seq_operations ct_seq_ops = {
178 .start = ct_seq_start,
184 static int ct_open(struct inode *inode, struct file *file)
186 return seq_open(file, &ct_seq_ops);
189 static struct file_operations ct_file_ops = {
190 .owner = THIS_MODULE,
194 .release = seq_release
198 static void *exp_seq_start(struct seq_file *s, loff_t *pos)
200 struct list_head *e = &ip_conntrack_expect_list;
203 /* strange seq_file api calls stop even if we fail,
204 * thus we need to grab lock since stop unlocks */
205 READ_LOCK(&ip_conntrack_lock);
206 READ_LOCK(&ip_conntrack_expect_tuple_lock);
211 for (i = 0; i <= *pos; i++) {
213 if (e == &ip_conntrack_expect_list)
219 static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos)
221 struct list_head *e = v;
225 if (e == &ip_conntrack_expect_list)
231 static void exp_seq_stop(struct seq_file *s, void *v)
233 READ_UNLOCK(&ip_conntrack_expect_tuple_lock);
234 READ_UNLOCK(&ip_conntrack_lock);
237 static int exp_seq_show(struct seq_file *s, void *v)
239 struct ip_conntrack_expect *expect = v;
241 if (expect->expectant->helper->timeout)
242 seq_printf(s, "%lu ", timer_pending(&expect->timeout)
243 ? (expect->timeout.expires - jiffies)/HZ : 0);
247 seq_printf(s, "use=%u proto=%u ", atomic_read(&expect->use),
248 expect->tuple.dst.protonum);
250 print_tuple(s, &expect->tuple,
251 ip_ct_find_proto(expect->tuple.dst.protonum));
252 return seq_putc(s, '\n');
255 static struct seq_operations exp_seq_ops = {
256 .start = exp_seq_start,
257 .next = exp_seq_next,
258 .stop = exp_seq_stop,
262 static int exp_open(struct inode *inode, struct file *file)
264 return seq_open(file, &exp_seq_ops);
267 static struct file_operations exp_file_ops = {
268 .owner = THIS_MODULE,
272 .release = seq_release
275 static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
280 return SEQ_START_TOKEN;
282 for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) {
283 if (!cpu_possible(cpu))
286 return &per_cpu(ip_conntrack_stat, cpu);
292 static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
296 for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
297 if (!cpu_possible(cpu))
300 return &per_cpu(ip_conntrack_stat, cpu);
306 static void ct_cpu_seq_stop(struct seq_file *seq, void *v)
310 static int ct_cpu_seq_show(struct seq_file *seq, void *v)
312 unsigned int nr_conntracks = atomic_read(&ip_conntrack_count);
313 struct ip_conntrack_stat *st = v;
315 if (v == SEQ_START_TOKEN) {
316 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");
320 seq_printf(seq, "%08x %08x %08x %08x %08x %08x %08x %08x "
321 "%08x %08x %08x %08x %08x %08x %08x %08x \n",
343 static struct seq_operations ct_cpu_seq_ops = {
344 .start = ct_cpu_seq_start,
345 .next = ct_cpu_seq_next,
346 .stop = ct_cpu_seq_stop,
347 .show = ct_cpu_seq_show,
350 static int ct_cpu_seq_open(struct inode *inode, struct file *file)
352 return seq_open(file, &ct_cpu_seq_ops);
355 static struct file_operations ct_cpu_seq_fops = {
356 .owner = THIS_MODULE,
357 .open = ct_cpu_seq_open,
360 .release = seq_release_private,
364 static unsigned int ip_confirm(unsigned int hooknum,
365 struct sk_buff **pskb,
366 const struct net_device *in,
367 const struct net_device *out,
368 int (*okfn)(struct sk_buff *))
370 /* We've seen it coming out the other side: confirm it */
371 return ip_conntrack_confirm(*pskb);
374 static unsigned int ip_conntrack_defrag(unsigned int hooknum,
375 struct sk_buff **pskb,
376 const struct net_device *in,
377 const struct net_device *out,
378 int (*okfn)(struct sk_buff *))
380 /* Previously seen (loopback)? Ignore. Do this before
385 /* Gather fragments. */
386 if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
387 *pskb = ip_ct_gather_frags(*pskb);
394 static unsigned int ip_refrag(unsigned int hooknum,
395 struct sk_buff **pskb,
396 const struct net_device *in,
397 const struct net_device *out,
398 int (*okfn)(struct sk_buff *))
400 struct rtable *rt = (struct rtable *)(*pskb)->dst;
402 /* We've seen it coming out the other side: confirm */
403 if (ip_confirm(hooknum, pskb, in, out, okfn) != NF_ACCEPT)
406 /* Local packets are never produced too large for their
407 interface. We degfragment them at LOCAL_OUT, however,
408 so we have to refragment them here. */
409 if ((*pskb)->len > dst_pmtu(&rt->u.dst) &&
410 !skb_shinfo(*pskb)->tso_size) {
411 /* No hook can be after us, so this should be OK. */
412 ip_fragment(*pskb, okfn);
418 static unsigned int ip_conntrack_local(unsigned int hooknum,
419 struct sk_buff **pskb,
420 const struct net_device *in,
421 const struct net_device *out,
422 int (*okfn)(struct sk_buff *))
424 /* root is playing with raw sockets. */
425 if ((*pskb)->len < sizeof(struct iphdr)
426 || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) {
428 printk("ipt_hook: happy cracking.\n");
431 return ip_conntrack_in(hooknum, pskb, in, out, okfn);
434 /* Connection tracking may drop packets, but never alters them, so
435 make it the first hook. */
436 static struct nf_hook_ops ip_conntrack_defrag_ops = {
437 .hook = ip_conntrack_defrag,
438 .owner = THIS_MODULE,
440 .hooknum = NF_IP_PRE_ROUTING,
441 .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
444 static struct nf_hook_ops ip_conntrack_in_ops = {
445 .hook = ip_conntrack_in,
446 .owner = THIS_MODULE,
448 .hooknum = NF_IP_PRE_ROUTING,
449 .priority = NF_IP_PRI_CONNTRACK,
452 static struct nf_hook_ops ip_conntrack_defrag_local_out_ops = {
453 .hook = ip_conntrack_defrag,
454 .owner = THIS_MODULE,
456 .hooknum = NF_IP_LOCAL_OUT,
457 .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
460 static struct nf_hook_ops ip_conntrack_local_out_ops = {
461 .hook = ip_conntrack_local,
462 .owner = THIS_MODULE,
464 .hooknum = NF_IP_LOCAL_OUT,
465 .priority = NF_IP_PRI_CONNTRACK,
468 /* Refragmenter; last chance. */
469 static struct nf_hook_ops ip_conntrack_out_ops = {
471 .owner = THIS_MODULE,
473 .hooknum = NF_IP_POST_ROUTING,
474 .priority = NF_IP_PRI_LAST,
477 static struct nf_hook_ops ip_conntrack_local_in_ops = {
479 .owner = THIS_MODULE,
481 .hooknum = NF_IP_LOCAL_IN,
482 .priority = NF_IP_PRI_LAST-1,
489 /* From ip_conntrack_core.c */
490 extern int ip_conntrack_max;
491 extern unsigned int ip_conntrack_htable_size;
493 /* From ip_conntrack_proto_tcp.c */
494 extern unsigned long ip_ct_tcp_timeout_syn_sent;
495 extern unsigned long ip_ct_tcp_timeout_syn_recv;
496 extern unsigned long ip_ct_tcp_timeout_established;
497 extern unsigned long ip_ct_tcp_timeout_fin_wait;
498 extern unsigned long ip_ct_tcp_timeout_close_wait;
499 extern unsigned long ip_ct_tcp_timeout_last_ack;
500 extern unsigned long ip_ct_tcp_timeout_time_wait;
501 extern unsigned long ip_ct_tcp_timeout_close;
502 extern unsigned long ip_ct_tcp_timeout_max_retrans;
503 extern int ip_ct_tcp_loose;
504 extern int ip_ct_tcp_be_liberal;
505 extern int ip_ct_tcp_max_retrans;
507 /* From ip_conntrack_proto_udp.c */
508 extern unsigned long ip_ct_udp_timeout;
509 extern unsigned long ip_ct_udp_timeout_stream;
511 /* From ip_conntrack_proto_icmp.c */
512 extern unsigned long ip_ct_icmp_timeout;
514 /* From ip_conntrack_proto_icmp.c */
515 extern unsigned long ip_ct_generic_timeout;
517 /* Log invalid packets of a given protocol */
518 static int log_invalid_proto_min = 0;
519 static int log_invalid_proto_max = 255;
521 static struct ctl_table_header *ip_ct_sysctl_header;
523 static ctl_table ip_ct_sysctl_table[] = {
525 .ctl_name = NET_IPV4_NF_CONNTRACK_MAX,
526 .procname = "ip_conntrack_max",
527 .data = &ip_conntrack_max,
528 .maxlen = sizeof(int),
530 .proc_handler = &proc_dointvec,
533 .ctl_name = NET_IPV4_NF_CONNTRACK_COUNT,
534 .procname = "ip_conntrack_count",
535 .data = &ip_conntrack_count,
536 .maxlen = sizeof(int),
538 .proc_handler = &proc_dointvec,
541 .ctl_name = NET_IPV4_NF_CONNTRACK_BUCKETS,
542 .procname = "ip_conntrack_buckets",
543 .data = &ip_conntrack_htable_size,
544 .maxlen = sizeof(unsigned int),
546 .proc_handler = &proc_dointvec,
549 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT,
550 .procname = "ip_conntrack_tcp_timeout_syn_sent",
551 .data = &ip_ct_tcp_timeout_syn_sent,
552 .maxlen = sizeof(unsigned int),
554 .proc_handler = &proc_dointvec_jiffies,
557 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV,
558 .procname = "ip_conntrack_tcp_timeout_syn_recv",
559 .data = &ip_ct_tcp_timeout_syn_recv,
560 .maxlen = sizeof(unsigned int),
562 .proc_handler = &proc_dointvec_jiffies,
565 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED,
566 .procname = "ip_conntrack_tcp_timeout_established",
567 .data = &ip_ct_tcp_timeout_established,
568 .maxlen = sizeof(unsigned int),
570 .proc_handler = &proc_dointvec_jiffies,
573 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT,
574 .procname = "ip_conntrack_tcp_timeout_fin_wait",
575 .data = &ip_ct_tcp_timeout_fin_wait,
576 .maxlen = sizeof(unsigned int),
578 .proc_handler = &proc_dointvec_jiffies,
581 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT,
582 .procname = "ip_conntrack_tcp_timeout_close_wait",
583 .data = &ip_ct_tcp_timeout_close_wait,
584 .maxlen = sizeof(unsigned int),
586 .proc_handler = &proc_dointvec_jiffies,
589 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK,
590 .procname = "ip_conntrack_tcp_timeout_last_ack",
591 .data = &ip_ct_tcp_timeout_last_ack,
592 .maxlen = sizeof(unsigned int),
594 .proc_handler = &proc_dointvec_jiffies,
597 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT,
598 .procname = "ip_conntrack_tcp_timeout_time_wait",
599 .data = &ip_ct_tcp_timeout_time_wait,
600 .maxlen = sizeof(unsigned int),
602 .proc_handler = &proc_dointvec_jiffies,
605 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE,
606 .procname = "ip_conntrack_tcp_timeout_close",
607 .data = &ip_ct_tcp_timeout_close,
608 .maxlen = sizeof(unsigned int),
610 .proc_handler = &proc_dointvec_jiffies,
613 .ctl_name = NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT,
614 .procname = "ip_conntrack_udp_timeout",
615 .data = &ip_ct_udp_timeout,
616 .maxlen = sizeof(unsigned int),
618 .proc_handler = &proc_dointvec_jiffies,
621 .ctl_name = NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT_STREAM,
622 .procname = "ip_conntrack_udp_timeout_stream",
623 .data = &ip_ct_udp_timeout_stream,
624 .maxlen = sizeof(unsigned int),
626 .proc_handler = &proc_dointvec_jiffies,
629 .ctl_name = NET_IPV4_NF_CONNTRACK_ICMP_TIMEOUT,
630 .procname = "ip_conntrack_icmp_timeout",
631 .data = &ip_ct_icmp_timeout,
632 .maxlen = sizeof(unsigned int),
634 .proc_handler = &proc_dointvec_jiffies,
637 .ctl_name = NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT,
638 .procname = "ip_conntrack_generic_timeout",
639 .data = &ip_ct_generic_timeout,
640 .maxlen = sizeof(unsigned int),
642 .proc_handler = &proc_dointvec_jiffies,
645 .ctl_name = NET_IPV4_NF_CONNTRACK_LOG_INVALID,
646 .procname = "ip_conntrack_log_invalid",
647 .data = &ip_ct_log_invalid,
648 .maxlen = sizeof(unsigned int),
650 .proc_handler = &proc_dointvec_minmax,
651 .strategy = &sysctl_intvec,
652 .extra1 = &log_invalid_proto_min,
653 .extra2 = &log_invalid_proto_max,
656 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS,
657 .procname = "ip_conntrack_tcp_timeout_max_retrans",
658 .data = &ip_ct_tcp_timeout_max_retrans,
659 .maxlen = sizeof(unsigned int),
661 .proc_handler = &proc_dointvec_jiffies,
664 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_LOOSE,
665 .procname = "ip_conntrack_tcp_loose",
666 .data = &ip_ct_tcp_loose,
667 .maxlen = sizeof(unsigned int),
669 .proc_handler = &proc_dointvec,
672 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_BE_LIBERAL,
673 .procname = "ip_conntrack_tcp_be_liberal",
674 .data = &ip_ct_tcp_be_liberal,
675 .maxlen = sizeof(unsigned int),
677 .proc_handler = &proc_dointvec,
680 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_MAX_RETRANS,
681 .procname = "ip_conntrack_tcp_max_retrans",
682 .data = &ip_ct_tcp_max_retrans,
683 .maxlen = sizeof(unsigned int),
685 .proc_handler = &proc_dointvec,
690 #define NET_IP_CONNTRACK_MAX 2089
692 static ctl_table ip_ct_netfilter_table[] = {
694 .ctl_name = NET_IPV4_NETFILTER,
695 .procname = "netfilter",
697 .child = ip_ct_sysctl_table,
700 .ctl_name = NET_IP_CONNTRACK_MAX,
701 .procname = "ip_conntrack_max",
702 .data = &ip_conntrack_max,
703 .maxlen = sizeof(int),
705 .proc_handler = &proc_dointvec
710 static ctl_table ip_ct_ipv4_table[] = {
712 .ctl_name = NET_IPV4,
715 .child = ip_ct_netfilter_table,
720 static ctl_table ip_ct_net_table[] = {
725 .child = ip_ct_ipv4_table,
730 EXPORT_SYMBOL(ip_ct_log_invalid);
731 #endif /* CONFIG_SYSCTL */
733 static int init_or_cleanup(int init)
735 #ifdef CONFIG_PROC_FS
736 struct proc_dir_entry *proc, *proc_exp, *proc_stat;
740 if (!init) goto cleanup;
742 ret = ip_conntrack_init();
744 goto cleanup_nothing;
746 #ifdef CONFIG_PROC_FS
747 proc = proc_net_fops_create("ip_conntrack", 0440, &ct_file_ops);
748 if (!proc) goto cleanup_init;
750 proc_exp = proc_net_fops_create("ip_conntrack_expect", 0440,
752 if (!proc_exp) goto cleanup_proc;
754 proc_stat = create_proc_entry("ip_conntrack", S_IRUGO, proc_net_stat);
756 goto cleanup_proc_exp;
758 proc_stat->proc_fops = &ct_cpu_seq_fops;
759 proc_stat->owner = THIS_MODULE;
762 ret = nf_register_hook(&ip_conntrack_defrag_ops);
764 printk("ip_conntrack: can't register pre-routing defrag hook.\n");
765 goto cleanup_proc_stat;
767 ret = nf_register_hook(&ip_conntrack_defrag_local_out_ops);
769 printk("ip_conntrack: can't register local_out defrag hook.\n");
770 goto cleanup_defragops;
772 ret = nf_register_hook(&ip_conntrack_in_ops);
774 printk("ip_conntrack: can't register pre-routing hook.\n");
775 goto cleanup_defraglocalops;
777 ret = nf_register_hook(&ip_conntrack_local_out_ops);
779 printk("ip_conntrack: can't register local out hook.\n");
782 ret = nf_register_hook(&ip_conntrack_out_ops);
784 printk("ip_conntrack: can't register post-routing hook.\n");
785 goto cleanup_inandlocalops;
787 ret = nf_register_hook(&ip_conntrack_local_in_ops);
789 printk("ip_conntrack: can't register local in hook.\n");
790 goto cleanup_inoutandlocalops;
793 ip_ct_sysctl_header = register_sysctl_table(ip_ct_net_table, 0);
794 if (ip_ct_sysctl_header == NULL) {
795 printk("ip_conntrack: can't register to sysctl.\n");
804 unregister_sysctl_table(ip_ct_sysctl_header);
806 nf_unregister_hook(&ip_conntrack_local_in_ops);
807 cleanup_inoutandlocalops:
808 nf_unregister_hook(&ip_conntrack_out_ops);
809 cleanup_inandlocalops:
810 nf_unregister_hook(&ip_conntrack_local_out_ops);
812 nf_unregister_hook(&ip_conntrack_in_ops);
813 cleanup_defraglocalops:
814 nf_unregister_hook(&ip_conntrack_defrag_local_out_ops);
816 /* Frag queues may hold fragments with skb->dst == NULL */
822 nf_unregister_hook(&ip_conntrack_defrag_ops);
824 #ifdef CONFIG_PROC_FS
825 proc_net_remove("ip_conntrack_stat");
827 proc_net_remove("ip_conntrack_expect");
829 proc_net_remove("ip_conntrack");
831 #endif /* CONFIG_PROC_FS */
832 ip_conntrack_cleanup();
837 /* FIXME: Allow NULL functions and sub in pointers to generic for
839 int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto)
843 WRITE_LOCK(&ip_conntrack_lock);
844 if (ip_ct_protos[proto->proto] != &ip_conntrack_generic_protocol) {
848 ip_ct_protos[proto->proto] = proto;
850 WRITE_UNLOCK(&ip_conntrack_lock);
854 void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto)
856 WRITE_LOCK(&ip_conntrack_lock);
857 ip_ct_protos[proto->proto] = &ip_conntrack_generic_protocol;
858 WRITE_UNLOCK(&ip_conntrack_lock);
860 /* Somebody could be still looking at the proto in bh. */
863 /* Remove all contrack entries for this protocol */
864 ip_ct_selective_cleanup(kill_proto, &proto->proto);
867 static int __init init(void)
869 return init_or_cleanup(1);
872 static void __exit fini(void)
880 /* Some modules need us, but don't depend directly on any symbol.
881 They should call this. */
882 void need_ip_conntrack(void)
886 EXPORT_SYMBOL(ip_conntrack_protocol_register);
887 EXPORT_SYMBOL(ip_conntrack_protocol_unregister);
888 EXPORT_SYMBOL(invert_tuplepr);
889 EXPORT_SYMBOL(ip_conntrack_alter_reply);
890 EXPORT_SYMBOL(ip_conntrack_destroyed);
891 EXPORT_SYMBOL(need_ip_conntrack);
892 EXPORT_SYMBOL(ip_conntrack_helper_register);
893 EXPORT_SYMBOL(ip_conntrack_helper_unregister);
894 EXPORT_SYMBOL(ip_ct_selective_cleanup);
895 EXPORT_SYMBOL(ip_ct_refresh_acct);
896 EXPORT_SYMBOL(ip_ct_protos);
897 EXPORT_SYMBOL(ip_ct_find_proto);
898 EXPORT_SYMBOL(ip_ct_find_helper);
899 EXPORT_SYMBOL(ip_conntrack_expect_alloc);
900 EXPORT_SYMBOL(ip_conntrack_expect_related);
901 EXPORT_SYMBOL(ip_conntrack_change_expect);
902 EXPORT_SYMBOL(ip_conntrack_unexpect_related);
903 EXPORT_SYMBOL_GPL(ip_conntrack_expect_find_get);
904 EXPORT_SYMBOL_GPL(ip_conntrack_expect_put);
905 EXPORT_SYMBOL(ip_conntrack_tuple_taken);
906 EXPORT_SYMBOL(ip_ct_gather_frags);
907 EXPORT_SYMBOL(ip_conntrack_htable_size);
908 EXPORT_SYMBOL(ip_conntrack_expect_list);
909 EXPORT_SYMBOL(ip_conntrack_lock);
910 EXPORT_SYMBOL(ip_conntrack_hash);
911 EXPORT_SYMBOL(ip_conntrack_untracked);
912 EXPORT_SYMBOL_GPL(ip_conntrack_find_get);
913 EXPORT_SYMBOL_GPL(ip_conntrack_put);