Skip to content

Commit

Permalink
Merge branch 'vrf-cleanups-part-2'
Browse files Browse the repository at this point in the history
Nikolay Aleksandrov says:

====================
vrf: cleanups part 2

This is the next part of vrf cleanups, patch 1 drops the SLAB_PANIC
when creating kmem cache since it's handled, patch 02 removes a slave
duplicate check which is already done by the lower/upper code, patch 3
moves the ndo_add_slave code around a bit so we can drop an error
label and patch 4 drops the master device checks which are unnecessary
because the ops are taken from the master device itself so it can't be
different.
====================

Acked-by: David Ahern <dsa@cumulusnetworks.com>
  • Loading branch information
David S. Miller committed Aug 20, 2015
2 parents 57b8efa + 2640b39 commit b86d598
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions drivers/net/vrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev)
{
struct net_vrf_dev *vrf_ptr = kmalloc(sizeof(*vrf_ptr), GFP_KERNEL);
struct slave *slave = kzalloc(sizeof(*slave), GFP_KERNEL);
struct slave *duplicate_slave;
struct net_vrf *vrf = netdev_priv(dev);
struct slave_queue *queue = &vrf->queue;
int ret = -ENOMEM;
Expand All @@ -361,42 +360,31 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev)
goto out_fail;

slave->dev = port_dev;

vrf_ptr->ifindex = dev->ifindex;
vrf_ptr->tb_id = vrf->tb_id;

duplicate_slave = __vrf_find_slave_dev(queue, port_dev);
if (duplicate_slave) {
ret = -EBUSY;
goto out_fail;
}

__vrf_insert_slave(queue, slave);

/* register the packet handler for slave ports */
ret = netdev_rx_handler_register(port_dev, vrf_handle_frame, dev);
if (ret) {
netdev_err(port_dev,
"Device %s failed to register rx_handler\n",
port_dev->name);
goto out_remove;
goto out_fail;
}

ret = netdev_master_upper_dev_link(port_dev, dev);
if (ret < 0)
goto out_unregister;

port_dev->flags |= IFF_SLAVE;

__vrf_insert_slave(queue, slave);
rcu_assign_pointer(port_dev->vrf_ptr, vrf_ptr);
cycle_netdev(port_dev);

return 0;

out_unregister:
netdev_rx_handler_unregister(port_dev);
out_remove:
__vrf_remove_slave(queue, slave);
out_fail:
kfree(vrf_ptr);
kfree(slave);
Expand All @@ -405,8 +393,7 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev)

static int vrf_add_slave(struct net_device *dev, struct net_device *port_dev)
{
if (!netif_is_vrf(dev) || netif_is_vrf(port_dev) ||
vrf_is_slave(port_dev))
if (netif_is_vrf(port_dev) || vrf_is_slave(port_dev))
return -EINVAL;

return do_vrf_add_slave(dev, port_dev);
Expand Down Expand Up @@ -443,9 +430,6 @@ static int do_vrf_del_slave(struct net_device *dev, struct net_device *port_dev)

static int vrf_del_slave(struct net_device *dev, struct net_device *port_dev)
{
if (!netif_is_vrf(dev))
return -EINVAL;

return do_vrf_del_slave(dev, port_dev);
}

Expand Down Expand Up @@ -649,7 +633,7 @@ static int __init vrf_init_module(void)
vrf_dst_ops.kmem_cachep =
kmem_cache_create("vrf_ip_dst_cache",
sizeof(struct rtable), 0,
SLAB_HWCACHE_ALIGN | SLAB_PANIC,
SLAB_HWCACHE_ALIGN,
NULL);

if (!vrf_dst_ops.kmem_cachep)
Expand Down

0 comments on commit b86d598

Please sign in to comment.