Merge "citrix" branch into "master".
[sliver-openvswitch.git] / datapath / linux-2.6 / compat-2.6 / dev-ip_gre.c
1 #include <linux/version.h>
2 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
3
4 #include <linux/netdevice.h>
5 #include <linux/rtnetlink.h>
6
7 struct netdev_list {
8         struct list_head unreg_list;
9         struct net_device *dev;
10 };
11
12 /**
13  *      unregister_netdevice_queue - remove device from the kernel
14  *      @dev: device
15  *      @head: list
16
17  *      This function shuts down a device interface and removes it
18  *      from the kernel tables.
19  *      If head not NULL, device is queued to be unregistered later.
20  *
21  *      Callers must hold the rtnl semaphore.  You may want
22  *      unregister_netdev() instead of this.
23  */
24
25 void unregister_netdevice_queue(struct net_device *dev, struct list_head *head)
26 {
27         ASSERT_RTNL();
28
29         if (head) {
30                 struct netdev_list *list_item = kmalloc(sizeof *list_item,
31                                                         GFP_KERNEL);
32                 /* If we can't queue it, probably better to try to destroy it
33                  * now.  Either could potentially be bad but this is probably
34                  * less likely to cause problems. */
35                 if (!list_item) {
36                         unregister_netdevice(dev);
37                         return;
38                 }
39
40                 list_item->dev = dev;
41                 list_add_tail(&list_item->unreg_list, head);
42         } else
43                 unregister_netdevice(dev);
44 }
45
46 /**
47  *      unregister_netdevice_many - unregister many devices
48  *      @head: list of devices
49  *
50  */
51 void unregister_netdevice_many(struct list_head *head)
52 {
53         if (!list_empty(head)) {
54                 struct netdev_list *list_item, *next;
55
56                 list_for_each_entry_safe(list_item, next, head, unreg_list) {
57                         unregister_netdevice(list_item->dev);
58                         kfree(list_item);
59                 }
60         }
61 }
62
63 #endif /* kernel < 2.6.33 */