mirror of
https://github.com/clearlinux/libnetwork.git
synced 2026-10-04 07:48:30 +00: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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user