Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 1 | /* (C) 1999-2001 Paul `Rusty' Russell |
| 2 | * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 7 | */ |
| 8 | |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 9 | #include <linux/types.h> |
| 10 | #include <linux/netfilter.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 11 | #include <linux/slab.h> |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 12 | #include <linux/module.h> |
| 13 | #include <linux/skbuff.h> |
| 14 | #include <linux/proc_fs.h> |
| 15 | #include <linux/seq_file.h> |
| 16 | #include <linux/percpu.h> |
| 17 | #include <linux/netdevice.h> |
Eric W. Biederman | 457c4cb | 2007-09-12 12:01:34 +0200 | [diff] [blame] | 18 | #include <net/net_namespace.h> |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 19 | #ifdef CONFIG_SYSCTL |
| 20 | #include <linux/sysctl.h> |
| 21 | #endif |
| 22 | |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 23 | #include <net/netfilter/nf_conntrack.h> |
Martin Josefsson | f618012 | 2006-11-29 02:35:01 +0100 | [diff] [blame] | 24 | #include <net/netfilter/nf_conntrack_core.h> |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 25 | #include <net/netfilter/nf_conntrack_l3proto.h> |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 26 | #include <net/netfilter/nf_conntrack_l4proto.h> |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 27 | #include <net/netfilter/nf_conntrack_expect.h> |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 28 | #include <net/netfilter/nf_conntrack_helper.h> |
Krzysztof Piotr Oledzki | 5840157 | 2008-07-21 10:01:34 -0700 | [diff] [blame] | 29 | #include <net/netfilter/nf_conntrack_acct.h> |
Patrick McHardy | 5d0aa2c | 2010-02-15 18:13:33 +0100 | [diff] [blame] | 30 | #include <net/netfilter/nf_conntrack_zones.h> |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 31 | |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 32 | MODULE_LICENSE("GPL"); |
| 33 | |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 34 | #ifdef CONFIG_PROC_FS |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 35 | int |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 36 | print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, |
Jan Engelhardt | 3294858 | 2008-01-31 04:53:24 -0800 | [diff] [blame] | 37 | const struct nf_conntrack_l3proto *l3proto, |
| 38 | const struct nf_conntrack_l4proto *l4proto) |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 39 | { |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 40 | return l3proto->print_tuple(s, tuple) || l4proto->print_tuple(s, tuple); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 41 | } |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 42 | EXPORT_SYMBOL_GPL(print_tuple); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 43 | |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 44 | struct ct_iter_state { |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 45 | struct seq_net_private p; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 46 | unsigned int bucket; |
| 47 | }; |
| 48 | |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 49 | static struct hlist_nulls_node *ct_get_first(struct seq_file *seq) |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 50 | { |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 51 | struct net *net = seq_file_net(seq); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 52 | struct ct_iter_state *st = seq->private; |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 53 | struct hlist_nulls_node *n; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 54 | |
| 55 | for (st->bucket = 0; |
Patrick McHardy | d696c7b | 2010-02-08 11:18:07 -0800 | [diff] [blame] | 56 | st->bucket < net->ct.htable_size; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 57 | st->bucket++) { |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 58 | n = rcu_dereference(net->ct.hash[st->bucket].first); |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 59 | if (!is_a_nulls(n)) |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 60 | return n; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 61 | } |
| 62 | return NULL; |
| 63 | } |
| 64 | |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 65 | static struct hlist_nulls_node *ct_get_next(struct seq_file *seq, |
| 66 | struct hlist_nulls_node *head) |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 67 | { |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 68 | struct net *net = seq_file_net(seq); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 69 | struct ct_iter_state *st = seq->private; |
| 70 | |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 71 | head = rcu_dereference(head->next); |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 72 | while (is_a_nulls(head)) { |
| 73 | if (likely(get_nulls_value(head) == st->bucket)) { |
Patrick McHardy | d696c7b | 2010-02-08 11:18:07 -0800 | [diff] [blame] | 74 | if (++st->bucket >= net->ct.htable_size) |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 75 | return NULL; |
| 76 | } |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 77 | head = rcu_dereference(net->ct.hash[st->bucket].first); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 78 | } |
| 79 | return head; |
| 80 | } |
| 81 | |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 82 | static struct hlist_nulls_node *ct_get_idx(struct seq_file *seq, loff_t pos) |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 83 | { |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 84 | struct hlist_nulls_node *head = ct_get_first(seq); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 85 | |
| 86 | if (head) |
| 87 | while (pos && (head = ct_get_next(seq, head))) |
| 88 | pos--; |
| 89 | return pos ? NULL : head; |
| 90 | } |
| 91 | |
| 92 | static void *ct_seq_start(struct seq_file *seq, loff_t *pos) |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 93 | __acquires(RCU) |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 94 | { |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 95 | rcu_read_lock(); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 96 | return ct_get_idx(seq, *pos); |
| 97 | } |
| 98 | |
| 99 | static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos) |
| 100 | { |
| 101 | (*pos)++; |
| 102 | return ct_get_next(s, v); |
| 103 | } |
| 104 | |
| 105 | static void ct_seq_stop(struct seq_file *s, void *v) |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 106 | __releases(RCU) |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 107 | { |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 108 | rcu_read_unlock(); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | /* return 0 on success, 1 in case of error */ |
| 112 | static int ct_seq_show(struct seq_file *s, void *v) |
| 113 | { |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 114 | struct nf_conntrack_tuple_hash *hash = v; |
| 115 | struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(hash); |
Jan Engelhardt | 3294858 | 2008-01-31 04:53:24 -0800 | [diff] [blame] | 116 | const struct nf_conntrack_l3proto *l3proto; |
| 117 | const struct nf_conntrack_l4proto *l4proto; |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 118 | int ret = 0; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 119 | |
Patrick McHardy | c88130b | 2008-01-31 04:42:11 -0800 | [diff] [blame] | 120 | NF_CT_ASSERT(ct); |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 121 | if (unlikely(!atomic_inc_not_zero(&ct->ct_general.use))) |
| 122 | return 0; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 123 | |
| 124 | /* we only want to print DIR_ORIGINAL */ |
| 125 | if (NF_CT_DIRECTION(hash)) |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 126 | goto release; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 127 | |
Patrick McHardy | 5e8fbe2 | 2008-04-14 11:15:52 +0200 | [diff] [blame] | 128 | l3proto = __nf_ct_l3proto_find(nf_ct_l3num(ct)); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 129 | NF_CT_ASSERT(l3proto); |
Patrick McHardy | 5e8fbe2 | 2008-04-14 11:15:52 +0200 | [diff] [blame] | 130 | l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct)); |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 131 | NF_CT_ASSERT(l4proto); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 132 | |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 133 | ret = -ENOSPC; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 134 | if (seq_printf(s, "%-8s %u %-8s %u %ld ", |
Patrick McHardy | 5e8fbe2 | 2008-04-14 11:15:52 +0200 | [diff] [blame] | 135 | l3proto->name, nf_ct_l3num(ct), |
| 136 | l4proto->name, nf_ct_protonum(ct), |
Patrick McHardy | c88130b | 2008-01-31 04:42:11 -0800 | [diff] [blame] | 137 | timer_pending(&ct->timeout) |
| 138 | ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0) |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 139 | goto release; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 140 | |
Patrick McHardy | c88130b | 2008-01-31 04:42:11 -0800 | [diff] [blame] | 141 | if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct)) |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 142 | goto release; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 143 | |
Patrick McHardy | c88130b | 2008-01-31 04:42:11 -0800 | [diff] [blame] | 144 | if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 145 | l3proto, l4proto)) |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 146 | goto release; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 147 | |
Krzysztof Piotr Oledzki | 5840157 | 2008-07-21 10:01:34 -0700 | [diff] [blame] | 148 | if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL)) |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 149 | goto release; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 150 | |
Patrick McHardy | c88130b | 2008-01-31 04:42:11 -0800 | [diff] [blame] | 151 | if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status))) |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 152 | if (seq_printf(s, "[UNREPLIED] ")) |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 153 | goto release; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 154 | |
Patrick McHardy | c88130b | 2008-01-31 04:42:11 -0800 | [diff] [blame] | 155 | if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 156 | l3proto, l4proto)) |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 157 | goto release; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 158 | |
Krzysztof Piotr Oledzki | 5840157 | 2008-07-21 10:01:34 -0700 | [diff] [blame] | 159 | if (seq_print_acct(s, ct, IP_CT_DIR_REPLY)) |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 160 | goto release; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 161 | |
Patrick McHardy | c88130b | 2008-01-31 04:42:11 -0800 | [diff] [blame] | 162 | if (test_bit(IPS_ASSURED_BIT, &ct->status)) |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 163 | if (seq_printf(s, "[ASSURED] ")) |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 164 | goto release; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 165 | |
| 166 | #if defined(CONFIG_NF_CONNTRACK_MARK) |
Patrick McHardy | c88130b | 2008-01-31 04:42:11 -0800 | [diff] [blame] | 167 | if (seq_printf(s, "mark=%u ", ct->mark)) |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 168 | goto release; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 169 | #endif |
| 170 | |
James Morris | 7c9728c | 2006-06-09 00:31:46 -0700 | [diff] [blame] | 171 | #ifdef CONFIG_NF_CONNTRACK_SECMARK |
Patrick McHardy | c88130b | 2008-01-31 04:42:11 -0800 | [diff] [blame] | 172 | if (seq_printf(s, "secmark=%u ", ct->secmark)) |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 173 | goto release; |
James Morris | 7c9728c | 2006-06-09 00:31:46 -0700 | [diff] [blame] | 174 | #endif |
| 175 | |
Patrick McHardy | 5d0aa2c | 2010-02-15 18:13:33 +0100 | [diff] [blame] | 176 | #ifdef CONFIG_NF_CONNTRACK_ZONES |
| 177 | if (seq_printf(s, "zone=%u ", nf_ct_zone(ct))) |
| 178 | goto release; |
| 179 | #endif |
| 180 | |
Patrick McHardy | c88130b | 2008-01-31 04:42:11 -0800 | [diff] [blame] | 181 | if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use))) |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 182 | goto release; |
YOSHIFUJI Hideaki | a5d2926 | 2007-07-19 10:44:21 +0900 | [diff] [blame] | 183 | |
Eric Dumazet | ea781f1 | 2009-03-25 21:05:46 +0100 | [diff] [blame] | 184 | ret = 0; |
| 185 | release: |
| 186 | nf_ct_put(ct); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 187 | return 0; |
| 188 | } |
| 189 | |
Philippe De Muyter | 56b3d97 | 2007-07-10 23:07:31 -0700 | [diff] [blame] | 190 | static const struct seq_operations ct_seq_ops = { |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 191 | .start = ct_seq_start, |
| 192 | .next = ct_seq_next, |
| 193 | .stop = ct_seq_stop, |
| 194 | .show = ct_seq_show |
| 195 | }; |
| 196 | |
| 197 | static int ct_open(struct inode *inode, struct file *file) |
| 198 | { |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 199 | return seq_open_net(inode, file, &ct_seq_ops, |
Pavel Emelyanov | e2da591 | 2007-10-10 02:29:58 -0700 | [diff] [blame] | 200 | sizeof(struct ct_iter_state)); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 201 | } |
| 202 | |
Arjan van de Ven | da7071d | 2007-02-12 00:55:36 -0800 | [diff] [blame] | 203 | static const struct file_operations ct_file_ops = { |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 204 | .owner = THIS_MODULE, |
| 205 | .open = ct_open, |
| 206 | .read = seq_read, |
| 207 | .llseek = seq_lseek, |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 208 | .release = seq_release_net, |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 209 | }; |
| 210 | |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 211 | static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos) |
| 212 | { |
Alexey Dobriyan | 8e9df80 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 213 | struct net *net = seq_file_net(seq); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 214 | int cpu; |
| 215 | |
| 216 | if (*pos == 0) |
| 217 | return SEQ_START_TOKEN; |
| 218 | |
Rusty Russell | 0f23174a | 2008-12-29 12:23:42 +0000 | [diff] [blame] | 219 | for (cpu = *pos-1; cpu < nr_cpu_ids; ++cpu) { |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 220 | if (!cpu_possible(cpu)) |
| 221 | continue; |
| 222 | *pos = cpu + 1; |
Alexey Dobriyan | 8e9df80 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 223 | return per_cpu_ptr(net->ct.stat, cpu); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | return NULL; |
| 227 | } |
| 228 | |
| 229 | static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
| 230 | { |
Alexey Dobriyan | 8e9df80 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 231 | struct net *net = seq_file_net(seq); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 232 | int cpu; |
| 233 | |
Rusty Russell | 0f23174a | 2008-12-29 12:23:42 +0000 | [diff] [blame] | 234 | for (cpu = *pos; cpu < nr_cpu_ids; ++cpu) { |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 235 | if (!cpu_possible(cpu)) |
| 236 | continue; |
| 237 | *pos = cpu + 1; |
Alexey Dobriyan | 8e9df80 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 238 | return per_cpu_ptr(net->ct.stat, cpu); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | return NULL; |
| 242 | } |
| 243 | |
| 244 | static void ct_cpu_seq_stop(struct seq_file *seq, void *v) |
| 245 | { |
| 246 | } |
| 247 | |
| 248 | static int ct_cpu_seq_show(struct seq_file *seq, void *v) |
| 249 | { |
Alexey Dobriyan | 8e9df80 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 250 | struct net *net = seq_file_net(seq); |
| 251 | unsigned int nr_conntracks = atomic_read(&net->ct.count); |
Jan Engelhardt | 3294858 | 2008-01-31 04:53:24 -0800 | [diff] [blame] | 252 | const struct ip_conntrack_stat *st = v; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 253 | |
| 254 | if (v == SEQ_START_TOKEN) { |
| 255 | 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"); |
| 256 | return 0; |
| 257 | } |
| 258 | |
| 259 | seq_printf(seq, "%08x %08x %08x %08x %08x %08x %08x %08x " |
| 260 | "%08x %08x %08x %08x %08x %08x %08x %08x \n", |
| 261 | nr_conntracks, |
| 262 | st->searched, |
| 263 | st->found, |
| 264 | st->new, |
| 265 | st->invalid, |
| 266 | st->ignore, |
| 267 | st->delete, |
| 268 | st->delete_list, |
| 269 | st->insert, |
| 270 | st->insert_failed, |
| 271 | st->drop, |
| 272 | st->early_drop, |
| 273 | st->error, |
| 274 | |
| 275 | st->expect_new, |
| 276 | st->expect_create, |
| 277 | st->expect_delete |
| 278 | ); |
| 279 | return 0; |
| 280 | } |
| 281 | |
Philippe De Muyter | 56b3d97 | 2007-07-10 23:07:31 -0700 | [diff] [blame] | 282 | static const struct seq_operations ct_cpu_seq_ops = { |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 283 | .start = ct_cpu_seq_start, |
| 284 | .next = ct_cpu_seq_next, |
| 285 | .stop = ct_cpu_seq_stop, |
| 286 | .show = ct_cpu_seq_show, |
| 287 | }; |
| 288 | |
| 289 | static int ct_cpu_seq_open(struct inode *inode, struct file *file) |
| 290 | { |
Alexey Dobriyan | 8e9df80 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 291 | return seq_open_net(inode, file, &ct_cpu_seq_ops, |
| 292 | sizeof(struct seq_net_private)); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 293 | } |
| 294 | |
Arjan van de Ven | da7071d | 2007-02-12 00:55:36 -0800 | [diff] [blame] | 295 | static const struct file_operations ct_cpu_seq_fops = { |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 296 | .owner = THIS_MODULE, |
| 297 | .open = ct_cpu_seq_open, |
| 298 | .read = seq_read, |
| 299 | .llseek = seq_lseek, |
Alexey Dobriyan | 8e9df80 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 300 | .release = seq_release_net, |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 301 | }; |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 302 | |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 303 | static int nf_conntrack_standalone_init_proc(struct net *net) |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 304 | { |
| 305 | struct proc_dir_entry *pde; |
| 306 | |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 307 | pde = proc_net_fops_create(net, "nf_conntrack", 0440, &ct_file_ops); |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 308 | if (!pde) |
| 309 | goto out_nf_conntrack; |
Denis V. Lunev | 52c0e11 | 2008-05-02 04:10:57 -0700 | [diff] [blame] | 310 | |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 311 | pde = proc_create("nf_conntrack", S_IRUGO, net->proc_net_stat, |
Denis V. Lunev | 52c0e11 | 2008-05-02 04:10:57 -0700 | [diff] [blame] | 312 | &ct_cpu_seq_fops); |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 313 | if (!pde) |
| 314 | goto out_stat_nf_conntrack; |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 315 | return 0; |
| 316 | |
| 317 | out_stat_nf_conntrack: |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 318 | proc_net_remove(net, "nf_conntrack"); |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 319 | out_nf_conntrack: |
| 320 | return -ENOMEM; |
| 321 | } |
| 322 | |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 323 | static void nf_conntrack_standalone_fini_proc(struct net *net) |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 324 | { |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 325 | remove_proc_entry("nf_conntrack", net->proc_net_stat); |
| 326 | proc_net_remove(net, "nf_conntrack"); |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 327 | } |
| 328 | #else |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 329 | static int nf_conntrack_standalone_init_proc(struct net *net) |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 330 | { |
| 331 | return 0; |
| 332 | } |
| 333 | |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 334 | static void nf_conntrack_standalone_fini_proc(struct net *net) |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 335 | { |
| 336 | } |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 337 | #endif /* CONFIG_PROC_FS */ |
| 338 | |
| 339 | /* Sysctl support */ |
| 340 | |
| 341 | #ifdef CONFIG_SYSCTL |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 342 | /* Log invalid packets of a given protocol */ |
| 343 | static int log_invalid_proto_min = 0; |
| 344 | static int log_invalid_proto_max = 255; |
| 345 | |
Krzysztof Piotr Oledzki | 9714be7 | 2008-08-06 02:35:44 -0700 | [diff] [blame] | 346 | static struct ctl_table_header *nf_ct_netfilter_header; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 347 | |
| 348 | static ctl_table nf_ct_sysctl_table[] = { |
| 349 | { |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 350 | .procname = "nf_conntrack_max", |
| 351 | .data = &nf_conntrack_max, |
| 352 | .maxlen = sizeof(int), |
| 353 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 354 | .proc_handler = proc_dointvec, |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 355 | }, |
| 356 | { |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 357 | .procname = "nf_conntrack_count", |
Alexey Dobriyan | 49ac871 | 2008-10-08 11:35:03 +0200 | [diff] [blame] | 358 | .data = &init_net.ct.count, |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 359 | .maxlen = sizeof(int), |
| 360 | .mode = 0444, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 361 | .proc_handler = proc_dointvec, |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 362 | }, |
| 363 | { |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 364 | .procname = "nf_conntrack_buckets", |
Patrick McHardy | d696c7b | 2010-02-08 11:18:07 -0800 | [diff] [blame] | 365 | .data = &init_net.ct.htable_size, |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 366 | .maxlen = sizeof(unsigned int), |
| 367 | .mode = 0444, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 368 | .proc_handler = proc_dointvec, |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 369 | }, |
| 370 | { |
Patrick McHardy | 39a27a3 | 2006-05-29 18:23:54 -0700 | [diff] [blame] | 371 | .procname = "nf_conntrack_checksum", |
Alexey Dobriyan | c04d055 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 372 | .data = &init_net.ct.sysctl_checksum, |
Patrick McHardy | 39a27a3 | 2006-05-29 18:23:54 -0700 | [diff] [blame] | 373 | .maxlen = sizeof(unsigned int), |
| 374 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 375 | .proc_handler = proc_dointvec, |
Patrick McHardy | 39a27a3 | 2006-05-29 18:23:54 -0700 | [diff] [blame] | 376 | }, |
| 377 | { |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 378 | .procname = "nf_conntrack_log_invalid", |
Alexey Dobriyan | c2a2c7e | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 379 | .data = &init_net.ct.sysctl_log_invalid, |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 380 | .maxlen = sizeof(unsigned int), |
| 381 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 382 | .proc_handler = proc_dointvec_minmax, |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 383 | .extra1 = &log_invalid_proto_min, |
| 384 | .extra2 = &log_invalid_proto_max, |
| 385 | }, |
Patrick McHardy | f264a7d | 2007-07-07 22:36:24 -0700 | [diff] [blame] | 386 | { |
Patrick McHardy | f264a7d | 2007-07-07 22:36:24 -0700 | [diff] [blame] | 387 | .procname = "nf_conntrack_expect_max", |
| 388 | .data = &nf_ct_expect_max, |
| 389 | .maxlen = sizeof(int), |
| 390 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 391 | .proc_handler = proc_dointvec, |
Patrick McHardy | f264a7d | 2007-07-07 22:36:24 -0700 | [diff] [blame] | 392 | }, |
Eric W. Biederman | f8572d8 | 2009-11-05 13:32:03 -0800 | [diff] [blame] | 393 | { } |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 394 | }; |
| 395 | |
| 396 | #define NET_NF_CONNTRACK_MAX 2089 |
| 397 | |
| 398 | static ctl_table nf_ct_netfilter_table[] = { |
| 399 | { |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 400 | .procname = "nf_conntrack_max", |
| 401 | .data = &nf_conntrack_max, |
| 402 | .maxlen = sizeof(int), |
| 403 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 404 | .proc_handler = proc_dointvec, |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 405 | }, |
Eric W. Biederman | f8572d8 | 2009-11-05 13:32:03 -0800 | [diff] [blame] | 406 | { } |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 407 | }; |
| 408 | |
Patrick McHardy | 9e23249 | 2008-01-31 04:54:45 -0800 | [diff] [blame] | 409 | static struct ctl_path nf_ct_path[] = { |
Eric W. Biederman | f8572d8 | 2009-11-05 13:32:03 -0800 | [diff] [blame] | 410 | { .procname = "net", }, |
Pavel Emelyanov | 3d7cc2b | 2008-01-09 00:33:11 -0800 | [diff] [blame] | 411 | { } |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 412 | }; |
Pavel Emelyanov | 3d7cc2b | 2008-01-09 00:33:11 -0800 | [diff] [blame] | 413 | |
Alexey Dobriyan | 8025070 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 414 | static int nf_conntrack_standalone_init_sysctl(struct net *net) |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 415 | { |
Alexey Dobriyan | 8025070 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 416 | struct ctl_table *table; |
Krzysztof Piotr Oledzki | 9714be7 | 2008-08-06 02:35:44 -0700 | [diff] [blame] | 417 | |
Alexey Dobriyan | 8025070 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 418 | if (net_eq(net, &init_net)) { |
| 419 | nf_ct_netfilter_header = |
| 420 | register_sysctl_paths(nf_ct_path, nf_ct_netfilter_table); |
| 421 | if (!nf_ct_netfilter_header) |
| 422 | goto out; |
| 423 | } |
| 424 | |
| 425 | table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table), |
| 426 | GFP_KERNEL); |
| 427 | if (!table) |
| 428 | goto out_kmemdup; |
| 429 | |
| 430 | table[1].data = &net->ct.count; |
Patrick McHardy | d696c7b | 2010-02-08 11:18:07 -0800 | [diff] [blame] | 431 | table[2].data = &net->ct.htable_size; |
Alexey Dobriyan | c04d055 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 432 | table[3].data = &net->ct.sysctl_checksum; |
Alexey Dobriyan | c2a2c7e | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 433 | table[4].data = &net->ct.sysctl_log_invalid; |
Alexey Dobriyan | 8025070 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 434 | |
| 435 | net->ct.sysctl_header = register_net_sysctl_table(net, |
| 436 | nf_net_netfilter_sysctl_path, table); |
| 437 | if (!net->ct.sysctl_header) |
Krzysztof Piotr Oledzki | 9714be7 | 2008-08-06 02:35:44 -0700 | [diff] [blame] | 438 | goto out_unregister_netfilter; |
| 439 | |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 440 | return 0; |
| 441 | |
Krzysztof Piotr Oledzki | 9714be7 | 2008-08-06 02:35:44 -0700 | [diff] [blame] | 442 | out_unregister_netfilter: |
Alexey Dobriyan | 8025070 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 443 | kfree(table); |
| 444 | out_kmemdup: |
| 445 | if (net_eq(net, &init_net)) |
| 446 | unregister_sysctl_table(nf_ct_netfilter_header); |
Krzysztof Piotr Oledzki | 9714be7 | 2008-08-06 02:35:44 -0700 | [diff] [blame] | 447 | out: |
| 448 | printk("nf_conntrack: can't register to sysctl.\n"); |
| 449 | return -ENOMEM; |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 450 | } |
| 451 | |
Alexey Dobriyan | 8025070 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 452 | static void nf_conntrack_standalone_fini_sysctl(struct net *net) |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 453 | { |
Alexey Dobriyan | 8025070 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 454 | struct ctl_table *table; |
| 455 | |
| 456 | if (net_eq(net, &init_net)) |
| 457 | unregister_sysctl_table(nf_ct_netfilter_header); |
| 458 | table = net->ct.sysctl_header->ctl_table_arg; |
| 459 | unregister_net_sysctl_table(net->ct.sysctl_header); |
| 460 | kfree(table); |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 461 | } |
| 462 | #else |
Alexey Dobriyan | 8025070 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 463 | static int nf_conntrack_standalone_init_sysctl(struct net *net) |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 464 | { |
| 465 | return 0; |
| 466 | } |
| 467 | |
Alexey Dobriyan | 8025070 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 468 | static void nf_conntrack_standalone_fini_sysctl(struct net *net) |
Alexey Dobriyan | b916f7d | 2008-03-20 15:15:43 +0100 | [diff] [blame] | 469 | { |
| 470 | } |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 471 | #endif /* CONFIG_SYSCTL */ |
| 472 | |
Alexey Dobriyan | dfdb8d7 | 2008-10-08 11:35:02 +0200 | [diff] [blame] | 473 | static int nf_conntrack_net_init(struct net *net) |
| 474 | { |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 475 | int ret; |
| 476 | |
| 477 | ret = nf_conntrack_init(net); |
| 478 | if (ret < 0) |
| 479 | goto out_init; |
| 480 | ret = nf_conntrack_standalone_init_proc(net); |
| 481 | if (ret < 0) |
| 482 | goto out_proc; |
Alexey Dobriyan | c04d055 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 483 | net->ct.sysctl_checksum = 1; |
Alexey Dobriyan | c2a2c7e | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 484 | net->ct.sysctl_log_invalid = 0; |
Alexey Dobriyan | 8025070 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 485 | ret = nf_conntrack_standalone_init_sysctl(net); |
| 486 | if (ret < 0) |
| 487 | goto out_sysctl; |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 488 | return 0; |
| 489 | |
Alexey Dobriyan | 8025070 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 490 | out_sysctl: |
| 491 | nf_conntrack_standalone_fini_proc(net); |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 492 | out_proc: |
| 493 | nf_conntrack_cleanup(net); |
| 494 | out_init: |
| 495 | return ret; |
Alexey Dobriyan | dfdb8d7 | 2008-10-08 11:35:02 +0200 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | static void nf_conntrack_net_exit(struct net *net) |
| 499 | { |
Alexey Dobriyan | 8025070 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 500 | nf_conntrack_standalone_fini_sysctl(net); |
Alexey Dobriyan | b2ce2c7 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 501 | nf_conntrack_standalone_fini_proc(net); |
Alexey Dobriyan | dfdb8d7 | 2008-10-08 11:35:02 +0200 | [diff] [blame] | 502 | nf_conntrack_cleanup(net); |
| 503 | } |
| 504 | |
| 505 | static struct pernet_operations nf_conntrack_net_ops = { |
| 506 | .init = nf_conntrack_net_init, |
| 507 | .exit = nf_conntrack_net_exit, |
| 508 | }; |
| 509 | |
Andrew Morton | 65b4b4e | 2006-03-28 16:37:06 -0800 | [diff] [blame] | 510 | static int __init nf_conntrack_standalone_init(void) |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 511 | { |
Alexey Dobriyan | 8025070 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 512 | return register_pernet_subsys(&nf_conntrack_net_ops); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 513 | } |
| 514 | |
Andrew Morton | 65b4b4e | 2006-03-28 16:37:06 -0800 | [diff] [blame] | 515 | static void __exit nf_conntrack_standalone_fini(void) |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 516 | { |
Alexey Dobriyan | dfdb8d7 | 2008-10-08 11:35:02 +0200 | [diff] [blame] | 517 | unregister_pernet_subsys(&nf_conntrack_net_ops); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 518 | } |
| 519 | |
Andrew Morton | 65b4b4e | 2006-03-28 16:37:06 -0800 | [diff] [blame] | 520 | module_init(nf_conntrack_standalone_init); |
| 521 | module_exit(nf_conntrack_standalone_fini); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 522 | |
| 523 | /* Some modules need us, but don't depend directly on any symbol. |
| 524 | They should call this. */ |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 525 | void need_conntrack(void) |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 526 | { |
| 527 | } |
Patrick McHardy | 13b1833 | 2006-12-02 22:11:25 -0800 | [diff] [blame] | 528 | EXPORT_SYMBOL_GPL(need_conntrack); |