Browse code

Merge pull request #32447 from aboch/vnd

Fix container no ipv6 when run container on --network=host

Madhu Venugopal authored on 2017/04/10 07:07:58
Showing 4 changed files
... ...
@@ -428,6 +428,22 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDRAndMac(c *check.C) {
428 428
 	c.Assert(strings.Trim(out, " \r\n'"), checker.Equals, "2001:db8:1::aabb:ccdd:eeff")
429 429
 }
430 430
 
431
+// TestDaemonIPv6HostMode checks that when the running a container with
432
+// network=host the host ipv6 addresses are not removed
433
+func (s *DockerDaemonSuite) TestDaemonIPv6HostMode(c *check.C) {
434
+	testRequires(c, SameHostDaemon)
435
+	deleteInterface(c, "docker0")
436
+
437
+	s.d.StartWithBusybox(c, "--ipv6", "--fixed-cidr-v6=2001:db8:2::/64")
438
+	out, err := s.d.Cmd("run", "-itd", "--name=hostcnt", "--network=host", "busybox:latest")
439
+	c.Assert(err, checker.IsNil, check.Commentf("Could not run container: %s, %v", out, err))
440
+
441
+	out, err = s.d.Cmd("exec", "hostcnt", "ip", "-6", "addr", "show", "docker0")
442
+	out = strings.Trim(out, " \r\n'")
443
+
444
+	c.Assert(out, checker.Contains, "2001:db8:2::1")
445
+}
446
+
431 447
 func (s *DockerDaemonSuite) TestDaemonLogLevelWrong(c *check.C) {
432 448
 	c.Assert(s.d.StartWithError("--log-level=bogus"), check.NotNil, check.Commentf("Daemon shouldn't start with wrong log level"))
433 449
 }
... ...
@@ -24,7 +24,7 @@ github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5
24 24
 github.com/imdario/mergo 0.2.1
25 25
 
26 26
 #get libnetwork packages
27
-github.com/docker/libnetwork f3c4ca8ce5c128e071bab198c4ed9fd0d08384eb
27
+github.com/docker/libnetwork ab8f7e61743aa7e54c5d0dad0551543adadc33cf
28 28
 github.com/docker/go-events 18b43f1bc85d9cdd42c05a6cd2d444c7a200a894
29 29
 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
30 30
 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
... ...
@@ -151,7 +151,6 @@ func checkRunning() bool {
151 151
 
152 152
 	if connection != nil {
153 153
 		err = connection.sysobj.Call(dbusInterface+".getDefaultZone", 0).Store(&zone)
154
-		logrus.Infof("Firewalld running: %t", err == nil)
155 154
 		return err == nil
156 155
 	}
157 156
 	return false
... ...
@@ -222,9 +222,11 @@ func NewSandbox(key string, osCreate, isRestore bool) (Sandbox, error) {
222 222
 	}
223 223
 
224 224
 	// As starting point, disable IPv6 on all interfaces
225
-	err = setIPv6(n.path, "all", false)
226
-	if err != nil {
227
-		logrus.Warnf("Failed to disable IPv6 on all interfaces on network namespace %q: %v", n.path, err)
225
+	if !n.isDefault {
226
+		err = setIPv6(n.path, "all", false)
227
+		if err != nil {
228
+			logrus.Warnf("Failed to disable IPv6 on all interfaces on network namespace %q: %v", n.path, err)
229
+		}
228 230
 	}
229 231
 
230 232
 	if err = n.loopbackUp(); err != nil {