diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2008-10-08 05:35:08 -0400 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2008-10-08 05:35:08 -0400 |
commit | 8e9df80180b73d4107bf8fbf28b1633c541d2770 (patch) | |
tree | 572b4bc6e53839818e545b0a7ba84234b0a027ce /net | |
parent | 0d55af8791bfb42e04cc456b348910582f230343 (diff) |
netfilter: netns nf_conntrack: per-netns /proc/net/stat/nf_conntrack, /proc/net/stat/ip_conntrack
Show correct conntrack count, while I'm at it.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | 14 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_standalone.c | 14 |
2 files changed, 18 insertions, 10 deletions
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c index fdc85b37078..313ebf00ee3 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | |||
@@ -285,6 +285,7 @@ static const struct file_operations ip_exp_file_ops = { | |||
285 | 285 | ||
286 | static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos) | 286 | static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos) |
287 | { | 287 | { |
288 | struct net *net = seq_file_net(seq); | ||
288 | int cpu; | 289 | int cpu; |
289 | 290 | ||
290 | if (*pos == 0) | 291 | if (*pos == 0) |
@@ -294,7 +295,7 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos) | |||
294 | if (!cpu_possible(cpu)) | 295 | if (!cpu_possible(cpu)) |
295 | continue; | 296 | continue; |
296 | *pos = cpu+1; | 297 | *pos = cpu+1; |
297 | return per_cpu_ptr(init_net.ct.stat, cpu); | 298 | return per_cpu_ptr(net->ct.stat, cpu); |
298 | } | 299 | } |
299 | 300 | ||
300 | return NULL; | 301 | return NULL; |
@@ -302,13 +303,14 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos) | |||
302 | 303 | ||
303 | static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 304 | static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
304 | { | 305 | { |
306 | struct net *net = seq_file_net(seq); | ||
305 | int cpu; | 307 | int cpu; |
306 | 308 | ||
307 | for (cpu = *pos; cpu < NR_CPUS; ++cpu) { | 309 | for (cpu = *pos; cpu < NR_CPUS; ++cpu) { |
308 | if (!cpu_possible(cpu)) | 310 | if (!cpu_possible(cpu)) |
309 | continue; | 311 | continue; |
310 | *pos = cpu+1; | 312 | *pos = cpu+1; |
311 | return per_cpu_ptr(init_net.ct.stat, cpu); | 313 | return per_cpu_ptr(net->ct.stat, cpu); |
312 | } | 314 | } |
313 | 315 | ||
314 | return NULL; | 316 | return NULL; |
@@ -320,7 +322,8 @@ static void ct_cpu_seq_stop(struct seq_file *seq, void *v) | |||
320 | 322 | ||
321 | static int ct_cpu_seq_show(struct seq_file *seq, void *v) | 323 | static int ct_cpu_seq_show(struct seq_file *seq, void *v) |
322 | { | 324 | { |
323 | unsigned int nr_conntracks = atomic_read(&init_net.ct.count); | 325 | struct net *net = seq_file_net(seq); |
326 | unsigned int nr_conntracks = atomic_read(&net->ct.count); | ||
324 | const struct ip_conntrack_stat *st = v; | 327 | const struct ip_conntrack_stat *st = v; |
325 | 328 | ||
326 | if (v == SEQ_START_TOKEN) { | 329 | if (v == SEQ_START_TOKEN) { |
@@ -360,7 +363,8 @@ static const struct seq_operations ct_cpu_seq_ops = { | |||
360 | 363 | ||
361 | static int ct_cpu_seq_open(struct inode *inode, struct file *file) | 364 | static int ct_cpu_seq_open(struct inode *inode, struct file *file) |
362 | { | 365 | { |
363 | return seq_open(file, &ct_cpu_seq_ops); | 366 | return seq_open_net(inode, file, &ct_cpu_seq_ops, |
367 | sizeof(struct seq_net_private)); | ||
364 | } | 368 | } |
365 | 369 | ||
366 | static const struct file_operations ct_cpu_seq_fops = { | 370 | static const struct file_operations ct_cpu_seq_fops = { |
@@ -368,7 +372,7 @@ static const struct file_operations ct_cpu_seq_fops = { | |||
368 | .open = ct_cpu_seq_open, | 372 | .open = ct_cpu_seq_open, |
369 | .read = seq_read, | 373 | .read = seq_read, |
370 | .llseek = seq_lseek, | 374 | .llseek = seq_lseek, |
371 | .release = seq_release, | 375 | .release = seq_release_net, |
372 | }; | 376 | }; |
373 | 377 | ||
374 | static int __net_init ip_conntrack_net_init(struct net *net) | 378 | static int __net_init ip_conntrack_net_init(struct net *net) |
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c index a4fdbbf363a..169760ddc16 100644 --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c | |||
@@ -194,6 +194,7 @@ static const struct file_operations ct_file_ops = { | |||
194 | 194 | ||
195 | 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) |
196 | { | 196 | { |
197 | struct net *net = seq_file_net(seq); | ||
197 | int cpu; | 198 | int cpu; |
198 | 199 | ||
199 | if (*pos == 0) | 200 | if (*pos == 0) |
@@ -203,7 +204,7 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos) | |||
203 | if (!cpu_possible(cpu)) | 204 | if (!cpu_possible(cpu)) |
204 | continue; | 205 | continue; |
205 | *pos = cpu + 1; | 206 | *pos = cpu + 1; |
206 | return per_cpu_ptr(init_net.ct.stat, cpu); | 207 | return per_cpu_ptr(net->ct.stat, cpu); |
207 | } | 208 | } |
208 | 209 | ||
209 | return NULL; | 210 | return NULL; |
@@ -211,13 +212,14 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos) | |||
211 | 212 | ||
212 | static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 213 | static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
213 | { | 214 | { |
215 | struct net *net = seq_file_net(seq); | ||
214 | int cpu; | 216 | int cpu; |
215 | 217 | ||
216 | for (cpu = *pos; cpu < NR_CPUS; ++cpu) { | 218 | for (cpu = *pos; cpu < NR_CPUS; ++cpu) { |
217 | if (!cpu_possible(cpu)) | 219 | if (!cpu_possible(cpu)) |
218 | continue; | 220 | continue; |
219 | *pos = cpu + 1; | 221 | *pos = cpu + 1; |
220 | return per_cpu_ptr(init_net.ct.stat, cpu); | 222 | return per_cpu_ptr(net->ct.stat, cpu); |
221 | } | 223 | } |
222 | 224 | ||
223 | return NULL; | 225 | return NULL; |
@@ -229,7 +231,8 @@ static void ct_cpu_seq_stop(struct seq_file *seq, void *v) | |||
229 | 231 | ||
230 | static int ct_cpu_seq_show(struct seq_file *seq, void *v) | 232 | static int ct_cpu_seq_show(struct seq_file *seq, void *v) |
231 | { | 233 | { |
232 | unsigned int nr_conntracks = atomic_read(&init_net.ct.count); | 234 | struct net *net = seq_file_net(seq); |
235 | unsigned int nr_conntracks = atomic_read(&net->ct.count); | ||
233 | const struct ip_conntrack_stat *st = v; | 236 | const struct ip_conntrack_stat *st = v; |
234 | 237 | ||
235 | if (v == SEQ_START_TOKEN) { | 238 | if (v == SEQ_START_TOKEN) { |
@@ -269,7 +272,8 @@ static const struct seq_operations ct_cpu_seq_ops = { | |||
269 | 272 | ||
270 | static int ct_cpu_seq_open(struct inode *inode, struct file *file) | 273 | static int ct_cpu_seq_open(struct inode *inode, struct file *file) |
271 | { | 274 | { |
272 | return seq_open(file, &ct_cpu_seq_ops); | 275 | return seq_open_net(inode, file, &ct_cpu_seq_ops, |
276 | sizeof(struct seq_net_private)); | ||
273 | } | 277 | } |
274 | 278 | ||
275 | static const struct file_operations ct_cpu_seq_fops = { | 279 | static const struct file_operations ct_cpu_seq_fops = { |
@@ -277,7 +281,7 @@ static const struct file_operations ct_cpu_seq_fops = { | |||
277 | .open = ct_cpu_seq_open, | 281 | .open = ct_cpu_seq_open, |
278 | .read = seq_read, | 282 | .read = seq_read, |
279 | .llseek = seq_lseek, | 283 | .llseek = seq_lseek, |
280 | .release = seq_release, | 284 | .release = seq_release_net, |
281 | }; | 285 | }; |
282 | 286 | ||
283 | static int nf_conntrack_standalone_init_proc(struct net *net) | 287 | static int nf_conntrack_standalone_init_proc(struct net *net) |