Browse Source

Fix issue in ipv6 when a non-default link-local ipv6 address is present.

If the bridge exists and it exists with a different link local ip address
than fe80::1/64 then we waifl to accept that as a valid configuration without
trying to add the default link local ip address. With this fix we always try
to add the default link local address if it doesn't exist.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
Jana Radhakrishnan 10 năm trước cách đây
mục cha
commit
79556b1ccc

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

@@ -190,7 +190,7 @@ func (ipv4 *IPv4AddrNoMatchError) Error() string {
 type IPv6AddrNoMatchError net.IPNet
 type IPv6AddrNoMatchError net.IPNet
 
 
 func (ipv6 *IPv6AddrNoMatchError) Error() string {
 func (ipv6 *IPv6AddrNoMatchError) Error() string {
-	return fmt.Sprintf("bridge IPv6 addresses do not match the expected bridge configuration %s", ipv6)
+	return fmt.Sprintf("bridge IPv6 addresses do not match the expected bridge configuration %s", (*net.IPNet)(ipv6).String())
 }
 }
 
 
 // InvalidLinkIPAddrError is returned when a link is configured to a container with an invalid ip address
 // InvalidLinkIPAddrError is returned when a link is configured to a container with an invalid ip address

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

@@ -34,7 +34,8 @@ func setupBridgeIPv6(config *NetworkConfiguration, i *bridgeInterface) error {
 		return err
 		return err
 	}
 	}
 
 
-	if len(addrsv6) == 0 {
+	// Add the default link local ipv6 address if it doesn't exist
+	if !findIPv6Address(netlink.Addr{IPNet: bridgeIPv6}, addrsv6) {
 		if err := netlink.AddrAdd(i.Link, &netlink.Addr{IPNet: bridgeIPv6}); err != nil {
 		if err := netlink.AddrAdd(i.Link, &netlink.Addr{IPNet: bridgeIPv6}); err != nil {
 			return &IPv6AddrAddError{ip: bridgeIPv6, err: err}
 			return &IPv6AddrAddError{ip: bridgeIPv6, err: err}
 		}
 		}