[PATCH v2 2/6] netns ct: per-netns /proc/net/stat/nf_conntrack , /proc/net/stat/ip_conntrack

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alexey Dobriyan
Date: Saturday, September 13, 2008 - 3:49 am

Show correct conntrack count, while I'm at it.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c |   14 +++++++++-----
 net/netfilter/nf_conntrack_standalone.c               |   14 +++++++++-----
 2 files changed, 18 insertions(+), 10 deletions(-)

--- 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 = {
 
 static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
 {
+	struct net *net = seq_file_net(seq);
 	int cpu;
 
 	if (*pos == 0)
@@ -294,7 +295,7 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
 		if (!cpu_possible(cpu))
 			continue;
 		*pos = cpu+1;
-		return per_cpu_ptr(init_net.ct.stat, cpu);
+		return per_cpu_ptr(net->ct.stat, cpu);
 	}
 
 	return NULL;
@@ -302,13 +303,14 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
 
 static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
+	struct net *net = seq_file_net(seq);
 	int cpu;
 
 	for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
 		if (!cpu_possible(cpu))
 			continue;
 		*pos = cpu+1;
-		return per_cpu_ptr(init_net.ct.stat, cpu);
+		return per_cpu_ptr(net->ct.stat, cpu);
 	}
 
 	return NULL;
@@ -320,7 +322,8 @@ static void ct_cpu_seq_stop(struct seq_file *seq, void *v)
 
 static int ct_cpu_seq_show(struct seq_file *seq, void *v)
 {
-	unsigned int nr_conntracks = atomic_read(&init_net.ct.count);
+	struct net *net = seq_file_net(seq);
+	unsigned int nr_conntracks = atomic_read(&net->ct.count);
 	const struct ip_conntrack_stat *st = v;
 
 	if (v == SEQ_START_TOKEN) {
@@ -360,7 +363,8 @@ static const struct seq_operations ct_cpu_seq_ops = {
 
 static int ct_cpu_seq_open(struct inode *inode, struct file *file)
 {
-	return seq_open(file, &ct_cpu_seq_ops);
+	return seq_open_net(inode, file, &ct_cpu_seq_ops,
+			    sizeof(struct seq_net_private));
 }
 
 static const struct file_operations ct_cpu_seq_fops = {
@@ -368,7 +372,7 @@ static const struct file_operations ct_cpu_seq_fops = {
 	.open    = ct_cpu_seq_open,
 	.read    = seq_read,
 	.llseek  = seq_lseek,
-	.release = seq_release,
+	.release = seq_release_net,
 };
 
 static int __net_init ip_conntrack_net_init(struct net *net)
--- 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 = {
 
 static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
 {
+	struct net *net = seq_file_net(seq);
 	int cpu;
 
 	if (*pos == 0)
@@ -203,7 +204,7 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
 		if (!cpu_possible(cpu))
 			continue;
 		*pos = cpu + 1;
-		return per_cpu_ptr(init_net.ct.stat, cpu);
+		return per_cpu_ptr(net->ct.stat, cpu);
 	}
 
 	return NULL;
@@ -211,13 +212,14 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
 
 static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
+	struct net *net = seq_file_net(seq);
 	int cpu;
 
 	for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
 		if (!cpu_possible(cpu))
 			continue;
 		*pos = cpu + 1;
-		return per_cpu_ptr(init_net.ct.stat, cpu);
+		return per_cpu_ptr(net->ct.stat, cpu);
 	}
 
 	return NULL;
@@ -229,7 +231,8 @@ static void ct_cpu_seq_stop(struct seq_file *seq, void *v)
 
 static int ct_cpu_seq_show(struct seq_file *seq, void *v)
 {
-	unsigned int nr_conntracks = atomic_read(&init_net.ct.count);
+	struct net *net = seq_file_net(seq);
+	unsigned int nr_conntracks = atomic_read(&net->ct.count);
 	const struct ip_conntrack_stat *st = v;
 
 	if (v == SEQ_START_TOKEN) {
@@ -269,7 +272,8 @@ static const struct seq_operations ct_cpu_seq_ops = {
 
 static int ct_cpu_seq_open(struct inode *inode, struct file *file)
 {
-	return seq_open(file, &ct_cpu_seq_ops);
+	return seq_open_net(inode, file, &ct_cpu_seq_ops,
+			    sizeof(struct seq_net_private));
 }
 
 static const struct file_operations ct_cpu_seq_fops = {
@@ -277,7 +281,7 @@ static const struct file_operations ct_cpu_seq_fops = {
 	.open	 = ct_cpu_seq_open,
 	.read	 = seq_read,
 	.llseek	 = seq_lseek,
-	.release = seq_release,
+	.release = seq_release_net,
 };
 
 static int nf_conntrack_standalone_init_proc(struct net *net)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 10/38] netns ct: per-netns expectations, adobriyan, (Thu Aug 21, 3:00 pm)
Re: [PATCH 10/38] netns ct: per-netns expectations, Patrick McHardy, (Thu Sep 4, 9:43 am)
[PATCH 01/33] nf_conntrack_sip: de-static helper pointers, Alexey Dobriyan, (Sun Sep 7, 8:02 pm)
[PATCH 04/33] Fix {ip,6}_route_me_harder() in netns, Alexey Dobriyan, (Sun Sep 7, 8:02 pm)
[PATCH 05/33] netns ct: per-netns expectations, Alexey Dobriyan, (Sun Sep 7, 8:02 pm)
[PATCH 06/33] netns ct: per-netns unconfirmed list, Alexey Dobriyan, (Sun Sep 7, 8:02 pm)
[PATCH 12/33] netns ct: export netns list, Alexey Dobriyan, (Sun Sep 7, 8:02 pm)
[PATCH 13/33] netns ct: unregister helper in every netns, Alexey Dobriyan, (Sun Sep 7, 8:02 pm)
[PATCH 16/33] netns ct: per-netns event cache, Alexey Dobriyan, (Sun Sep 7, 8:02 pm)
[PATCH 17/33] netns ct: final init_net tweaks, Alexey Dobriyan, (Sun Sep 7, 8:02 pm)
[PATCH 17/33] netns ct: final init_net tweaks, Alexey Dobriyan, (Sun Sep 7, 8:02 pm)
[PATCH 24/33] netns ct: SIP conntracking in netns, Alexey Dobriyan, (Sun Sep 7, 8:03 pm)
[PATCH 25/33] netns ct: H323 conntracking in netns, Alexey Dobriyan, (Sun Sep 7, 8:03 pm)
[PATCH 26/33] netns ct: GRE conntracking in netns, Alexey Dobriyan, (Sun Sep 7, 8:03 pm)
[PATCH 27/33] netns ct: PPTP conntracking in netns, Alexey Dobriyan, (Sun Sep 7, 8:03 pm)
[PATCH 28/33] netns nat: fix ipt_MASQUERADE in netns, Alexey Dobriyan, (Sun Sep 7, 8:03 pm)
[PATCH 29/33] netns nat: per-netns NAT table, Alexey Dobriyan, (Sun Sep 7, 8:03 pm)
[PATCH 30/33] netns nat: per-netns bysource hash, Alexey Dobriyan, (Sun Sep 7, 8:03 pm)
[PATCH 31/33] netns ct: fixup DNAT in netns, Alexey Dobriyan, (Sun Sep 7, 8:03 pm)
[PATCH 32/33] netns nat: PPTP NAT in netns, Alexey Dobriyan, (Sun Sep 7, 8:03 pm)
[PATCH 33/33] Enable netfilter in netns, Alexey Dobriyan, (Sun Sep 7, 8:03 pm)
Re: [PATCH 04/33] Fix {ip,6}_route_me_harder() in netns, Patrick McHardy, (Mon Sep 8, 10:44 pm)
Re: [PATCH 05/33] netns ct: per-netns expectations, Patrick McHardy, (Mon Sep 8, 10:49 pm)
Re: [PATCH 06/33] netns ct: per-netns unconfirmed list, Patrick McHardy, (Mon Sep 8, 10:50 pm)
Re: [PATCH 12/33] netns ct: export netns list, Patrick McHardy, (Mon Sep 8, 10:59 pm)
Re: [PATCH 13/33] netns ct: unregister helper in every netns, Patrick McHardy, (Mon Sep 8, 11:01 pm)
Re: [PATCH 16/33] netns ct: per-netns event cache, Patrick McHardy, (Mon Sep 8, 11:12 pm)
Re: [PATCH 16/33] netns ct: per-netns event cache, Patrick McHardy, (Tue Sep 9, 12:07 am)
Re: [PATCH 05/33] netns ct: per-netns expectations, Alexey Dobriyan, (Tue Sep 9, 12:07 am)
Re: [PATCH 16/33] netns ct: per-netns event cache, Alexey Dobriyan, (Tue Sep 9, 12:07 am)
Re: [PATCH 05/33] netns ct: per-netns expectations, Patrick McHardy, (Tue Sep 9, 12:10 am)
Re: [PATCH 16/33] netns ct: per-netns event cache, Patrick McHardy, (Tue Sep 9, 12:16 am)
Re: [PATCH 17/33] netns ct: final init_net tweaks, Patrick McHardy, (Tue Sep 9, 12:20 am)
Re: [PATCH 17/33] netns ct: final init_net tweaks, Alexey Dobriyan, (Tue Sep 9, 12:32 am)
Re: [PATCH 17/33] netns ct: final init_net tweaks, Patrick McHardy, (Tue Sep 9, 12:51 am)
Re: [PATCH 17/33] netns ct: final init_net tweaks, Alexey Dobriyan, (Sat Sep 13, 3:45 am)
[PATCH v2 1/6] netns ct: per-netns statistics, Alexey Dobriyan, (Sat Sep 13, 3:48 am)
[PATCH v2 2/6] netns ct: per-netns /proc/net/stat/nf_connt ..., Alexey Dobriyan, (Sat Sep 13, 3:49 am)
[PATCH v2 6/6] netns ct: per-netns conntrack accounting, Alexey Dobriyan, (Sat Sep 13, 3:55 am)
[PATCH v2 7/6] netns ct: final netns tweaks, Alexey Dobriyan, (Fri Sep 26, 4:59 pm)
Re: [PATCH 17/33] netns ct: final init_net tweaks, Alexey Dobriyan, (Fri Sep 26, 5:00 pm)
Re: [PATCH 17/33] netns ct: final init_net tweaks, Patrick McHardy, (Sun Sep 28, 3:31 am)
Re: [PATCH v2 1/6] netns ct: per-netns statistics, Patrick McHardy, (Thu Oct 2, 12:58 am)
Re: [PATCH v2 7/6] netns ct: final netns tweaks, Patrick McHardy, (Thu Oct 2, 1:11 am)
Re: [PATCH 24/33] netns ct: SIP conntracking in netns, Patrick McHardy, (Thu Oct 2, 1:52 am)
Re: [PATCH 25/33] netns ct: H323 conntracking in netns, Patrick McHardy, (Thu Oct 2, 1:52 am)
Re: [PATCH 26/33] netns ct: GRE conntracking in netns, Patrick McHardy, (Thu Oct 2, 1:53 am)
Re: [PATCH 27/33] netns ct: PPTP conntracking in netns, Patrick McHardy, (Thu Oct 2, 1:54 am)
Re: [PATCH 28/33] netns nat: fix ipt_MASQUERADE in netns, Patrick McHardy, (Thu Oct 2, 2:06 am)
Re: [PATCH 29/33] netns nat: per-netns NAT table, Patrick McHardy, (Thu Oct 2, 2:08 am)
Re: [PATCH 29/33] netns nat: per-netns NAT table, Patrick McHardy, (Thu Oct 2, 2:09 am)
Re: [PATCH 30/33] netns nat: per-netns bysource hash, Patrick McHardy, (Thu Oct 2, 2:09 am)
Re: [PATCH 31/33] netns ct: fixup DNAT in netns, Patrick McHardy, (Thu Oct 2, 2:10 am)
Re: [PATCH 32/33] netns nat: PPTP NAT in netns, Patrick McHardy, (Thu Oct 2, 2:11 am)
Re: [PATCH 33/33] Enable netfilter in netns, Patrick McHardy, (Thu Oct 2, 2:12 am)
Re: [PATCH 33/33] Enable netfilter in netns, Alexey Dobriyan, (Thu Oct 2, 2:51 am)
Re: [PATCH 33/33] Enable netfilter in netns, Alexey Dobriyan, (Thu Oct 2, 2:53 am)
Re: [PATCH 33/33] Enable netfilter in netns, Patrick McHardy, (Thu Oct 2, 3:00 am)