diff options
| author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-05-08 19:17:57 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2011-05-09 14:41:40 -0400 |
| commit | 226bd3411471af42f7edbdfaf73f2d54ebb62a66 (patch) | |
| tree | 3d815d5f9f2b060d2ce9567c2c2e8a6f5fbb42b0 | |
| parent | 7ef73bca731fea9d4b706db2acb96b6488aa1b0e (diff) | |
net: use batched device unregister in veth and macvlan
veth devices dont use the batched device unregisters yet.
Since veth are a pair of devices, it makes sense to use a batch of two
unregisters, this roughly divides dismantle time by two.
Fix this by changing dellink() callers to always provide a non NULL
head. (Idea from Michał Mirosław)
This patch also handles macvlan case : We now dismantle all macvlans on
top of a lower dev at once.
Reported-by: Alex Bligh <alex@alex.org.uk>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Michał Mirosław <mirqus@gmail.com>
Cc: Jesse Gross <jesse@nicira.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Ben Greear <greearb@candelatech.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/net/macvlan.c | 5 | ||||
| -rw-r--r-- | net/core/rtnetlink.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 3ad5425b82dd..d7c0bc62da7f 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c | |||
| @@ -785,6 +785,7 @@ static int macvlan_device_event(struct notifier_block *unused, | |||
| 785 | struct net_device *dev = ptr; | 785 | struct net_device *dev = ptr; |
| 786 | struct macvlan_dev *vlan, *next; | 786 | struct macvlan_dev *vlan, *next; |
| 787 | struct macvlan_port *port; | 787 | struct macvlan_port *port; |
| 788 | LIST_HEAD(list_kill); | ||
| 788 | 789 | ||
| 789 | if (!macvlan_port_exists(dev)) | 790 | if (!macvlan_port_exists(dev)) |
| 790 | return NOTIFY_DONE; | 791 | return NOTIFY_DONE; |
| @@ -810,7 +811,9 @@ static int macvlan_device_event(struct notifier_block *unused, | |||
| 810 | break; | 811 | break; |
| 811 | 812 | ||
| 812 | list_for_each_entry_safe(vlan, next, &port->vlans, list) | 813 | list_for_each_entry_safe(vlan, next, &port->vlans, list) |
| 813 | vlan->dev->rtnl_link_ops->dellink(vlan->dev, NULL); | 814 | vlan->dev->rtnl_link_ops->dellink(vlan->dev, &list_kill); |
| 815 | unregister_netdevice_many(&list_kill); | ||
| 816 | list_del(&list_kill); | ||
| 814 | break; | 817 | break; |
| 815 | case NETDEV_PRE_TYPE_CHANGE: | 818 | case NETDEV_PRE_TYPE_CHANGE: |
| 816 | /* Forbid underlaying device to change its type. */ | 819 | /* Forbid underlaying device to change its type. */ |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 5a160f4a1ba0..d2ba2597c75a 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
| @@ -1501,6 +1501,7 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
| 1501 | char ifname[IFNAMSIZ]; | 1501 | char ifname[IFNAMSIZ]; |
| 1502 | struct nlattr *tb[IFLA_MAX+1]; | 1502 | struct nlattr *tb[IFLA_MAX+1]; |
| 1503 | int err; | 1503 | int err; |
| 1504 | LIST_HEAD(list_kill); | ||
| 1504 | 1505 | ||
| 1505 | err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); | 1506 | err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); |
| 1506 | if (err < 0) | 1507 | if (err < 0) |
| @@ -1524,7 +1525,9 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
| 1524 | if (!ops) | 1525 | if (!ops) |
| 1525 | return -EOPNOTSUPP; | 1526 | return -EOPNOTSUPP; |
| 1526 | 1527 | ||
| 1527 | ops->dellink(dev, NULL); | 1528 | ops->dellink(dev, &list_kill); |
| 1529 | unregister_netdevice_many(&list_kill); | ||
| 1530 | list_del(&list_kill); | ||
| 1528 | return 0; | 1531 | return 0; |
| 1529 | } | 1532 | } |
| 1530 | 1533 | ||
