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

Disable DAD for sandbox IPv6 addresses

Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
Alessandro Boch 2016-01-05 11:35:53 -08:00
parent abaaa23a8c
commit 31016faad5
4 changed files with 52 additions and 2 deletions

View file

@ -4,7 +4,7 @@ build_image=libnetworkbuild
dockerargs = --privileged -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork
container_env = -e "INSIDECONTAINER=-incontainer=true"
docker = docker run --rm -it ${dockerargs} $$EXTRA_ARGS ${container_env} ${build_image}
ciargs = -e "COVERALLS_TOKEN=$$COVERALLS_TOKEN" -e "INSIDECONTAINER=-incontainer=true"
ciargs = -e CIRCLECI -e "COVERALLS_TOKEN=$$COVERALLS_TOKEN" -e "INSIDECONTAINER=-incontainer=true"
cidocker = docker run ${dockerargs} ${ciargs} ${container_env} ${build_image}
CROSS_PLATFORMS = linux/amd64 linux/386 linux/arm windows/amd64 windows/386

View file

@ -6,6 +6,7 @@ import (
"os/exec"
"regexp"
"sync"
"syscall"
"github.com/docker/libnetwork/types"
"github.com/vishvananda/netlink"
@ -337,7 +338,7 @@ func setInterfaceIPv6(iface netlink.Link, i *nwIface) error {
if i.AddressIPv6() == nil {
return nil
}
ipAddr := &netlink.Addr{IPNet: i.AddressIPv6(), Label: ""}
ipAddr := &netlink.Addr{IPNet: i.AddressIPv6(), Label: "", Flags: syscall.IFA_F_NODAD}
return netlink.AddrAdd(iface, ipAddr)
}

View file

@ -5,12 +5,15 @@ import (
"os"
"path/filepath"
"runtime"
"syscall"
"testing"
"time"
"github.com/docker/libnetwork/netutils"
"github.com/docker/libnetwork/testutils"
"github.com/docker/libnetwork/types"
"github.com/vishvananda/netlink"
"github.com/vishvananda/netlink/nl"
"github.com/vishvananda/netns"
)
@ -179,3 +182,43 @@ func TestScanStatistics(t *testing.T) {
t.Fatalf("Error scanning the statistics")
}
}
func TestDisableIPv6DAD(t *testing.T) {
if testutils.RunningOnCircleCI() {
t.Skipf("Skipping as not supported on CIRCLE CI kernel")
}
defer testutils.SetupTestOSContext(t)()
ipv6, _ := types.ParseCIDR("2001:db8::44/64")
iface := &nwIface{addressIPv6: ipv6}
veth := &netlink.Veth{
LinkAttrs: netlink.LinkAttrs{Name: "sideA"},
PeerName: "sideB",
}
err := netlink.LinkAdd(veth)
if err != nil {
t.Fatal(err)
}
link, err := netlink.LinkByName("sideA")
if err != nil {
t.Fatal(err)
}
err = setInterfaceIPv6(link, iface)
if err != nil {
t.Fatal(err)
}
addrList, err := netlink.AddrList(link, nl.FAMILY_V6)
if err != nil {
t.Fatal(err)
}
if addrList[0].Flags&syscall.IFA_F_NODAD == 0 {
t.Fatalf("Unexpected interface flags: 0x%x. Expected to contain 0x%x", addrList[0].Flags, syscall.IFA_F_NODAD)
}
}

View file

@ -1,6 +1,7 @@
package testutils
import (
"os"
"runtime"
"syscall"
"testing"
@ -37,3 +38,8 @@ func SetupTestOSContext(t *testing.T) func() {
runtime.UnlockOSThread()
}
}
// RunningOnCircleCI returns true if being executed on libnetwork Circle CI setup
func RunningOnCircleCI() bool {
return os.Getenv("CIRCLECI") != ""
}