macvlan: add link to upper device
authorJiri Pirko <jiri@resnulli.us>
Thu, 3 Jan 2013 22:48:50 +0000 (22:48 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 4 Jan 2013 21:31:49 +0000 (13:31 -0800)
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/macvlan.c

index 80c6f927a7b4b128368c6d1b33a8a80b2b93b591..0ae45182f40dc1427592ec8ca9f81ef027b3d080 100644 (file)
@@ -764,16 +764,22 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
                memcpy(dev->dev_addr, lowerdev->dev_addr, ETH_ALEN);
        }
 
+       err = netdev_upper_dev_link(lowerdev, dev);
+       if (err)
+               goto destroy_port;
+
        port->count += 1;
        err = register_netdevice(dev);
        if (err < 0)
-               goto destroy_port;
+               goto upper_dev_unlink;
 
        list_add_tail(&vlan->list, &port->vlans);
        netif_stacked_transfer_operstate(lowerdev, dev);
 
        return 0;
 
+upper_dev_unlink:
+       netdev_upper_dev_unlink(lowerdev, dev);
 destroy_port:
        port->count -= 1;
        if (!port->count)
@@ -797,6 +803,7 @@ void macvlan_dellink(struct net_device *dev, struct list_head *head)
 
        list_del(&vlan->list);
        unregister_netdevice_queue(dev, head);
+       netdev_upper_dev_unlink(vlan->lowerdev, dev);
 }
 EXPORT_SYMBOL_GPL(macvlan_dellink);