Commit b86d598d authored by David S. Miller's avatar David S. Miller

Merge branch 'vrf-cleanups-part-2'

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: default avatarDavid Ahern <dsa@cumulusnetworks.com>
parents 57b8efa1 2640b39c
......@@ -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;
......@@ -361,25 +360,16 @@ 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);
......@@ -387,7 +377,7 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev)
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);
......@@ -395,8 +385,6 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev)
out_unregister:
netdev_rx_handler_unregister(port_dev);
out_remove:
__vrf_remove_slave(queue, slave);
out_fail:
kfree(vrf_ptr);
kfree(slave);
......@@ -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);
......@@ -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);
}
......@@ -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)
......
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