moby--moby/libnetwork/drivers/bridge/setup_verify.go

27 lines
810 B
Go
Raw Normal View History

package bridge
import "fmt"
func SetupVerifyConfiguredAddresses(i *Interface) error {
// Fetch a single IPv4 and a slice of IPv6 addresses from the bridge.
addrv4, addrsv6, err := i.Addresses()
if err != nil {
return err
}
// Verify that the bridge IPv4 address matches the requested configuration.
if i.Config.AddressIPv4 != nil && !addrv4.IP.Equal(i.Config.AddressIPv4.IP) {
return fmt.Errorf("Bridge IPv4 (%s) does not match requested configuration %s", addrv4.IP, i.Config.AddressIPv4.IP)
}
// Verify that one of the bridge IPv6 addresses matches the requested
// configuration.
for _, addrv6 := range addrsv6 {
if addrv6.String() == BridgeIPv6.String() {
return nil
}
}
return fmt.Errorf("Bridge IPv6 addresses do not match the expected bridge configuration %s", BridgeIPv6)
}