Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 1 | /* ip_conntrack proc compat - based on ip_conntrack_standalone.c |
| 2 | * |
| 3 | * (C) 1999-2001 Paul `Rusty' Russell |
| 4 | * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | #include <linux/types.h> |
| 11 | #include <linux/proc_fs.h> |
| 12 | #include <linux/seq_file.h> |
| 13 | #include <linux/percpu.h> |
Eric W. Biederman | 457c4cb | 2007-09-12 12:01:34 +0200 | [diff] [blame] | 14 | #include <net/net_namespace.h> |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 15 | |
| 16 | #include <linux/netfilter.h> |
| 17 | #include <net/netfilter/nf_conntrack_core.h> |
| 18 | #include <net/netfilter/nf_conntrack_l3proto.h> |
| 19 | #include <net/netfilter/nf_conntrack_l4proto.h> |
| 20 | #include <net/netfilter/nf_conntrack_expect.h> |
Krzysztof Piotr Oledzki | 5840157 | 2008-07-21 10:01:34 -0700 | [diff] [blame] | 21 | #include <net/netfilter/nf_conntrack_acct.h> |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 22 | |
| 23 | struct ct_iter_state { |
| 24 | unsigned int bucket; |
| 25 | }; |
| 26 | |
Patrick McHardy | f205c5e | 2007-07-07 22:28:14 -0700 | [diff] [blame] | 27 | static struct hlist_node *ct_get_first(struct seq_file *seq) |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 28 | { |
| 29 | struct ct_iter_state *st = seq->private; |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 30 | struct hlist_node *n; |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 31 | |
| 32 | for (st->bucket = 0; |
| 33 | st->bucket < nf_conntrack_htable_size; |
| 34 | st->bucket++) { |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 35 | n = rcu_dereference(nf_conntrack_hash[st->bucket].first); |
| 36 | if (n) |
| 37 | return n; |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 38 | } |
| 39 | return NULL; |
| 40 | } |
| 41 | |
Patrick McHardy | f205c5e | 2007-07-07 22:28:14 -0700 | [diff] [blame] | 42 | static struct hlist_node *ct_get_next(struct seq_file *seq, |
| 43 | struct hlist_node *head) |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 44 | { |
| 45 | struct ct_iter_state *st = seq->private; |
| 46 | |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 47 | head = rcu_dereference(head->next); |
Patrick McHardy | f205c5e | 2007-07-07 22:28:14 -0700 | [diff] [blame] | 48 | while (head == NULL) { |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 49 | if (++st->bucket >= nf_conntrack_htable_size) |
| 50 | return NULL; |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 51 | head = rcu_dereference(nf_conntrack_hash[st->bucket].first); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 52 | } |
| 53 | return head; |
| 54 | } |
| 55 | |
Patrick McHardy | f205c5e | 2007-07-07 22:28:14 -0700 | [diff] [blame] | 56 | static struct hlist_node *ct_get_idx(struct seq_file *seq, loff_t pos) |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 57 | { |
Patrick McHardy | f205c5e | 2007-07-07 22:28:14 -0700 | [diff] [blame] | 58 | struct hlist_node *head = ct_get_first(seq); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 59 | |
| 60 | if (head) |
| 61 | while (pos && (head = ct_get_next(seq, head))) |
| 62 | pos--; |
| 63 | return pos ? NULL : head; |
| 64 | } |
| 65 | |
| 66 | static void *ct_seq_start(struct seq_file *seq, loff_t *pos) |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 67 | __acquires(RCU) |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 68 | { |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 69 | rcu_read_lock(); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 70 | return ct_get_idx(seq, *pos); |
| 71 | } |
| 72 | |
| 73 | static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos) |
| 74 | { |
| 75 | (*pos)++; |
| 76 | return ct_get_next(s, v); |
| 77 | } |
| 78 | |
| 79 | static void ct_seq_stop(struct seq_file *s, void *v) |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 80 | __releases(RCU) |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 81 | { |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 82 | rcu_read_unlock(); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | static int ct_seq_show(struct seq_file *s, void *v) |
| 86 | { |
| 87 | const struct nf_conntrack_tuple_hash *hash = v; |
| 88 | const struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(hash); |
Jan Engelhardt | 3294858 | 2008-01-31 04:53:24 -0800 | [diff] [blame] | 89 | const struct nf_conntrack_l3proto *l3proto; |
| 90 | const struct nf_conntrack_l4proto *l4proto; |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 91 | |
| 92 | NF_CT_ASSERT(ct); |
| 93 | |
| 94 | /* we only want to print DIR_ORIGINAL */ |
| 95 | if (NF_CT_DIRECTION(hash)) |
| 96 | return 0; |
Patrick McHardy | 5e8fbe2 | 2008-04-14 11:15:52 +0200 | [diff] [blame] | 97 | if (nf_ct_l3num(ct) != AF_INET) |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 98 | return 0; |
| 99 | |
Patrick McHardy | 5e8fbe2 | 2008-04-14 11:15:52 +0200 | [diff] [blame] | 100 | l3proto = __nf_ct_l3proto_find(nf_ct_l3num(ct)); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 101 | NF_CT_ASSERT(l3proto); |
Patrick McHardy | 5e8fbe2 | 2008-04-14 11:15:52 +0200 | [diff] [blame] | 102 | l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct)); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 103 | NF_CT_ASSERT(l4proto); |
| 104 | |
| 105 | if (seq_printf(s, "%-8s %u %ld ", |
Patrick McHardy | 5e8fbe2 | 2008-04-14 11:15:52 +0200 | [diff] [blame] | 106 | l4proto->name, nf_ct_protonum(ct), |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 107 | timer_pending(&ct->timeout) |
| 108 | ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0) |
| 109 | return -ENOSPC; |
| 110 | |
Patrick McHardy | c71e916 | 2008-01-14 23:49:37 -0800 | [diff] [blame] | 111 | if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct)) |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 112 | return -ENOSPC; |
| 113 | |
| 114 | if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, |
| 115 | l3proto, l4proto)) |
| 116 | return -ENOSPC; |
| 117 | |
Krzysztof Piotr Oledzki | 5840157 | 2008-07-21 10:01:34 -0700 | [diff] [blame] | 118 | if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL)) |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 119 | return -ENOSPC; |
| 120 | |
| 121 | if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status))) |
| 122 | if (seq_printf(s, "[UNREPLIED] ")) |
| 123 | return -ENOSPC; |
| 124 | |
| 125 | if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, |
| 126 | l3proto, l4proto)) |
| 127 | return -ENOSPC; |
| 128 | |
Krzysztof Piotr Oledzki | 5840157 | 2008-07-21 10:01:34 -0700 | [diff] [blame] | 129 | if (seq_print_acct(s, ct, IP_CT_DIR_REPLY)) |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 130 | return -ENOSPC; |
| 131 | |
| 132 | if (test_bit(IPS_ASSURED_BIT, &ct->status)) |
| 133 | if (seq_printf(s, "[ASSURED] ")) |
| 134 | return -ENOSPC; |
| 135 | |
| 136 | #ifdef CONFIG_NF_CONNTRACK_MARK |
| 137 | if (seq_printf(s, "mark=%u ", ct->mark)) |
| 138 | return -ENOSPC; |
| 139 | #endif |
| 140 | |
| 141 | #ifdef CONFIG_NF_CONNTRACK_SECMARK |
| 142 | if (seq_printf(s, "secmark=%u ", ct->secmark)) |
| 143 | return -ENOSPC; |
| 144 | #endif |
| 145 | |
| 146 | if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use))) |
| 147 | return -ENOSPC; |
| 148 | |
| 149 | return 0; |
| 150 | } |
| 151 | |
Philippe De Muyter | 56b3d97 | 2007-07-10 23:07:31 -0700 | [diff] [blame] | 152 | static const struct seq_operations ct_seq_ops = { |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 153 | .start = ct_seq_start, |
| 154 | .next = ct_seq_next, |
| 155 | .stop = ct_seq_stop, |
| 156 | .show = ct_seq_show |
| 157 | }; |
| 158 | |
| 159 | static int ct_open(struct inode *inode, struct file *file) |
| 160 | { |
Pavel Emelyanov | e2da591 | 2007-10-10 02:29:58 -0700 | [diff] [blame] | 161 | return seq_open_private(file, &ct_seq_ops, |
| 162 | sizeof(struct ct_iter_state)); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 163 | } |
| 164 | |
Arjan van de Ven | 9a32144 | 2007-02-12 00:55:35 -0800 | [diff] [blame] | 165 | static const struct file_operations ct_file_ops = { |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 166 | .owner = THIS_MODULE, |
| 167 | .open = ct_open, |
| 168 | .read = seq_read, |
| 169 | .llseek = seq_lseek, |
| 170 | .release = seq_release_private, |
| 171 | }; |
| 172 | |
| 173 | /* expects */ |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 174 | struct ct_expect_iter_state { |
| 175 | unsigned int bucket; |
| 176 | }; |
| 177 | |
| 178 | static struct hlist_node *ct_expect_get_first(struct seq_file *seq) |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 179 | { |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 180 | struct ct_expect_iter_state *st = seq->private; |
Patrick McHardy | 7d0742d | 2008-01-31 04:38:19 -0800 | [diff] [blame] | 181 | struct hlist_node *n; |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 182 | |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 183 | for (st->bucket = 0; st->bucket < nf_ct_expect_hsize; st->bucket++) { |
Patrick McHardy | 7d0742d | 2008-01-31 04:38:19 -0800 | [diff] [blame] | 184 | n = rcu_dereference(nf_ct_expect_hash[st->bucket].first); |
| 185 | if (n) |
| 186 | return n; |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 187 | } |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 188 | return NULL; |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 189 | } |
| 190 | |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 191 | static struct hlist_node *ct_expect_get_next(struct seq_file *seq, |
| 192 | struct hlist_node *head) |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 193 | { |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 194 | struct ct_expect_iter_state *st = seq->private; |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 195 | |
Patrick McHardy | 7d0742d | 2008-01-31 04:38:19 -0800 | [diff] [blame] | 196 | head = rcu_dereference(head->next); |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 197 | while (head == NULL) { |
| 198 | if (++st->bucket >= nf_ct_expect_hsize) |
| 199 | return NULL; |
Patrick McHardy | 7d0742d | 2008-01-31 04:38:19 -0800 | [diff] [blame] | 200 | head = rcu_dereference(nf_ct_expect_hash[st->bucket].first); |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 201 | } |
| 202 | return head; |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 203 | } |
| 204 | |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 205 | static struct hlist_node *ct_expect_get_idx(struct seq_file *seq, loff_t pos) |
| 206 | { |
| 207 | struct hlist_node *head = ct_expect_get_first(seq); |
| 208 | |
| 209 | if (head) |
| 210 | while (pos && (head = ct_expect_get_next(seq, head))) |
| 211 | pos--; |
| 212 | return pos ? NULL : head; |
| 213 | } |
| 214 | |
| 215 | static void *exp_seq_start(struct seq_file *seq, loff_t *pos) |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 216 | __acquires(RCU) |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 217 | { |
Patrick McHardy | 7d0742d | 2008-01-31 04:38:19 -0800 | [diff] [blame] | 218 | rcu_read_lock(); |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 219 | return ct_expect_get_idx(seq, *pos); |
| 220 | } |
| 221 | |
| 222 | static void *exp_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
| 223 | { |
| 224 | (*pos)++; |
| 225 | return ct_expect_get_next(seq, v); |
| 226 | } |
| 227 | |
| 228 | static void exp_seq_stop(struct seq_file *seq, void *v) |
Patrick McHardy | 76507f6 | 2008-01-31 04:38:38 -0800 | [diff] [blame] | 229 | __releases(RCU) |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 230 | { |
Patrick McHardy | 7d0742d | 2008-01-31 04:38:19 -0800 | [diff] [blame] | 231 | rcu_read_unlock(); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | static int exp_seq_show(struct seq_file *s, void *v) |
| 235 | { |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 236 | struct nf_conntrack_expect *exp; |
Jan Engelhardt | 3294858 | 2008-01-31 04:53:24 -0800 | [diff] [blame] | 237 | const struct hlist_node *n = v; |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 238 | |
| 239 | exp = hlist_entry(n, struct nf_conntrack_expect, hnode); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 240 | |
| 241 | if (exp->tuple.src.l3num != AF_INET) |
| 242 | return 0; |
| 243 | |
| 244 | if (exp->timeout.function) |
| 245 | seq_printf(s, "%ld ", timer_pending(&exp->timeout) |
| 246 | ? (long)(exp->timeout.expires - jiffies)/HZ : 0); |
| 247 | else |
| 248 | seq_printf(s, "- "); |
| 249 | |
| 250 | seq_printf(s, "proto=%u ", exp->tuple.dst.protonum); |
| 251 | |
| 252 | print_tuple(s, &exp->tuple, |
| 253 | __nf_ct_l3proto_find(exp->tuple.src.l3num), |
| 254 | __nf_ct_l4proto_find(exp->tuple.src.l3num, |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 255 | exp->tuple.dst.protonum)); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 256 | return seq_putc(s, '\n'); |
| 257 | } |
| 258 | |
Philippe De Muyter | 56b3d97 | 2007-07-10 23:07:31 -0700 | [diff] [blame] | 259 | static const struct seq_operations exp_seq_ops = { |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 260 | .start = exp_seq_start, |
| 261 | .next = exp_seq_next, |
| 262 | .stop = exp_seq_stop, |
| 263 | .show = exp_seq_show |
| 264 | }; |
| 265 | |
| 266 | static int exp_open(struct inode *inode, struct file *file) |
| 267 | { |
Pavel Emelyanov | e2da591 | 2007-10-10 02:29:58 -0700 | [diff] [blame] | 268 | return seq_open_private(file, &exp_seq_ops, |
| 269 | sizeof(struct ct_expect_iter_state)); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 270 | } |
| 271 | |
Arjan van de Ven | 9a32144 | 2007-02-12 00:55:35 -0800 | [diff] [blame] | 272 | static const struct file_operations ip_exp_file_ops = { |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 273 | .owner = THIS_MODULE, |
| 274 | .open = exp_open, |
| 275 | .read = seq_read, |
| 276 | .llseek = seq_lseek, |
Patrick McHardy | 5d08ad4 | 2007-07-07 22:34:07 -0700 | [diff] [blame] | 277 | .release = seq_release_private, |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 278 | }; |
| 279 | |
| 280 | static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos) |
| 281 | { |
| 282 | int cpu; |
| 283 | |
| 284 | if (*pos == 0) |
| 285 | return SEQ_START_TOKEN; |
| 286 | |
| 287 | for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) { |
| 288 | if (!cpu_possible(cpu)) |
| 289 | continue; |
| 290 | *pos = cpu+1; |
| 291 | return &per_cpu(nf_conntrack_stat, cpu); |
| 292 | } |
| 293 | |
| 294 | return NULL; |
| 295 | } |
| 296 | |
| 297 | static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
| 298 | { |
| 299 | int cpu; |
| 300 | |
| 301 | for (cpu = *pos; cpu < NR_CPUS; ++cpu) { |
| 302 | if (!cpu_possible(cpu)) |
| 303 | continue; |
| 304 | *pos = cpu+1; |
| 305 | return &per_cpu(nf_conntrack_stat, cpu); |
| 306 | } |
| 307 | |
| 308 | return NULL; |
| 309 | } |
| 310 | |
| 311 | static void ct_cpu_seq_stop(struct seq_file *seq, void *v) |
| 312 | { |
| 313 | } |
| 314 | |
| 315 | static int ct_cpu_seq_show(struct seq_file *seq, void *v) |
| 316 | { |
| 317 | unsigned int nr_conntracks = atomic_read(&nf_conntrack_count); |
Jan Engelhardt | 3294858 | 2008-01-31 04:53:24 -0800 | [diff] [blame] | 318 | const struct ip_conntrack_stat *st = v; |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 319 | |
| 320 | if (v == SEQ_START_TOKEN) { |
| 321 | seq_printf(seq, "entries searched found new invalid ignore delete delete_list insert insert_failed drop early_drop icmp_error expect_new expect_create expect_delete\n"); |
| 322 | return 0; |
| 323 | } |
| 324 | |
| 325 | seq_printf(seq, "%08x %08x %08x %08x %08x %08x %08x %08x " |
| 326 | "%08x %08x %08x %08x %08x %08x %08x %08x \n", |
| 327 | nr_conntracks, |
| 328 | st->searched, |
| 329 | st->found, |
| 330 | st->new, |
| 331 | st->invalid, |
| 332 | st->ignore, |
| 333 | st->delete, |
| 334 | st->delete_list, |
| 335 | st->insert, |
| 336 | st->insert_failed, |
| 337 | st->drop, |
| 338 | st->early_drop, |
| 339 | st->error, |
| 340 | |
| 341 | st->expect_new, |
| 342 | st->expect_create, |
| 343 | st->expect_delete |
| 344 | ); |
| 345 | return 0; |
| 346 | } |
| 347 | |
Philippe De Muyter | 56b3d97 | 2007-07-10 23:07:31 -0700 | [diff] [blame] | 348 | static const struct seq_operations ct_cpu_seq_ops = { |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 349 | .start = ct_cpu_seq_start, |
| 350 | .next = ct_cpu_seq_next, |
| 351 | .stop = ct_cpu_seq_stop, |
| 352 | .show = ct_cpu_seq_show, |
| 353 | }; |
| 354 | |
| 355 | static int ct_cpu_seq_open(struct inode *inode, struct file *file) |
| 356 | { |
| 357 | return seq_open(file, &ct_cpu_seq_ops); |
| 358 | } |
| 359 | |
Arjan van de Ven | 9a32144 | 2007-02-12 00:55:35 -0800 | [diff] [blame] | 360 | static const struct file_operations ct_cpu_seq_fops = { |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 361 | .owner = THIS_MODULE, |
| 362 | .open = ct_cpu_seq_open, |
| 363 | .read = seq_read, |
| 364 | .llseek = seq_lseek, |
Pavel Emelyanov | 665bba1 | 2008-02-29 11:39:17 -0800 | [diff] [blame] | 365 | .release = seq_release, |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 366 | }; |
| 367 | |
| 368 | int __init nf_conntrack_ipv4_compat_init(void) |
| 369 | { |
| 370 | struct proc_dir_entry *proc, *proc_exp, *proc_stat; |
| 371 | |
Eric W. Biederman | 457c4cb | 2007-09-12 12:01:34 +0200 | [diff] [blame] | 372 | proc = proc_net_fops_create(&init_net, "ip_conntrack", 0440, &ct_file_ops); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 373 | if (!proc) |
| 374 | goto err1; |
| 375 | |
Eric W. Biederman | 457c4cb | 2007-09-12 12:01:34 +0200 | [diff] [blame] | 376 | proc_exp = proc_net_fops_create(&init_net, "ip_conntrack_expect", 0440, |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 377 | &ip_exp_file_ops); |
| 378 | if (!proc_exp) |
| 379 | goto err2; |
| 380 | |
Denis V. Lunev | 8eeee8b | 2008-03-27 16:55:53 -0700 | [diff] [blame] | 381 | proc_stat = proc_create("ip_conntrack", S_IRUGO, |
| 382 | init_net.proc_net_stat, &ct_cpu_seq_fops); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 383 | if (!proc_stat) |
| 384 | goto err3; |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 385 | return 0; |
| 386 | |
| 387 | err3: |
Eric W. Biederman | 457c4cb | 2007-09-12 12:01:34 +0200 | [diff] [blame] | 388 | proc_net_remove(&init_net, "ip_conntrack_expect"); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 389 | err2: |
Eric W. Biederman | 457c4cb | 2007-09-12 12:01:34 +0200 | [diff] [blame] | 390 | proc_net_remove(&init_net, "ip_conntrack"); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 391 | err1: |
| 392 | return -ENOMEM; |
| 393 | } |
| 394 | |
| 395 | void __exit nf_conntrack_ipv4_compat_fini(void) |
| 396 | { |
Eric W. Biederman | 457c4cb | 2007-09-12 12:01:34 +0200 | [diff] [blame] | 397 | remove_proc_entry("ip_conntrack", init_net.proc_net_stat); |
| 398 | proc_net_remove(&init_net, "ip_conntrack_expect"); |
| 399 | proc_net_remove(&init_net, "ip_conntrack"); |
Patrick McHardy | e4bd8bc | 2006-11-29 02:35:22 +0100 | [diff] [blame] | 400 | } |