diff options
author | Denis V. Lunev <den@openvz.org> | 2008-10-07 17:47:12 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-10-07 17:47:12 -0400 |
commit | 7b43ccecc77480353a5657d993d671cae9e94efd (patch) | |
tree | be4e5b0b700c024f53a8503ec8cf23f5e5fa1401 /net/ipv6 | |
parent | 35f0a5df6cbc315da031c40541e135a059bfde7d (diff) |
ipv6: separate seq_ops for global & per/device ipv6 statistics
idev has been stored on seq->private. NULL has been stored for global
statistics.
The situation is changed with net namespace. We need to store pointer to
struct net and the only place is seq->private. So, we'll have for
/proc/net/dev_snmp6/* and for /proc/net/snmp6 pointers of two different
types stored in the same field.
This effectively requires to separate seq_ops of these files.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/proc.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index 25eda8bf2182..7601f56ce915 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c | |||
@@ -175,26 +175,17 @@ snmp6_seq_show_item(struct seq_file *seq, void **mib, struct snmp_mib *itemlist) | |||
175 | 175 | ||
176 | static int snmp6_seq_show(struct seq_file *seq, void *v) | 176 | static int snmp6_seq_show(struct seq_file *seq, void *v) |
177 | { | 177 | { |
178 | struct inet6_dev *idev = (struct inet6_dev *)seq->private; | 178 | snmp6_seq_show_item(seq, (void **)ipv6_statistics, snmp6_ipstats_list); |
179 | 179 | snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list); | |
180 | if (idev) { | 180 | snmp6_seq_show_icmpv6msg(seq, (void **)icmpv6msg_statistics); |
181 | seq_printf(seq, "%-32s\t%u\n", "ifIndex", idev->dev->ifindex); | 181 | snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list); |
182 | snmp6_seq_show_item(seq, (void **)idev->stats.ipv6, snmp6_ipstats_list); | 182 | snmp6_seq_show_item(seq, (void **)udplite_stats_in6, snmp6_udplite6_list); |
183 | snmp6_seq_show_item(seq, (void **)idev->stats.icmpv6, snmp6_icmp6_list); | ||
184 | snmp6_seq_show_icmpv6msg(seq, (void **)idev->stats.icmpv6msg); | ||
185 | } else { | ||
186 | snmp6_seq_show_item(seq, (void **)ipv6_statistics, snmp6_ipstats_list); | ||
187 | snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list); | ||
188 | snmp6_seq_show_icmpv6msg(seq, (void **)icmpv6msg_statistics); | ||
189 | snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list); | ||
190 | snmp6_seq_show_item(seq, (void **)udplite_stats_in6, snmp6_udplite6_list); | ||
191 | } | ||
192 | return 0; | 183 | return 0; |
193 | } | 184 | } |
194 | 185 | ||
195 | static int snmp6_seq_open(struct inode *inode, struct file *file) | 186 | static int snmp6_seq_open(struct inode *inode, struct file *file) |
196 | { | 187 | { |
197 | return single_open(file, snmp6_seq_show, PDE(inode)->data); | 188 | return single_open(file, snmp6_seq_show, NULL); |
198 | } | 189 | } |
199 | 190 | ||
200 | static const struct file_operations snmp6_seq_fops = { | 191 | static const struct file_operations snmp6_seq_fops = { |
@@ -205,6 +196,30 @@ static const struct file_operations snmp6_seq_fops = { | |||
205 | .release = single_release, | 196 | .release = single_release, |
206 | }; | 197 | }; |
207 | 198 | ||
199 | static int snmp6_dev_seq_show(struct seq_file *seq, void *v) | ||
200 | { | ||
201 | struct inet6_dev *idev = (struct inet6_dev *)seq->private; | ||
202 | |||
203 | seq_printf(seq, "%-32s\t%u\n", "ifIndex", idev->dev->ifindex); | ||
204 | snmp6_seq_show_item(seq, (void **)idev->stats.ipv6, snmp6_ipstats_list); | ||
205 | snmp6_seq_show_item(seq, (void **)idev->stats.icmpv6, snmp6_icmp6_list); | ||
206 | snmp6_seq_show_icmpv6msg(seq, (void **)idev->stats.icmpv6msg); | ||
207 | return 0; | ||
208 | } | ||
209 | |||
210 | static int snmp6_dev_seq_open(struct inode *inode, struct file *file) | ||
211 | { | ||
212 | return single_open(file, snmp6_dev_seq_show, PDE(inode)->data); | ||
213 | } | ||
214 | |||
215 | static const struct file_operations snmp6_dev_seq_fops = { | ||
216 | .owner = THIS_MODULE, | ||
217 | .open = snmp6_dev_seq_open, | ||
218 | .read = seq_read, | ||
219 | .llseek = seq_lseek, | ||
220 | .release = single_release, | ||
221 | }; | ||
222 | |||
208 | int snmp6_register_dev(struct inet6_dev *idev) | 223 | int snmp6_register_dev(struct inet6_dev *idev) |
209 | { | 224 | { |
210 | struct proc_dir_entry *p; | 225 | struct proc_dir_entry *p; |
@@ -221,7 +236,8 @@ int snmp6_register_dev(struct inet6_dev *idev) | |||
221 | return -ENOENT; | 236 | return -ENOENT; |
222 | 237 | ||
223 | p = proc_create_data(idev->dev->name, S_IRUGO, | 238 | p = proc_create_data(idev->dev->name, S_IRUGO, |
224 | net->mib.proc_net_devsnmp6, &snmp6_seq_fops, idev); | 239 | net->mib.proc_net_devsnmp6, |
240 | &snmp6_dev_seq_fops, idev); | ||
225 | if (!p) | 241 | if (!p) |
226 | return -ENOMEM; | 242 | return -ENOMEM; |
227 | 243 | ||