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