Browse Source

Fixed a bug in bridge driver where when the bridge already exists
the bridgeInterface.bridgeIPv4 is not getting initialized properly

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>

Jana Radhakrishnan 10 years ago
parent
commit
b0a38a0d1b
2 changed files with 8 additions and 2 deletions
  1. 1 1
      libnetwork/drivers/bridge/bridge.go
  2. 7 1
      libnetwork/drivers/bridge/setup_verify.go

+ 1 - 1
libnetwork/drivers/bridge/bridge.go

@@ -156,7 +156,7 @@ func (d *driver) CreateNetwork(id driverapi.UUID, option interface{}) error {
 
 		// We ensure that the bridge has the expectedIPv4 and IPv6 addresses in
 		// the case of a previously existing device.
-		{bridgeAlreadyExists, setupVerifyConfiguredAddresses},
+		{bridgeAlreadyExists, setupVerifyAndReconcile},
 
 		// Setup the bridge to allocate containers IPv4 addresses in the
 		// specified subnet.

+ 7 - 1
libnetwork/drivers/bridge/setup_verify.go

@@ -6,7 +6,7 @@ import (
 	"github.com/vishvananda/netlink"
 )
 
-func setupVerifyConfiguredAddresses(config *Configuration, i *bridgeInterface) error {
+func setupVerifyAndReconcile(config *Configuration, i *bridgeInterface) error {
 	// Fetch a single IPv4 and a slice of IPv6 addresses from the bridge.
 	addrv4, addrsv6, err := i.addresses()
 	if err != nil {
@@ -29,6 +29,12 @@ func setupVerifyConfiguredAddresses(config *Configuration, i *bridgeInterface) e
 		return fmt.Errorf("Bridge IPv6 addresses do not match the expected bridge configuration %s", bridgeIPv6)
 	}
 
+	// By this time we have either configured a new bridge with an IP address
+	// or made sure an existing bridge's IP matches the configuration
+	// Now is the time to cache these states in the bridgeInterface.
+	i.bridgeIPv4 = addrv4.IPNet
+	i.bridgeIPv6 = bridgeIPv6
+
 	return nil
 }