aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-10-27 03:03:04 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-28 05:22:06 -0400
commit44a0873d52282f24b1894c58c0f157e0f626ddc9 (patch)
tree2d913650b6c9474f135546cf06fe5e8d174ef478
parent83ab50a56e6ea94627fea83ce7b03332bd4c2f02 (diff)
net: Introduce unregister_netdevice_queue()
This patchs adds an unreg_list anchor to struct net_device, and introduces an unregister_netdevice_queue() function, able to queue a net_device to a list instead of immediately unregister it. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netdevice.h9
-rw-r--r--net/core/dev.c20
2 files changed, 21 insertions, 8 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 83800091a31a..0ded0a4768a0 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -683,6 +683,7 @@ struct net_device
683 683
684 struct list_head dev_list; 684 struct list_head dev_list;
685 struct list_head napi_list; 685 struct list_head napi_list;
686 struct list_head unreg_list;
686 687
687 /* Net device features */ 688 /* Net device features */
688 unsigned long features; 689 unsigned long features;
@@ -1116,7 +1117,13 @@ extern int dev_close(struct net_device *dev);
1116extern void dev_disable_lro(struct net_device *dev); 1117extern void dev_disable_lro(struct net_device *dev);
1117extern int dev_queue_xmit(struct sk_buff *skb); 1118extern int dev_queue_xmit(struct sk_buff *skb);
1118extern int register_netdevice(struct net_device *dev); 1119extern int register_netdevice(struct net_device *dev);
1119extern void unregister_netdevice(struct net_device *dev); 1120extern void unregister_netdevice_queue(struct net_device *dev,
1121 struct list_head *head);
1122static inline void unregister_netdevice(struct net_device *dev)
1123{
1124 unregister_netdevice_queue(dev, NULL);
1125}
1126
1120extern void free_netdev(struct net_device *dev); 1127extern void free_netdev(struct net_device *dev);
1121extern void synchronize_net(void); 1128extern void synchronize_net(void);
1122extern int register_netdevice_notifier(struct notifier_block *nb); 1129extern int register_netdevice_notifier(struct notifier_block *nb);
diff --git a/net/core/dev.c b/net/core/dev.c
index 950c13fa60d2..ff94e2b8df7f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5245,25 +5245,31 @@ void synchronize_net(void)
5245EXPORT_SYMBOL(synchronize_net); 5245EXPORT_SYMBOL(synchronize_net);
5246 5246
5247/** 5247/**
5248 * unregister_netdevice - remove device from the kernel 5248 * unregister_netdevice_queue - remove device from the kernel
5249 * @dev: device 5249 * @dev: device
5250 * 5250 * @head: list
5251
5251 * This function shuts down a device interface and removes it 5252 * This function shuts down a device interface and removes it
5252 * from the kernel tables. 5253 * from the kernel tables.
5254 * If head not NULL, device is queued to be unregistered later.
5253 * 5255 *
5254 * Callers must hold the rtnl semaphore. You may want 5256 * Callers must hold the rtnl semaphore. You may want
5255 * unregister_netdev() instead of this. 5257 * unregister_netdev() instead of this.
5256 */ 5258 */
5257 5259
5258void unregister_netdevice(struct net_device *dev) 5260void unregister_netdevice_queue(struct net_device *dev, struct list_head *head)
5259{ 5261{
5260 ASSERT_RTNL(); 5262 ASSERT_RTNL();
5261 5263
5262 rollback_registered(dev); 5264 if (head) {
5263 /* Finish processing unregister after unlock */ 5265 list_add_tail(&dev->unreg_list, head);
5264 net_set_todo(dev); 5266 } else {
5267 rollback_registered(dev);
5268 /* Finish processing unregister after unlock */
5269 net_set_todo(dev);
5270 }
5265} 5271}
5266EXPORT_SYMBOL(unregister_netdevice); 5272EXPORT_SYMBOL(unregister_netdevice_queue);
5267 5273
5268/** 5274/**
5269 * unregister_netdev - remove device from the kernel 5275 * unregister_netdev - remove device from the kernel