]> git.proxmox.com Git - mirror_lxc.git/commitdiff
Fix network cleanup on error
authorDaniel Lezcano <daniel.lezcano@free.fr>
Thu, 5 Jan 2012 21:45:32 +0000 (22:45 +0100)
committerDaniel Lezcano <daniel.lezcano@free.fr>
Thu, 5 Jan 2012 21:45:32 +0000 (22:45 +0100)
Network cleanup does not cleanup correctly the virtual interfaces
in case of an error.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/conf.c
src/lxc/start.c

index 41039d7a3fd46a5a72f5e6fe837a2f4d5408b0d5..5e41d382ce61d535bce7a9509de5b3e5a867fd34 100644 (file)
@@ -1702,13 +1702,19 @@ void lxc_delete_network(struct lxc_list *network)
                if (netdev->ifindex == 0)
                        continue;
 
-               /* Recent kernels already delete the virtual devices */
-               if (netdev->type != LXC_NET_PHYS)
+               if (netdev->type == LXC_NET_PHYS) {
+                       if (lxc_netdev_rename_by_index(netdev->ifindex, netdev->link))
+                               WARN("failed to rename to the initial name the " \
+                                    "netdev '%s'", netdev->link);
                        continue;
+               }
 
-               if (lxc_netdev_rename_by_index(netdev->ifindex, netdev->link))
-                       WARN("failed to rename to the initial name the netdev '%s'",
-                            netdev->link);
+               /* Recent kernel remove the virtual interfaces when the network
+                * namespace is destroyed but in case we did not moved the
+                * interface to the network namespace, we have to destroy it
+                */
+               if (lxc_netdev_delete_by_index(netdev->ifindex))
+                       WARN("failed to remove interface '%s'", netdev->name);
        }
 }
 
index 334262d7ea91d1c04ab5f155449672b694a8db16..18f6878c689a5eb60302979fa2d3c0de176e4d46 100644 (file)
@@ -490,7 +490,6 @@ int lxc_spawn(struct lxc_handler *handler)
                }
        }
 
-
        /* Create a process in a new set of namespaces */
        handler->pid = lxc_clone(do_start, handler, clone_flags);
        if (handler->pid < 0) {