From 911ecc3376d4b140953512f0a7689820192e1873 Mon Sep 17 00:00:00 2001 From: Arko Dasgupta Date: Mon, 10 Feb 2020 17:34:30 -0800 Subject: [PATCH] Set the bip network value as the subnet Dont assign the --bip value directly to the subnet for the default bridge. Instead use the network value from the ParseCIDR output Addresses: https://github.com/moby/moby/issues/40392 Signed-off-by: Arko Dasgupta (cherry picked from commit f800d5f786f733f7cbb3e53e0197685043d67dc1) Signed-off-by: Sebastiaan van Stijn --- daemon/daemon_unix.go | 4 ++-- integration/network/service_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index bc0ba221fa..ced292bc1b 100644 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -967,11 +967,11 @@ func initBridgeDriver(controller libnetwork.NetworkController, config *config.Co } if config.BridgeConfig.IP != "" { - ipamV4Conf.PreferredPool = config.BridgeConfig.IP - ip, _, err := net.ParseCIDR(config.BridgeConfig.IP) + ip, ipNet, err := net.ParseCIDR(config.BridgeConfig.IP) if err != nil { return err } + ipamV4Conf.PreferredPool = ipNet.String() ipamV4Conf.Gateway = ip.String() } else if bridgeName == bridge.DefaultBridgeName && ipamV4Conf.PreferredPool != "" { logrus.Infof("Default bridge (%s) is assigned with an IP address %s. Daemon option --bip can be used to set a preferred IP address", bridgeName, ipamV4Conf.PreferredPool) diff --git a/integration/network/service_test.go b/integration/network/service_test.go index e6d417b0c9..f0300befcf 100644 --- a/integration/network/service_test.go +++ b/integration/network/service_test.go @@ -193,7 +193,7 @@ func TestDaemonWithBipAndDefaultNetworkPool(t *testing.T) { out, err := c.NetworkInspect(context.Background(), "bridge", types.NetworkInspectOptions{}) assert.NilError(t, err) // Make sure BIP IP doesn't get override with new default address pool . - assert.Equal(t, out.IPAM.Config[0].Subnet, "172.60.0.1/16") + assert.Equal(t, out.IPAM.Config[0].Subnet, "172.60.0.0/16") delInterface(t, defaultNetworkBridge) }