1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Re-arrange MAC election code for sandbox iface

- in bridge.go

Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
Alessandro Boch 2015-05-01 13:51:17 -07:00
parent 3e19e4cff9
commit bfc5721970

View file

@ -404,12 +404,8 @@ func (d *driver) CreateEndpoint(nid, eid types.UUID, epOptions map[string]interf
}
}()
mac := netutils.GenerateRandomMAC()
// Add user specified attributes
if epConfig != nil && epConfig.MacAddress != nil {
mac = epConfig.MacAddress
}
// Set the sbox's MAC. If specified, use the one configured by user, otherwise use a random one
mac := electMacAddress(epConfig)
err = netlink.LinkSetHardwareAddr(sbox, mac)
if err != nil {
return nil, err
@ -613,6 +609,13 @@ func parseContainerOptions(cOptions interface{}) (*ContainerConfiguration, error
}
}
func electMacAddress(epConfig *EndpointConfiguration) net.HardwareAddr {
if epConfig != nil && epConfig.MacAddress != nil {
return epConfig.MacAddress
}
return netutils.GenerateRandomMAC()
}
// Generates a name to be used for a virtual ethernet
// interface. The name is constructed by 'veth' appended
// by a randomly generated hex value. (example: veth0f60e2c)