From 79b37def4829bb1e9606e8131d6bb0ef0496f006 Mon Sep 17 00:00:00 2001 From: Alessandro Boch Date: Thu, 15 Oct 2015 22:16:40 -0700 Subject: [PATCH] Explicitly set namepsace for ipamutils.ElectInterface Signed-off-by: Alessandro Boch --- libnetwork/drivers/bridge/bridge_test.go | 3 +++ libnetwork/ipamutils/utils_linux.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/libnetwork/drivers/bridge/bridge_test.go b/libnetwork/drivers/bridge/bridge_test.go index b7677eeb85..9aafe85d50 100644 --- a/libnetwork/drivers/bridge/bridge_test.go +++ b/libnetwork/drivers/bridge/bridge_test.go @@ -218,6 +218,9 @@ func TestCreateMultipleNetworks(t *testing.T) { t.Fatalf("Failed to create bridge: %v", err) } + // Verify the network isolation rules are installed, each network subnet should appear 2 times + verifyV4INCEntries(d.networks, 2, t) + config3 := &networkConfiguration{BridgeName: "net_test_3"} genericOption[netlabel.GenericData] = config3 if err := d.CreateNetwork("3", genericOption, getIPv4Data(t), nil); err != nil { diff --git a/libnetwork/ipamutils/utils_linux.go b/libnetwork/ipamutils/utils_linux.go index d8c9eb8a1c..9706cf39cd 100644 --- a/libnetwork/ipamutils/utils_linux.go +++ b/libnetwork/ipamutils/utils_linux.go @@ -6,6 +6,7 @@ import ( "net" "github.com/docker/libnetwork/netutils" + "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/resolvconf" "github.com/vishvananda/netlink" ) @@ -21,6 +22,8 @@ func ElectInterfaceAddresses(name string) (*net.IPNet, []*net.IPNet, error) { err error ) + defer osl.InitOSContext()() + link, _ := netlink.LinkByName(name) if link != nil { v4addr, err := netlink.AddrList(link, netlink.FAMILY_V4)