Commit acc5efbc authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[VLAN]: Clean up unregister_vlan_dev

Save two levels of indentation by aborting on error conditions,
remove unnecessary initialization to NULL and remove two obvious
comments.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 69ab4b7d
...@@ -142,29 +142,28 @@ static void vlan_rcu_free(struct rcu_head *rcu) ...@@ -142,29 +142,28 @@ static void vlan_rcu_free(struct rcu_head *rcu)
static int unregister_vlan_dev(struct net_device *real_dev, static int unregister_vlan_dev(struct net_device *real_dev,
unsigned short vlan_id) unsigned short vlan_id)
{ {
struct net_device *dev = NULL; struct net_device *dev;
int real_dev_ifindex = real_dev->ifindex; int real_dev_ifindex = real_dev->ifindex;
struct vlan_group *grp; struct vlan_group *grp;
int i, ret; unsigned int i;
int ret;
/* sanity check */
if (vlan_id >= VLAN_VID_MASK) if (vlan_id >= VLAN_VID_MASK)
return -EINVAL; return -EINVAL;
ASSERT_RTNL(); ASSERT_RTNL();
grp = __vlan_find_group(real_dev_ifindex); grp = __vlan_find_group(real_dev_ifindex);
if (!grp)
return -ENOENT;
ret = 0;
if (grp) {
dev = vlan_group_get_device(grp, vlan_id); dev = vlan_group_get_device(grp, vlan_id);
if (dev) { if (!dev)
/* Remove proc entry */ return -ENOENT;
vlan_proc_rem_dev(dev); vlan_proc_rem_dev(dev);
/* Take it out of our own structures, but be sure to /* Take it out of our own structures, but be sure to interlock with
* interlock with HW accelerating devices or SW vlan * HW accelerating devices or SW vlan input packet processing.
* input packet processing.
*/ */
if (real_dev->features & NETIF_F_HW_VLAN_FILTER) if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
real_dev->vlan_rx_kill_vid(real_dev, vlan_id); real_dev->vlan_rx_kill_vid(real_dev, vlan_id);
...@@ -172,16 +171,13 @@ static int unregister_vlan_dev(struct net_device *real_dev, ...@@ -172,16 +171,13 @@ static int unregister_vlan_dev(struct net_device *real_dev,
vlan_group_set_device(grp, vlan_id, NULL); vlan_group_set_device(grp, vlan_id, NULL);
synchronize_net(); synchronize_net();
/* Caller unregisters (and if necessary, puts) VLAN device, but we
/* Caller unregisters (and if necessary, puts) * get rid of the reference to real_dev here.
* VLAN device, but we get rid of the reference to
* real_dev here.
*/ */
dev_put(real_dev); dev_put(real_dev);
/* If the group is now empty, kill off the /* If the group is now empty, kill off the group. */
* group. ret = 0;
*/
for (i = 0; i < VLAN_VID_MASK; i++) for (i = 0; i < VLAN_VID_MASK; i++)
if (vlan_group_get_device(grp, i)) if (vlan_group_get_device(grp, i))
break; break;
...@@ -194,12 +190,8 @@ static int unregister_vlan_dev(struct net_device *real_dev, ...@@ -194,12 +190,8 @@ static int unregister_vlan_dev(struct net_device *real_dev,
/* Free the group, after all cpu's are done. */ /* Free the group, after all cpu's are done. */
call_rcu(&grp->rcu, vlan_rcu_free); call_rcu(&grp->rcu, vlan_rcu_free);
grp = NULL;
ret = 1; ret = 1;
} }
}
}
return ret; return ret;
} }
......
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