aboutsummaryrefslogtreecommitdiffstats
path: root/net/8021q/vlanproc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-18 21:02:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-18 21:02:35 -0400
commit334d094504c2fe1c44211ecb49146ae6bca8c321 (patch)
treed3c0f68e4b9f8e3d2ccc39e7dfe5de0534a5fad9 /net/8021q/vlanproc.c
parentd1a4be630fb068f251d64b62919f143c49ca8057 (diff)
parentd1643d24c61b725bef399cc1cf2944b4c9c23177 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.26
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.26: (1090 commits) [NET]: Fix and allocate less memory for ->priv'less netdevices [IPV6]: Fix dangling references on error in fib6_add(). [NETLABEL]: Fix NULL deref in netlbl_unlabel_staticlist_gen() if ifindex not found [PKT_SCHED]: Fix datalen check in tcf_simp_init(). [INET]: Uninline the __inet_inherit_port call. [INET]: Drop the inet_inherit_port() call. SCTP: Initialize partial_bytes_acked to 0, when all of the data is acked. [netdrvr] forcedeth: internal simplifications; changelog removal phylib: factor out get_phy_id from within get_phy_device PHY: add BCM5464 support to broadcom PHY driver cxgb3: Fix __must_check warning with dev_dbg. tc35815: Statistics cleanup natsemi: fix MMIO for PPC 44x platforms [TIPC]: Cleanup of TIPC reference table code [TIPC]: Optimized initialization of TIPC reference table [TIPC]: Remove inlining of reference table locking routines e1000: convert uint16_t style integers to u16 ixgb: convert uint16_t style integers to u16 sb1000.c: make const arrays static sb1000.c: stop inlining largish static functions ...
Diffstat (limited to 'net/8021q/vlanproc.c')
-rw-r--r--net/8021q/vlanproc.c70
1 files changed, 36 insertions, 34 deletions
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 9671aa51af2c..daad0064e2c2 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -34,6 +34,7 @@
34#include <linux/netdevice.h> 34#include <linux/netdevice.h>
35#include <linux/if_vlan.h> 35#include <linux/if_vlan.h>
36#include <net/net_namespace.h> 36#include <net/net_namespace.h>
37#include <net/netns/generic.h>
37#include "vlanproc.h" 38#include "vlanproc.h"
38#include "vlan.h" 39#include "vlan.h"
39 40
@@ -79,7 +80,8 @@ static const struct seq_operations vlan_seq_ops = {
79 80
80static int vlan_seq_open(struct inode *inode, struct file *file) 81static int vlan_seq_open(struct inode *inode, struct file *file)
81{ 82{
82 return seq_open(file, &vlan_seq_ops); 83 return seq_open_net(inode, file, &vlan_seq_ops,
84 sizeof(struct seq_net_private));
83} 85}
84 86
85static const struct file_operations vlan_fops = { 87static const struct file_operations vlan_fops = {
@@ -87,7 +89,7 @@ static const struct file_operations vlan_fops = {
87 .open = vlan_seq_open, 89 .open = vlan_seq_open,
88 .read = seq_read, 90 .read = seq_read,
89 .llseek = seq_lseek, 91 .llseek = seq_lseek,
90 .release = seq_release, 92 .release = seq_release_net,
91}; 93};
92 94
93/* 95/*
@@ -111,18 +113,6 @@ static const struct file_operations vlandev_fops = {
111 * Proc filesystem derectory entries. 113 * Proc filesystem derectory entries.
112 */ 114 */
113 115
114/*
115 * /proc/net/vlan
116 */
117
118static struct proc_dir_entry *proc_vlan_dir;
119
120/*
121 * /proc/net/vlan/config
122 */
123
124static struct proc_dir_entry *proc_vlan_conf;
125
126/* Strings */ 116/* Strings */
127static const char *vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = { 117static const char *vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = {
128 [VLAN_NAME_TYPE_RAW_PLUS_VID] = "VLAN_NAME_TYPE_RAW_PLUS_VID", 118 [VLAN_NAME_TYPE_RAW_PLUS_VID] = "VLAN_NAME_TYPE_RAW_PLUS_VID",
@@ -138,13 +128,15 @@ static const char *vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = {
138 * Clean up /proc/net/vlan entries 128 * Clean up /proc/net/vlan entries
139 */ 129 */
140 130
141void vlan_proc_cleanup(void) 131void vlan_proc_cleanup(struct net *net)
142{ 132{
143 if (proc_vlan_conf) 133 struct vlan_net *vn = net_generic(net, vlan_net_id);
144 remove_proc_entry(name_conf, proc_vlan_dir); 134
135 if (vn->proc_vlan_conf)
136 remove_proc_entry(name_conf, vn->proc_vlan_dir);
145 137
146 if (proc_vlan_dir) 138 if (vn->proc_vlan_dir)
147 proc_net_remove(&init_net, name_root); 139 proc_net_remove(net, name_root);
148 140
149 /* Dynamically added entries should be cleaned up as their vlan_device 141 /* Dynamically added entries should be cleaned up as their vlan_device
150 * is removed, so we should not have to take care of it here... 142 * is removed, so we should not have to take care of it here...
@@ -155,21 +147,23 @@ void vlan_proc_cleanup(void)
155 * Create /proc/net/vlan entries 147 * Create /proc/net/vlan entries
156 */ 148 */
157 149
158int __init vlan_proc_init(void) 150int vlan_proc_init(struct net *net)
159{ 151{
160 proc_vlan_dir = proc_mkdir(name_root, init_net.proc_net); 152 struct vlan_net *vn = net_generic(net, vlan_net_id);
161 if (!proc_vlan_dir) 153
154 vn->proc_vlan_dir = proc_net_mkdir(net, name_root, net->proc_net);
155 if (!vn->proc_vlan_dir)
162 goto err; 156 goto err;
163 157
164 proc_vlan_conf = proc_create(name_conf, S_IFREG|S_IRUSR|S_IWUSR, 158 vn->proc_vlan_conf = proc_create(name_conf, S_IFREG|S_IRUSR|S_IWUSR,
165 proc_vlan_dir, &vlan_fops); 159 vn->proc_vlan_dir, &vlan_fops);
166 if (!proc_vlan_conf) 160 if (!vn->proc_vlan_conf)
167 goto err; 161 goto err;
168 return 0; 162 return 0;
169 163
170err: 164err:
171 pr_err("%s: can't create entry in proc filesystem!\n", __FUNCTION__); 165 pr_err("%s: can't create entry in proc filesystem!\n", __func__);
172 vlan_proc_cleanup(); 166 vlan_proc_cleanup(net);
173 return -ENOBUFS; 167 return -ENOBUFS;
174} 168}
175 169
@@ -180,9 +174,10 @@ err:
180int vlan_proc_add_dev(struct net_device *vlandev) 174int vlan_proc_add_dev(struct net_device *vlandev)
181{ 175{
182 struct vlan_dev_info *dev_info = vlan_dev_info(vlandev); 176 struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
177 struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id);
183 178
184 dev_info->dent = proc_create(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR, 179 dev_info->dent = proc_create(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR,
185 proc_vlan_dir, &vlandev_fops); 180 vn->proc_vlan_dir, &vlandev_fops);
186 if (!dev_info->dent) 181 if (!dev_info->dent)
187 return -ENOBUFS; 182 return -ENOBUFS;
188 183
@@ -195,10 +190,12 @@ int vlan_proc_add_dev(struct net_device *vlandev)
195 */ 190 */
196int vlan_proc_rem_dev(struct net_device *vlandev) 191int vlan_proc_rem_dev(struct net_device *vlandev)
197{ 192{
193 struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id);
194
198 /** NOTE: This will consume the memory pointed to by dent, it seems. */ 195 /** NOTE: This will consume the memory pointed to by dent, it seems. */
199 if (vlan_dev_info(vlandev)->dent) { 196 if (vlan_dev_info(vlandev)->dent) {
200 remove_proc_entry(vlan_dev_info(vlandev)->dent->name, 197 remove_proc_entry(vlan_dev_info(vlandev)->dent->name,
201 proc_vlan_dir); 198 vn->proc_vlan_dir);
202 vlan_dev_info(vlandev)->dent = NULL; 199 vlan_dev_info(vlandev)->dent = NULL;
203 } 200 }
204 return 0; 201 return 0;
@@ -215,6 +212,7 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
215 __acquires(dev_base_lock) 212 __acquires(dev_base_lock)
216{ 213{
217 struct net_device *dev; 214 struct net_device *dev;
215 struct net *net = seq_file_net(seq);
218 loff_t i = 1; 216 loff_t i = 1;
219 217
220 read_lock(&dev_base_lock); 218 read_lock(&dev_base_lock);
@@ -222,7 +220,7 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
222 if (*pos == 0) 220 if (*pos == 0)
223 return SEQ_START_TOKEN; 221 return SEQ_START_TOKEN;
224 222
225 for_each_netdev(&init_net, dev) { 223 for_each_netdev(net, dev) {
226 if (!is_vlan_dev(dev)) 224 if (!is_vlan_dev(dev))
227 continue; 225 continue;
228 226
@@ -236,14 +234,15 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
236static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos) 234static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
237{ 235{
238 struct net_device *dev; 236 struct net_device *dev;
237 struct net *net = seq_file_net(seq);
239 238
240 ++*pos; 239 ++*pos;
241 240
242 dev = (struct net_device *)v; 241 dev = (struct net_device *)v;
243 if (v == SEQ_START_TOKEN) 242 if (v == SEQ_START_TOKEN)
244 dev = net_device_entry(&init_net.dev_base_head); 243 dev = net_device_entry(&net->dev_base_head);
245 244
246 for_each_netdev_continue(&init_net, dev) { 245 for_each_netdev_continue(net, dev) {
247 if (!is_vlan_dev(dev)) 246 if (!is_vlan_dev(dev))
248 continue; 247 continue;
249 248
@@ -261,13 +260,16 @@ static void vlan_seq_stop(struct seq_file *seq, void *v)
261 260
262static int vlan_seq_show(struct seq_file *seq, void *v) 261static int vlan_seq_show(struct seq_file *seq, void *v)
263{ 262{
263 struct net *net = seq_file_net(seq);
264 struct vlan_net *vn = net_generic(net, vlan_net_id);
265
264 if (v == SEQ_START_TOKEN) { 266 if (v == SEQ_START_TOKEN) {
265 const char *nmtype = NULL; 267 const char *nmtype = NULL;
266 268
267 seq_puts(seq, "VLAN Dev name | VLAN ID\n"); 269 seq_puts(seq, "VLAN Dev name | VLAN ID\n");
268 270
269 if (vlan_name_type < ARRAY_SIZE(vlan_name_type_str)) 271 if (vn->name_type < ARRAY_SIZE(vlan_name_type_str))
270 nmtype = vlan_name_type_str[vlan_name_type]; 272 nmtype = vlan_name_type_str[vn->name_type];
271 273
272 seq_printf(seq, "Name-Type: %s\n", 274 seq_printf(seq, "Name-Type: %s\n",
273 nmtype ? nmtype : "UNKNOWN"); 275 nmtype ? nmtype : "UNKNOWN");