diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2008-10-08 05:35:05 -0400 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2008-10-08 05:35:05 -0400 |
commit | b2ce2c7479d9b60dd268203e56bb738e78fd5fda (patch) | |
tree | 486dc76da0290ff8d9da950262780565cd646c36 /net | |
parent | 74c51a1497033e6ff7b8096797daca233a4a30df (diff) |
netfilter: netns nf_conntrack: per-netns /proc/net/nf_conntrack, /proc/net/stat/nf_conntrack
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/nf_conntrack_standalone.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c index 5456e4b9424..02eaf872277 100644 --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c | |||
@@ -40,18 +40,20 @@ print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, | |||
40 | EXPORT_SYMBOL_GPL(print_tuple); | 40 | EXPORT_SYMBOL_GPL(print_tuple); |
41 | 41 | ||
42 | struct ct_iter_state { | 42 | struct ct_iter_state { |
43 | struct seq_net_private p; | ||
43 | unsigned int bucket; | 44 | unsigned int bucket; |
44 | }; | 45 | }; |
45 | 46 | ||
46 | static struct hlist_node *ct_get_first(struct seq_file *seq) | 47 | static struct hlist_node *ct_get_first(struct seq_file *seq) |
47 | { | 48 | { |
49 | struct net *net = seq_file_net(seq); | ||
48 | struct ct_iter_state *st = seq->private; | 50 | struct ct_iter_state *st = seq->private; |
49 | struct hlist_node *n; | 51 | struct hlist_node *n; |
50 | 52 | ||
51 | for (st->bucket = 0; | 53 | for (st->bucket = 0; |
52 | st->bucket < nf_conntrack_htable_size; | 54 | st->bucket < nf_conntrack_htable_size; |
53 | st->bucket++) { | 55 | st->bucket++) { |
54 | n = rcu_dereference(init_net.ct.hash[st->bucket].first); | 56 | n = rcu_dereference(net->ct.hash[st->bucket].first); |
55 | if (n) | 57 | if (n) |
56 | return n; | 58 | return n; |
57 | } | 59 | } |
@@ -61,13 +63,14 @@ static struct hlist_node *ct_get_first(struct seq_file *seq) | |||
61 | static struct hlist_node *ct_get_next(struct seq_file *seq, | 63 | static struct hlist_node *ct_get_next(struct seq_file *seq, |
62 | struct hlist_node *head) | 64 | struct hlist_node *head) |
63 | { | 65 | { |
66 | struct net *net = seq_file_net(seq); | ||
64 | struct ct_iter_state *st = seq->private; | 67 | struct ct_iter_state *st = seq->private; |
65 | 68 | ||
66 | head = rcu_dereference(head->next); | 69 | head = rcu_dereference(head->next); |
67 | while (head == NULL) { | 70 | while (head == NULL) { |
68 | if (++st->bucket >= nf_conntrack_htable_size) | 71 | if (++st->bucket >= nf_conntrack_htable_size) |
69 | return NULL; | 72 | return NULL; |
70 | head = rcu_dereference(init_net.ct.hash[st->bucket].first); | 73 | head = rcu_dereference(net->ct.hash[st->bucket].first); |
71 | } | 74 | } |
72 | return head; | 75 | return head; |
73 | } | 76 | } |
@@ -177,7 +180,7 @@ static const struct seq_operations ct_seq_ops = { | |||
177 | 180 | ||
178 | static int ct_open(struct inode *inode, struct file *file) | 181 | static int ct_open(struct inode *inode, struct file *file) |
179 | { | 182 | { |
180 | return seq_open_private(file, &ct_seq_ops, | 183 | return seq_open_net(inode, file, &ct_seq_ops, |
181 | sizeof(struct ct_iter_state)); | 184 | sizeof(struct ct_iter_state)); |
182 | } | 185 | } |
183 | 186 | ||
@@ -186,7 +189,7 @@ static const struct file_operations ct_file_ops = { | |||
186 | .open = ct_open, | 189 | .open = ct_open, |
187 | .read = seq_read, | 190 | .read = seq_read, |
188 | .llseek = seq_lseek, | 191 | .llseek = seq_lseek, |
189 | .release = seq_release_private, | 192 | .release = seq_release_net, |
190 | }; | 193 | }; |
191 | 194 | ||
192 | static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos) | 195 | static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos) |
@@ -277,38 +280,38 @@ static const struct file_operations ct_cpu_seq_fops = { | |||
277 | .release = seq_release, | 280 | .release = seq_release, |
278 | }; | 281 | }; |
279 | 282 | ||
280 | static int nf_conntrack_standalone_init_proc(void) | 283 | static int nf_conntrack_standalone_init_proc(struct net *net) |
281 | { | 284 | { |
282 | struct proc_dir_entry *pde; | 285 | struct proc_dir_entry *pde; |
283 | 286 | ||
284 | pde = proc_net_fops_create(&init_net, "nf_conntrack", 0440, &ct_file_ops); | 287 | pde = proc_net_fops_create(net, "nf_conntrack", 0440, &ct_file_ops); |
285 | if (!pde) | 288 | if (!pde) |
286 | goto out_nf_conntrack; | 289 | goto out_nf_conntrack; |
287 | 290 | ||
288 | pde = proc_create("nf_conntrack", S_IRUGO, init_net.proc_net_stat, | 291 | pde = proc_create("nf_conntrack", S_IRUGO, net->proc_net_stat, |
289 | &ct_cpu_seq_fops); | 292 | &ct_cpu_seq_fops); |
290 | if (!pde) | 293 | if (!pde) |
291 | goto out_stat_nf_conntrack; | 294 | goto out_stat_nf_conntrack; |
292 | return 0; | 295 | return 0; |
293 | 296 | ||
294 | out_stat_nf_conntrack: | 297 | out_stat_nf_conntrack: |
295 | proc_net_remove(&init_net, "nf_conntrack"); | 298 | proc_net_remove(net, "nf_conntrack"); |
296 | out_nf_conntrack: | 299 | out_nf_conntrack: |
297 | return -ENOMEM; | 300 | return -ENOMEM; |
298 | } | 301 | } |
299 | 302 | ||
300 | static void nf_conntrack_standalone_fini_proc(void) | 303 | static void nf_conntrack_standalone_fini_proc(struct net *net) |
301 | { | 304 | { |
302 | remove_proc_entry("nf_conntrack", init_net.proc_net_stat); | 305 | remove_proc_entry("nf_conntrack", net->proc_net_stat); |
303 | proc_net_remove(&init_net, "nf_conntrack"); | 306 | proc_net_remove(net, "nf_conntrack"); |
304 | } | 307 | } |
305 | #else | 308 | #else |
306 | static int nf_conntrack_standalone_init_proc(void) | 309 | static int nf_conntrack_standalone_init_proc(struct net *net) |
307 | { | 310 | { |
308 | return 0; | 311 | return 0; |
309 | } | 312 | } |
310 | 313 | ||
311 | static void nf_conntrack_standalone_fini_proc(void) | 314 | static void nf_conntrack_standalone_fini_proc(struct net *net) |
312 | { | 315 | { |
313 | } | 316 | } |
314 | #endif /* CONFIG_PROC_FS */ | 317 | #endif /* CONFIG_PROC_FS */ |
@@ -442,11 +445,25 @@ static void nf_conntrack_standalone_fini_sysctl(void) | |||
442 | 445 | ||
443 | static int nf_conntrack_net_init(struct net *net) | 446 | static int nf_conntrack_net_init(struct net *net) |
444 | { | 447 | { |
445 | return nf_conntrack_init(net); | 448 | int ret; |
449 | |||
450 | ret = nf_conntrack_init(net); | ||
451 | if (ret < 0) | ||
452 | goto out_init; | ||
453 | ret = nf_conntrack_standalone_init_proc(net); | ||
454 | if (ret < 0) | ||
455 | goto out_proc; | ||
456 | return 0; | ||
457 | |||
458 | out_proc: | ||
459 | nf_conntrack_cleanup(net); | ||
460 | out_init: | ||
461 | return ret; | ||
446 | } | 462 | } |
447 | 463 | ||
448 | static void nf_conntrack_net_exit(struct net *net) | 464 | static void nf_conntrack_net_exit(struct net *net) |
449 | { | 465 | { |
466 | nf_conntrack_standalone_fini_proc(net); | ||
450 | nf_conntrack_cleanup(net); | 467 | nf_conntrack_cleanup(net); |
451 | } | 468 | } |
452 | 469 | ||
@@ -462,17 +479,12 @@ static int __init nf_conntrack_standalone_init(void) | |||
462 | ret = register_pernet_subsys(&nf_conntrack_net_ops); | 479 | ret = register_pernet_subsys(&nf_conntrack_net_ops); |
463 | if (ret < 0) | 480 | if (ret < 0) |
464 | goto out; | 481 | goto out; |
465 | ret = nf_conntrack_standalone_init_proc(); | ||
466 | if (ret < 0) | ||
467 | goto out_proc; | ||
468 | ret = nf_conntrack_standalone_init_sysctl(); | 482 | ret = nf_conntrack_standalone_init_sysctl(); |
469 | if (ret < 0) | 483 | if (ret < 0) |
470 | goto out_sysctl; | 484 | goto out_sysctl; |
471 | return 0; | 485 | return 0; |
472 | 486 | ||
473 | out_sysctl: | 487 | out_sysctl: |
474 | nf_conntrack_standalone_fini_proc(); | ||
475 | out_proc: | ||
476 | unregister_pernet_subsys(&nf_conntrack_net_ops); | 488 | unregister_pernet_subsys(&nf_conntrack_net_ops); |
477 | out: | 489 | out: |
478 | return ret; | 490 | return ret; |
@@ -481,7 +493,6 @@ out: | |||
481 | static void __exit nf_conntrack_standalone_fini(void) | 493 | static void __exit nf_conntrack_standalone_fini(void) |
482 | { | 494 | { |
483 | nf_conntrack_standalone_fini_sysctl(); | 495 | nf_conntrack_standalone_fini_sysctl(); |
484 | nf_conntrack_standalone_fini_proc(); | ||
485 | unregister_pernet_subsys(&nf_conntrack_net_ops); | 496 | unregister_pernet_subsys(&nf_conntrack_net_ops); |
486 | } | 497 | } |
487 | 498 | ||