aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-04-16 03:51:51 -0400
committerDavid S. Miller <davem@davemloft.net>2008-04-16 03:51:51 -0400
commita59a8c1c865e6d231e1b5675f767ace006f08c21 (patch)
tree86b8999246864dbc59f6989b79af0daf2e1de3dd
parentcd1c701432fbf84ad5ea1d8012ddd398a560bccc (diff)
[VLAN]: Create proc entries in the proper net.
The proc_vlan_dir and proc_vlan_conf migrate on the struct vlan_net and their creation uses the struct net. The devices' entries use the corresponding device's net. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Acked-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/8021q/vlan.h6
-rw-r--r--net/8021q/vlanproc.c44
2 files changed, 23 insertions, 27 deletions
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index f27d8d6f3625..7258357db847 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -52,7 +52,13 @@ static inline int is_vlan_dev(struct net_device *dev)
52 52
53extern int vlan_net_id; 53extern int vlan_net_id;
54 54
55struct proc_dir_entry;
56
55struct vlan_net { 57struct vlan_net {
58 /* /proc/net/vlan */
59 struct proc_dir_entry *proc_vlan_dir;
60 /* /proc/net/vlan/config */
61 struct proc_dir_entry *proc_vlan_conf;
56}; 62};
57 63
58#endif /* !(__BEN_VLAN_802_1Q_INC__) */ 64#endif /* !(__BEN_VLAN_802_1Q_INC__) */
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 4d13aeb88584..995544b89071 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
@@ -111,18 +112,6 @@ static const struct file_operations vlandev_fops = {
111 * Proc filesystem derectory entries. 112 * Proc filesystem derectory entries.
112 */ 113 */
113 114
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 */ 115/* Strings */
127static const char *vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = { 116static const char *vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = {
128 [VLAN_NAME_TYPE_RAW_PLUS_VID] = "VLAN_NAME_TYPE_RAW_PLUS_VID", 117 [VLAN_NAME_TYPE_RAW_PLUS_VID] = "VLAN_NAME_TYPE_RAW_PLUS_VID",
@@ -140,14 +129,13 @@ static const char *vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = {
140 129
141void vlan_proc_cleanup(struct net *net) 130void vlan_proc_cleanup(struct net *net)
142{ 131{
143 if (net != &init_net) 132 struct vlan_net *vn = net_generic(net, vlan_net_id);
144 return;
145 133
146 if (proc_vlan_conf) 134 if (vn->proc_vlan_conf)
147 remove_proc_entry(name_conf, proc_vlan_dir); 135 remove_proc_entry(name_conf, vn->proc_vlan_dir);
148 136
149 if (proc_vlan_dir) 137 if (vn->proc_vlan_dir)
150 proc_net_remove(&init_net, name_root); 138 proc_net_remove(net, name_root);
151 139
152 /* Dynamically added entries should be cleaned up as their vlan_device 140 /* Dynamically added entries should be cleaned up as their vlan_device
153 * is removed, so we should not have to take care of it here... 141 * is removed, so we should not have to take care of it here...
@@ -160,16 +148,15 @@ void vlan_proc_cleanup(struct net *net)
160 148
161int vlan_proc_init(struct net *net) 149int vlan_proc_init(struct net *net)
162{ 150{
163 if (net != &init_net) 151 struct vlan_net *vn = net_generic(net, vlan_net_id);
164 return 0;
165 152
166 proc_vlan_dir = proc_mkdir(name_root, init_net.proc_net); 153 vn->proc_vlan_dir = proc_net_mkdir(net, name_root, net->proc_net);
167 if (!proc_vlan_dir) 154 if (!vn->proc_vlan_dir)
168 goto err; 155 goto err;
169 156
170 proc_vlan_conf = proc_create(name_conf, S_IFREG|S_IRUSR|S_IWUSR, 157 vn->proc_vlan_conf = proc_create(name_conf, S_IFREG|S_IRUSR|S_IWUSR,
171 proc_vlan_dir, &vlan_fops); 158 vn->proc_vlan_dir, &vlan_fops);
172 if (!proc_vlan_conf) 159 if (!vn->proc_vlan_conf)
173 goto err; 160 goto err;
174 return 0; 161 return 0;
175 162
@@ -186,9 +173,10 @@ err:
186int vlan_proc_add_dev(struct net_device *vlandev) 173int vlan_proc_add_dev(struct net_device *vlandev)
187{ 174{
188 struct vlan_dev_info *dev_info = vlan_dev_info(vlandev); 175 struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
176 struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id);
189 177
190 dev_info->dent = proc_create(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR, 178 dev_info->dent = proc_create(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR,
191 proc_vlan_dir, &vlandev_fops); 179 vn->proc_vlan_dir, &vlandev_fops);
192 if (!dev_info->dent) 180 if (!dev_info->dent)
193 return -ENOBUFS; 181 return -ENOBUFS;
194 182
@@ -201,10 +189,12 @@ int vlan_proc_add_dev(struct net_device *vlandev)
201 */ 189 */
202int vlan_proc_rem_dev(struct net_device *vlandev) 190int vlan_proc_rem_dev(struct net_device *vlandev)
203{ 191{
192 struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id);
193
204 /** NOTE: This will consume the memory pointed to by dent, it seems. */ 194 /** NOTE: This will consume the memory pointed to by dent, it seems. */
205 if (vlan_dev_info(vlandev)->dent) { 195 if (vlan_dev_info(vlandev)->dent) {
206 remove_proc_entry(vlan_dev_info(vlandev)->dent->name, 196 remove_proc_entry(vlan_dev_info(vlandev)->dent->name,
207 proc_vlan_dir); 197 vn->proc_vlan_dir);
208 vlan_dev_info(vlandev)->dent = NULL; 198 vlan_dev_info(vlandev)->dent = NULL;
209 } 199 }
210 return 0; 200 return 0;