Skip to content

Commit

Permalink
net: Introduce unregister_netdevice_queue()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Oct 28, 2009
1 parent 83ab50a commit 44a0873
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
9 changes: 8 additions & 1 deletion include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ struct net_device

struct list_head dev_list;
struct list_head napi_list;
struct list_head unreg_list;

/* Net device features */
unsigned long features;
Expand Down Expand Up @@ -1116,7 +1117,13 @@ extern int dev_close(struct net_device *dev);
extern void dev_disable_lro(struct net_device *dev);
extern int dev_queue_xmit(struct sk_buff *skb);
extern int register_netdevice(struct net_device *dev);
extern void unregister_netdevice(struct net_device *dev);
extern void unregister_netdevice_queue(struct net_device *dev,
struct list_head *head);
static inline void unregister_netdevice(struct net_device *dev)
{
unregister_netdevice_queue(dev, NULL);
}

extern void free_netdev(struct net_device *dev);
extern void synchronize_net(void);
extern int register_netdevice_notifier(struct notifier_block *nb);
Expand Down
20 changes: 13 additions & 7 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -5245,25 +5245,31 @@ void synchronize_net(void)
EXPORT_SYMBOL(synchronize_net);

/**
* unregister_netdevice - remove device from the kernel
* unregister_netdevice_queue - remove device from the kernel
* @dev: device
*
* @head: list
* This function shuts down a device interface and removes it
* from the kernel tables.
* If head not NULL, device is queued to be unregistered later.
*
* Callers must hold the rtnl semaphore. You may want
* unregister_netdev() instead of this.
*/

void unregister_netdevice(struct net_device *dev)
void unregister_netdevice_queue(struct net_device *dev, struct list_head *head)
{
ASSERT_RTNL();

rollback_registered(dev);
/* Finish processing unregister after unlock */
net_set_todo(dev);
if (head) {
list_add_tail(&dev->unreg_list, head);
} else {
rollback_registered(dev);
/* Finish processing unregister after unlock */
net_set_todo(dev);
}
}
EXPORT_SYMBOL(unregister_netdevice);
EXPORT_SYMBOL(unregister_netdevice_queue);

/**
* unregister_netdev - remove device from the kernel
Expand Down

0 comments on commit 44a0873

Please sign in to comment.