Browse code

Properly initialize IpamConf structure in initBridgeDriver

Signed-off-by: Alessandro Boch <aboch@docker.com>

Alessandro Boch authored on 2015/12/31 07:51:51
Showing 2 changed files
... ...
@@ -584,14 +584,14 @@ func initBridgeDriver(controller libnetwork.NetworkController, config *Config) e
584 584
 		deferIPv6Alloc = ones <= 80
585 585
 
586 586
 		if ipamV6Conf == nil {
587
-			ipamV6Conf = &libnetwork.IpamConf{}
587
+			ipamV6Conf = &libnetwork.IpamConf{AuxAddresses: make(map[string]string)}
588 588
 		}
589 589
 		ipamV6Conf.PreferredPool = fCIDRv6.String()
590 590
 	}
591 591
 
592 592
 	if config.Bridge.DefaultGatewayIPv6 != nil {
593 593
 		if ipamV6Conf == nil {
594
-			ipamV6Conf = &libnetwork.IpamConf{}
594
+			ipamV6Conf = &libnetwork.IpamConf{AuxAddresses: make(map[string]string)}
595 595
 		}
596 596
 		ipamV6Conf.AuxAddresses["DefaultGatewayIPv6"] = config.Bridge.DefaultGatewayIPv6.String()
597 597
 	}
... ...
@@ -334,15 +334,13 @@ func (s *DockerSuite) TestDaemonIPv6Enabled(c *check.C) {
334 334
 // TestDaemonIPv6FixedCIDR checks that when the daemon is started with --ipv6=true and a fixed CIDR
335 335
 // that running containers are given a link-local and global IPv6 address
336 336
 func (s *DockerSuite) TestDaemonIPv6FixedCIDR(c *check.C) {
337
-	testRequires(c, IPv6)
338
-
339 337
 	if err := setupV6(); err != nil {
340 338
 		c.Fatal("Could not set up host for IPv6 tests")
341 339
 	}
342 340
 
343 341
 	d := NewDaemon(c)
344 342
 
345
-	if err := d.StartWithBusybox("--ipv6", "--fixed-cidr-v6='2001:db8:1::/64'"); err != nil {
343
+	if err := d.StartWithBusybox("--ipv6", "--fixed-cidr-v6='2001:db8:2::/64'", "--default-gateway-v6='2001:db8:2::100'"); err != nil {
346 344
 		c.Fatalf("Could not start daemon with busybox: %v", err)
347 345
 	}
348 346
 	defer d.Stop()
... ...
@@ -351,18 +349,7 @@ func (s *DockerSuite) TestDaemonIPv6FixedCIDR(c *check.C) {
351 351
 		c.Fatalf("Could not run container: %s, %v", out, err)
352 352
 	}
353 353
 
354
-	out, err := d.Cmd("inspect", "--format", "'{{.NetworkSettings.Networks.bridge.LinkLocalIPv6Address}}'", "ipv6test")
355
-	out = strings.Trim(out, " \r\n'")
356
-
357
-	if err != nil {
358
-		c.Fatalf("Error inspecting container: %s, %v", out, err)
359
-	}
360
-
361
-	if ip := net.ParseIP(out); ip == nil {
362
-		c.Fatalf("Container should have a link-local IPv6 address")
363
-	}
364
-
365
-	out, err = d.Cmd("inspect", "--format", "'{{.NetworkSettings.Networks.bridge.GlobalIPv6Address}}'", "ipv6test")
354
+	out, err := d.Cmd("inspect", "--format", "'{{.NetworkSettings.Networks.bridge.GlobalIPv6Address}}'", "ipv6test")
366 355
 	out = strings.Trim(out, " \r\n'")
367 356
 
368 357
 	if err != nil {
... ...
@@ -372,6 +359,8 @@ func (s *DockerSuite) TestDaemonIPv6FixedCIDR(c *check.C) {
372 372
 	if ip := net.ParseIP(out); ip == nil {
373 373
 		c.Fatalf("Container should have a global IPv6 address")
374 374
 	}
375
+
376
+	// TODO: Check IPv6 def gateway in inspect o/p (once docker/docker 19001 is merged
375 377
 	if err := teardownV6(); err != nil {
376 378
 		c.Fatal("Could not perform teardown for IPv6 tests")
377 379
 	}