gvisor/runsc: use a veth link address instead of generating a new one

PiperOrigin-RevId: 248367340
Change-Id: Id792afcfff9c9d2cfd62cae21048316267b4a924
This commit is contained in:
Andrei Vagin
2019-05-15 11:11:58 -07:00
committed by Shentubot
parent dc4a042f3a
commit 85380ff03d
3 changed files with 8 additions and 21 deletions
-4
View File
@@ -153,10 +153,6 @@ run_docker_tests() {
# configuration, e.g. save/restore not supported with hostnet.
declare -a variations=("" "-kvm" "-hostnet" "-overlay")
for v in "${variations[@]}"; do
# FIXME(b/132073574): we need to flush arp tables, otherwise tests fail with
# timeout.
sudo ip neigh show
sudo ip neigh flush dev docker0
# Run runsc tests with docker that are tagged manual.
bazel test \
"${BAZEL_BUILD_FLAGS[@]}" \
+7 -17
View File
@@ -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
}
+1
View File
@@ -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)