diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2014-07-25 18:25:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-29 14:43:50 -0400 |
commit | 9c5ff24f963919965155cf0c4a2323b22a0c5c84 (patch) | |
tree | 8be53cca32ce634c291589f161684913f42432ac /net/8021q | |
parent | a317a2f19da7d0af1f068cf4d3ae80cdd73643b7 (diff) |
vlan: fail early when creating netdev named config
Similarly, vlan will create /proc/net/vlan/<dev>, so when we
create dev with name "config", it will confict with
/proc/net/vlan/config.
Reported-by: Stephane Chazelas <stephane.chazelas@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/8021q')
-rw-r--r-- | net/8021q/vlan.c | 21 | ||||
-rw-r--r-- | net/8021q/vlanproc.c | 2 |
2 files changed, 15 insertions, 8 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index cba9c212a730..64c6bed4a3d3 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -325,23 +325,24 @@ static void vlan_transfer_features(struct net_device *dev, | |||
325 | netdev_update_features(vlandev); | 325 | netdev_update_features(vlandev); |
326 | } | 326 | } |
327 | 327 | ||
328 | static void __vlan_device_event(struct net_device *dev, unsigned long event) | 328 | static int __vlan_device_event(struct net_device *dev, unsigned long event) |
329 | { | 329 | { |
330 | int err = 0; | ||
331 | |||
330 | switch (event) { | 332 | switch (event) { |
331 | case NETDEV_CHANGENAME: | 333 | case NETDEV_CHANGENAME: |
332 | vlan_proc_rem_dev(dev); | 334 | vlan_proc_rem_dev(dev); |
333 | if (vlan_proc_add_dev(dev) < 0) | 335 | err = vlan_proc_add_dev(dev); |
334 | pr_warn("failed to change proc name for %s\n", | ||
335 | dev->name); | ||
336 | break; | 336 | break; |
337 | case NETDEV_REGISTER: | 337 | case NETDEV_REGISTER: |
338 | if (vlan_proc_add_dev(dev) < 0) | 338 | err = vlan_proc_add_dev(dev); |
339 | pr_warn("failed to add proc entry for %s\n", dev->name); | ||
340 | break; | 339 | break; |
341 | case NETDEV_UNREGISTER: | 340 | case NETDEV_UNREGISTER: |
342 | vlan_proc_rem_dev(dev); | 341 | vlan_proc_rem_dev(dev); |
343 | break; | 342 | break; |
344 | } | 343 | } |
344 | |||
345 | return err; | ||
345 | } | 346 | } |
346 | 347 | ||
347 | static int vlan_device_event(struct notifier_block *unused, unsigned long event, | 348 | static int vlan_device_event(struct notifier_block *unused, unsigned long event, |
@@ -356,8 +357,12 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, | |||
356 | bool last = false; | 357 | bool last = false; |
357 | LIST_HEAD(list); | 358 | LIST_HEAD(list); |
358 | 359 | ||
359 | if (is_vlan_dev(dev)) | 360 | if (is_vlan_dev(dev)) { |
360 | __vlan_device_event(dev, event); | 361 | int err = __vlan_device_event(dev, event); |
362 | |||
363 | if (err) | ||
364 | return notifier_from_errno(err); | ||
365 | } | ||
361 | 366 | ||
362 | if ((event == NETDEV_UP) && | 367 | if ((event == NETDEV_UP) && |
363 | (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) { | 368 | (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) { |
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c index 1d0e89213a28..ae63cf72a953 100644 --- a/net/8021q/vlanproc.c +++ b/net/8021q/vlanproc.c | |||
@@ -171,6 +171,8 @@ int vlan_proc_add_dev(struct net_device *vlandev) | |||
171 | struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev); | 171 | struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev); |
172 | struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id); | 172 | struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id); |
173 | 173 | ||
174 | if (!strcmp(vlandev->name, name_conf)) | ||
175 | return -EINVAL; | ||
174 | vlan->dent = | 176 | vlan->dent = |
175 | proc_create_data(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR, | 177 | proc_create_data(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR, |
176 | vn->proc_vlan_dir, &vlandev_fops, vlandev); | 178 | vn->proc_vlan_dir, &vlandev_fops, vlandev); |