From caeb202a8a95863a44fa8f45e0515437239b173c Mon Sep 17 00:00:00 2001
From: dengguangxing <dengguangxing@huawei.com>
Date: Wed, 16 May 2018 15:16:51 +0800
Subject: [PATCH 48/94] runc: Only configure networking

[Changelog]: Only configure networking when creating a net ns
When joining an existing namespace, don't default to configuring a
loopback interface in that namespace.

Its creator should have done that, and we don't want to fail to create
the container when we don't have sufficient privileges to configure the
network namespace.

This is cherry-picked from runc upstream:
 https://github.com/opencontainers/runc/pull/1777
[Author]:Shukui Yang

Change-Id: I1f181f18e23c621db6718a185e35b50531d27c09
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Signed-off-by: dengguangxing <dengguangxing@huawei.com>
---
 libcontainer/specconv/spec_linux.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcontainer/specconv/spec_linux.go b/libcontainer/specconv/spec_linux.go
index 8a2947f..a968313 100644
--- a/libcontainer/specconv/spec_linux.go
+++ b/libcontainer/specconv/spec_linux.go
@@ -194,7 +194,7 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) {
 		}
 		config.Namespaces.Add(t, ns.Path)
 	}
-	if config.Namespaces.Contains(configs.NEWNET) {
+	if config.Namespaces.Contains(configs.NEWNET) && config.Namespaces.PathOf(configs.NEWNET) == "" {
 		config.Networks = []*configs.Network{
 			{
 				Type: "loopback",
-- 
2.7.4.3

