aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-10-27 03:06:36 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-28 05:22:07 -0400
commit23289a37e2b127dfc4de1313fba15bb4c9f0cd5b (patch)
tree209edb2cb43dedb97477e1297873ada4759a1066
parent9b5e383c11b08784eb0087617f880077982ef769 (diff)
net: add a list_head parameter to dellink() method
Adding a list_head parameter to rtnl_link_ops->dellink() methods allow us to queue devices on a list, in order to dismantle them all at once. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/macvlan.c6
-rw-r--r--drivers/net/veth.c2
-rw-r--r--include/net/rtnetlink.h3
-rw-r--r--net/8021q/vlan.c8
-rw-r--r--net/8021q/vlan.h2
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/rtnetlink.c14
7 files changed, 19 insertions, 18 deletions
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 3aabfd9dd21..20b7707f38e 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -555,13 +555,13 @@ static int macvlan_newlink(struct net_device *dev,
555 return 0; 555 return 0;
556} 556}
557 557
558static void macvlan_dellink(struct net_device *dev) 558static void macvlan_dellink(struct net_device *dev, struct list_head *head)
559{ 559{
560 struct macvlan_dev *vlan = netdev_priv(dev); 560 struct macvlan_dev *vlan = netdev_priv(dev);
561 struct macvlan_port *port = vlan->port; 561 struct macvlan_port *port = vlan->port;
562 562
563 list_del(&vlan->list); 563 list_del(&vlan->list);
564 unregister_netdevice(dev); 564 unregister_netdevice_queue(dev, head);
565 565
566 if (list_empty(&port->vlans)) 566 if (list_empty(&port->vlans))
567 macvlan_port_destroy(port->dev); 567 macvlan_port_destroy(port->dev);
@@ -601,7 +601,7 @@ static int macvlan_device_event(struct notifier_block *unused,
601 break; 601 break;
602 case NETDEV_UNREGISTER: 602 case NETDEV_UNREGISTER:
603 list_for_each_entry_safe(vlan, next, &port->vlans, list) 603 list_for_each_entry_safe(vlan, next, &port->vlans, list)
604 macvlan_dellink(vlan->dev); 604 macvlan_dellink(vlan->dev, NULL);
605 break; 605 break;
606 } 606 }
607 return NOTIFY_DONE; 607 return NOTIFY_DONE;
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index ade5b344f75..ffb502daa91 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -442,7 +442,7 @@ err_register_peer:
442 return err; 442 return err;
443} 443}
444 444
445static void veth_dellink(struct net_device *dev) 445static void veth_dellink(struct net_device *dev, struct list_head *head)
446{ 446{
447 struct veth_priv *priv; 447 struct veth_priv *priv;
448 struct net_device *peer; 448 struct net_device *peer;
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index c3aa044d3fc..cd5af1f508f 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -61,7 +61,8 @@ struct rtnl_link_ops {
61 int (*changelink)(struct net_device *dev, 61 int (*changelink)(struct net_device *dev,
62 struct nlattr *tb[], 62 struct nlattr *tb[],
63 struct nlattr *data[]); 63 struct nlattr *data[]);
64 void (*dellink)(struct net_device *dev); 64 void (*dellink)(struct net_device *dev,
65 struct list_head *head);
65 66
66 size_t (*get_size)(const struct net_device *dev); 67 size_t (*get_size)(const struct net_device *dev);
67 int (*fill_info)(struct sk_buff *skb, 68 int (*fill_info)(struct sk_buff *skb,
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 8836575f9d7..6b5c9dddaa7 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -140,7 +140,7 @@ static void vlan_rcu_free(struct rcu_head *rcu)
140 vlan_group_free(container_of(rcu, struct vlan_group, rcu)); 140 vlan_group_free(container_of(rcu, struct vlan_group, rcu));
141} 141}
142 142
143void unregister_vlan_dev(struct net_device *dev) 143void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
144{ 144{
145 struct vlan_dev_info *vlan = vlan_dev_info(dev); 145 struct vlan_dev_info *vlan = vlan_dev_info(dev);
146 struct net_device *real_dev = vlan->real_dev; 146 struct net_device *real_dev = vlan->real_dev;
@@ -164,7 +164,7 @@ void unregister_vlan_dev(struct net_device *dev)
164 164
165 synchronize_net(); 165 synchronize_net();
166 166
167 unregister_netdevice(dev); 167 unregister_netdevice_queue(dev, head);
168 168
169 /* If the group is now empty, kill off the group. */ 169 /* If the group is now empty, kill off the group. */
170 if (grp->nr_vlans == 0) { 170 if (grp->nr_vlans == 0) {
@@ -535,7 +535,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
535 if (grp->nr_vlans == 1) 535 if (grp->nr_vlans == 1)
536 i = VLAN_GROUP_ARRAY_LEN; 536 i = VLAN_GROUP_ARRAY_LEN;
537 537
538 unregister_vlan_dev(vlandev); 538 unregister_vlan_dev(vlandev, NULL);
539 } 539 }
540 break; 540 break;
541 } 541 }
@@ -642,7 +642,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
642 err = -EPERM; 642 err = -EPERM;
643 if (!capable(CAP_NET_ADMIN)) 643 if (!capable(CAP_NET_ADMIN))
644 break; 644 break;
645 unregister_vlan_dev(dev); 645 unregister_vlan_dev(dev, NULL);
646 err = 0; 646 err = 0;
647 break; 647 break;
648 648
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 4ade5edf103..68f9290e683 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -82,7 +82,7 @@ void vlan_dev_get_realdev_name(const struct net_device *dev, char *result);
82int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id); 82int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id);
83void vlan_setup(struct net_device *dev); 83void vlan_setup(struct net_device *dev);
84int register_vlan_dev(struct net_device *dev); 84int register_vlan_dev(struct net_device *dev);
85void unregister_vlan_dev(struct net_device *dev); 85void unregister_vlan_dev(struct net_device *dev, struct list_head *head);
86 86
87static inline u32 vlan_get_ingress_priority(struct net_device *dev, 87static inline u32 vlan_get_ingress_priority(struct net_device *dev,
88 u16 vlan_tci) 88 u16 vlan_tci)
diff --git a/net/core/dev.c b/net/core/dev.c
index 04d3e301402..4513dfd5718 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5629,7 +5629,7 @@ restart:
5629 5629
5630 /* Delete virtual devices */ 5630 /* Delete virtual devices */
5631 if (dev->rtnl_link_ops && dev->rtnl_link_ops->dellink) { 5631 if (dev->rtnl_link_ops && dev->rtnl_link_ops->dellink) {
5632 dev->rtnl_link_ops->dellink(dev); 5632 dev->rtnl_link_ops->dellink(dev, NULL);
5633 goto restart; 5633 goto restart;
5634 } 5634 }
5635 5635
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 52ea418d530..391a62cd9df 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -248,7 +248,7 @@ static LIST_HEAD(link_ops);
248int __rtnl_link_register(struct rtnl_link_ops *ops) 248int __rtnl_link_register(struct rtnl_link_ops *ops)
249{ 249{
250 if (!ops->dellink) 250 if (!ops->dellink)
251 ops->dellink = unregister_netdevice; 251 ops->dellink = unregister_netdevice_queue;
252 252
253 list_add_tail(&ops->list, &link_ops); 253 list_add_tail(&ops->list, &link_ops);
254 return 0; 254 return 0;
@@ -277,13 +277,13 @@ EXPORT_SYMBOL_GPL(rtnl_link_register);
277static void __rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops) 277static void __rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops)
278{ 278{
279 struct net_device *dev; 279 struct net_device *dev;
280restart: 280 LIST_HEAD(list_kill);
281
281 for_each_netdev(net, dev) { 282 for_each_netdev(net, dev) {
282 if (dev->rtnl_link_ops == ops) { 283 if (dev->rtnl_link_ops == ops)
283 ops->dellink(dev); 284 ops->dellink(dev, &list_kill);
284 goto restart;
285 }
286 } 285 }
286 unregister_netdevice_many(&list_kill);
287} 287}
288 288
289void rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops) 289void rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops)
@@ -972,7 +972,7 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
972 if (!ops) 972 if (!ops)
973 return -EOPNOTSUPP; 973 return -EOPNOTSUPP;
974 974
975 ops->dellink(dev); 975 ops->dellink(dev, NULL);
976 return 0; 976 return 0;
977} 977}
978 978