diff options
author | 2012-01-05 22:45:32 +0100 | |
---|---|---|
committer | 2012-01-05 22:45:32 +0100 | |
commit | d8f8e35202d9f84ca69cc4c65aeda0febb934e39 (patch) | |
tree | 90e2fb349575b25dbba693c27156280badd21bec /src | |
parent | give explicit error when the cgroup are not found (diff) | |
download | lxc-d8f8e35202d9f84ca69cc4c65aeda0febb934e39.tar.gz lxc-d8f8e35202d9f84ca69cc4c65aeda0febb934e39.tar.bz2 lxc-d8f8e35202d9f84ca69cc4c65aeda0febb934e39.zip |
Fix network cleanup on error
Network cleanup does not cleanup correctly the virtual interfaces
in case of an error.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/lxc/conf.c | 16 | ||||
-rw-r--r-- | src/lxc/start.c | 1 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 41039d7..5e41d38 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -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); } } diff --git a/src/lxc/start.c b/src/lxc/start.c index 334262d..18f6878 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -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) { |