summaryrefslogtreecommitdiffhomepage
path: root/runsc/boot
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@google.com>2019-05-15 11:10:56 -0700
committerShentubot <shentubot@google.com>2019-05-15 11:11:58 -0700
commit85380ff03d21da417ad74d28b293c768d7effb4f (patch)
treef5a5edf12da71a1fe9c8f0d7f7e3a6bb1557fbbd /runsc/boot
parentdc4a042f3a6810f6d1d96eff9c40651621b4692b (diff)
gvisor/runsc: use a veth link address instead of generating a new one
PiperOrigin-RevId: 248367340 Change-Id: Id792afcfff9c9d2cfd62cae21048316267b4a924
Diffstat (limited to 'runsc/boot')
-rw-r--r--runsc/boot/network.go24
1 files changed, 7 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
-}