Commit 9c5ff24f authored by WANG Cong's avatar WANG Cong Committed by David S. Miller

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: default avatarStephane Chazelas <stephane.chazelas@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a317a2f1
...@@ -325,23 +325,24 @@ static void vlan_transfer_features(struct net_device *dev, ...@@ -325,23 +325,24 @@ static void vlan_transfer_features(struct net_device *dev,
netdev_update_features(vlandev); netdev_update_features(vlandev);
} }
static void __vlan_device_event(struct net_device *dev, unsigned long event) static int __vlan_device_event(struct net_device *dev, unsigned long event)
{ {
int err = 0;
switch (event) { switch (event) {
case NETDEV_CHANGENAME: case NETDEV_CHANGENAME:
vlan_proc_rem_dev(dev); vlan_proc_rem_dev(dev);
if (vlan_proc_add_dev(dev) < 0) err = vlan_proc_add_dev(dev);
pr_warn("failed to change proc name for %s\n",
dev->name);
break; break;
case NETDEV_REGISTER: case NETDEV_REGISTER:
if (vlan_proc_add_dev(dev) < 0) err = vlan_proc_add_dev(dev);
pr_warn("failed to add proc entry for %s\n", dev->name);
break; break;
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
vlan_proc_rem_dev(dev); vlan_proc_rem_dev(dev);
break; break;
} }
return err;
} }
static int vlan_device_event(struct notifier_block *unused, unsigned long event, 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,8 +357,12 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
bool last = false; bool last = false;
LIST_HEAD(list); LIST_HEAD(list);
if (is_vlan_dev(dev)) if (is_vlan_dev(dev)) {
__vlan_device_event(dev, event); int err = __vlan_device_event(dev, event);
if (err)
return notifier_from_errno(err);
}
if ((event == NETDEV_UP) && if ((event == NETDEV_UP) &&
(dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) { (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) {
......
...@@ -171,6 +171,8 @@ int vlan_proc_add_dev(struct net_device *vlandev) ...@@ -171,6 +171,8 @@ int vlan_proc_add_dev(struct net_device *vlandev)
struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev); struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev);
struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id); struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id);
if (!strcmp(vlandev->name, name_conf))
return -EINVAL;
vlan->dent = vlan->dent =
proc_create_data(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR, proc_create_data(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR,
vn->proc_vlan_dir, &vlandev_fops, vlandev); vn->proc_vlan_dir, &vlandev_fops, vlandev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment