[lxc-devel] [lxc/master] start: Fix net iface remaining issue

ssup2 on Github lxc-bot at linuxcontainers.org
Tue Aug 21 10:24:59 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 557 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180821/b1b8a8ba/attachment.bin>
-------------- next part --------------
From 78852a0c17d1a39858f79ac7a96b2de057a30288 Mon Sep 17 00:00:00 2001
From: Jungsub Shin <supsup5642 at gmail.com>
Date: Tue, 21 Aug 2018 19:21:59 +0900
Subject: [PATCH] start: Fix net iface remaining issue

When creating container that has multiple net ifaces fails
because of wrong net config, lxc doesn't remove previously created
net ifaces.

Solve this issue with changing return path in lxc_spawn().

Signed-off-by: Jungsub Shin jungsub_shin at tmax.co.kr
---
 src/lxc/start.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/lxc/start.c b/src/lxc/start.c
index 35a2bed04..967d23c1b 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -1662,6 +1662,20 @@ static int lxc_spawn(struct lxc_handler *handler)
 		return -1;
 	}
 
+	if (conf->shmount.path_host) {
+		if (!conf->shmount.path_cont) {
+			lxc_sync_fini(handler);
+			return -1;
+		}
+
+		ret = lxc_setup_shmount(conf);
+		if (ret < 0) {
+			ERROR("Failed to setup shared mount point");
+			lxc_sync_fini(handler);
+			return -1;
+		}
+	}
+
 	if (handler->ns_clone_flags & CLONE_NEWNET) {
 		if (!lxc_list_empty(&conf->network)) {
 
@@ -1683,26 +1697,11 @@ static int lxc_spawn(struct lxc_handler *handler)
 			ret = lxc_create_network_priv(handler);
 			if (ret < 0) {
 				ERROR("Failed to create the network");
-				lxc_sync_fini(handler);
-				return -1;
+				goto out_delete_net;
 			}
 		}
 	}
 
-	if (conf->shmount.path_host) {
-		if (!conf->shmount.path_cont) {
-			lxc_sync_fini(handler);
-			return -1;
-		}
-
-		ret = lxc_setup_shmount(conf);
-		if (ret < 0) {
-			ERROR("Failed to setup shared mount point");
-			lxc_sync_fini(handler);
-			return -1;
-		}
-	}
-
 	if (!cgroup_init(handler)) {
 		ERROR("Failed initializing cgroup support");
 		goto out_delete_net;


More information about the lxc-devel mailing list