diff options
Diffstat (limited to 'runsc')
-rw-r--r-- | runsc/boot/network.go | 24 | ||||
-rw-r--r-- | runsc/sandbox/network.go | 1 |
2 files changed, 8 insertions, 17 deletions
diff --git a/runsc/boot/network.go b/runsc/boot/network.go index 598ec969e..0a154d90b 100644 --- a/runsc/boot/network.go +++ b/runsc/boot/network.go @@ -16,7 +16,6 @@ package boot import ( "fmt" - "math/rand" "net" "syscall" @@ -52,11 +51,12 @@ type DefaultRoute struct { // FDBasedLink configures an fd-based link. type FDBasedLink struct { - Name string - MTU int - Addresses []net.IP - Routes []Route - GSOMaxSize uint32 + Name string + MTU int + Addresses []net.IP + Routes []Route + GSOMaxSize uint32 + LinkAddress []byte } // LoopbackLink configures a loopback li nk. @@ -134,7 +134,7 @@ func (n *Network) CreateLinksAndRoutes(args *CreateLinksAndRoutesArgs, _ *struct return fmt.Errorf("failed to dup FD %v: %v", oldFD, err) } - mac := tcpip.LinkAddress(generateRndMac()) + mac := tcpip.LinkAddress(link.LinkAddress) linkEP, err := fdbased.New(&fdbased.Options{ FD: newFD, MTU: uint32(link.MTU), @@ -220,13 +220,3 @@ func ipToAddressMask(ip net.IP) tcpip.AddressMask { _, addr := ipToAddressAndProto(ip) return tcpip.AddressMask(addr) } - -// generateRndMac returns a random local MAC address. -// Copied from eth_random_addr() (include/linux/etherdevice.h) -func generateRndMac() net.HardwareAddr { - mac := make(net.HardwareAddr, 6) - rand.Read(mac) - mac[0] &^= 0x1 // clear multicast bit - mac[0] |= 0x2 // set local assignment bit (IEEE802) - return mac -} diff --git a/runsc/sandbox/network.go b/runsc/sandbox/network.go index 2a68d7043..0460d5f1a 100644 --- a/runsc/sandbox/network.go +++ b/runsc/sandbox/network.go @@ -246,6 +246,7 @@ func createInterfacesAndRoutesFromNS(conn *urpc.Client, nsPath string, enableGSO if err != nil { return fmt.Errorf("getting link for interface %q: %v", iface.Name, err) } + link.LinkAddress = []byte(ifaceLink.Attrs().HardwareAddr) if enableGSO { gso, err := isGSOEnabled(fd, iface.Name) |