mirror of
https://github.com/clearlinux/libnetwork.git
synced 2026-09-01 11:25:59 +00:00
Explicitly set namespace for all network operations
Make sure to always explicitly set namespace for all kernel bound network operations irrespective of whether the operation is performed in init namespace or a user defined namespace. This already happens for user defined netns. But doesn't happen for initial netns that libnetwork runs in. Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
This commit is contained in:
+22
-22
@@ -257,7 +257,7 @@ func TestHost(t *testing.T) {
|
||||
|
||||
func TestBridge(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
ip, subnet, err := net.ParseCIDR("192.168.100.1/24")
|
||||
@@ -330,7 +330,7 @@ func TestBridge(t *testing.T) {
|
||||
|
||||
func TestUnknownDriver(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
_, err := createTestNetwork("unknowndriver", "testnetwork", options.Generic{})
|
||||
@@ -357,7 +357,7 @@ func TestNilRemoteDriver(t *testing.T) {
|
||||
|
||||
func TestDuplicateNetwork(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
// Creating a default bridge name network (can't be removed)
|
||||
@@ -378,7 +378,7 @@ func TestDuplicateNetwork(t *testing.T) {
|
||||
|
||||
func TestNetworkName(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
netOption := options.Generic{
|
||||
@@ -415,7 +415,7 @@ func TestNetworkName(t *testing.T) {
|
||||
|
||||
func TestNetworkType(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
netOption := options.Generic{
|
||||
@@ -442,7 +442,7 @@ func TestNetworkType(t *testing.T) {
|
||||
|
||||
func TestNetworkID(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
netOption := options.Generic{
|
||||
@@ -469,7 +469,7 @@ func TestNetworkID(t *testing.T) {
|
||||
|
||||
func TestDeleteNetworkWithActiveEndpoints(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
netOption := options.Generic{
|
||||
@@ -510,7 +510,7 @@ func TestDeleteNetworkWithActiveEndpoints(t *testing.T) {
|
||||
|
||||
func TestUnknownNetwork(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
netOption := options.Generic{
|
||||
@@ -542,7 +542,7 @@ func TestUnknownNetwork(t *testing.T) {
|
||||
|
||||
func TestUnknownEndpoint(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
ip, subnet, err := net.ParseCIDR("192.168.100.1/24")
|
||||
@@ -590,7 +590,7 @@ func TestUnknownEndpoint(t *testing.T) {
|
||||
|
||||
func TestNetworkEndpointsWalkers(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
// Create network 1 and add 2 endpoint: ep11, ep12
|
||||
@@ -722,7 +722,7 @@ func TestNetworkEndpointsWalkers(t *testing.T) {
|
||||
|
||||
func TestDuplicateEndpoint(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
netOption := options.Generic{
|
||||
@@ -772,7 +772,7 @@ func TestDuplicateEndpoint(t *testing.T) {
|
||||
|
||||
func TestControllerQuery(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
// Create network 1
|
||||
@@ -876,7 +876,7 @@ func TestControllerQuery(t *testing.T) {
|
||||
|
||||
func TestNetworkQuery(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
// Create network 1 and add 2 endpoint: ep11, ep12
|
||||
@@ -998,7 +998,7 @@ func checkSandbox(t *testing.T, info libnetwork.EndpointInfo) {
|
||||
|
||||
func TestEndpointJoin(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
// Create network 1 and add 2 endpoint: ep11, ep12
|
||||
@@ -1186,7 +1186,7 @@ func (f *fakeSandbox) Delete() error {
|
||||
|
||||
func TestEndpointDeleteWithActiveContainer(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
||||
@@ -1250,7 +1250,7 @@ func TestEndpointDeleteWithActiveContainer(t *testing.T) {
|
||||
|
||||
func TestEndpointMultipleJoins(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
n, err := createTestNetwork(bridgeNetType, "testmultiple", options.Generic{
|
||||
@@ -1322,7 +1322,7 @@ func TestEndpointMultipleJoins(t *testing.T) {
|
||||
|
||||
func TestLeaveAll(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
||||
@@ -1386,7 +1386,7 @@ func TestLeaveAll(t *testing.T) {
|
||||
|
||||
func TestontainerInvalidLeave(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
||||
@@ -1453,7 +1453,7 @@ func TestontainerInvalidLeave(t *testing.T) {
|
||||
|
||||
func TestEndpointUpdateParent(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
n, err := createTestNetwork("bridge", "testnetwork", options.Generic{
|
||||
@@ -1539,7 +1539,7 @@ func TestEndpointUpdateParent(t *testing.T) {
|
||||
|
||||
func TestEnableIPv6(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
tmpResolvConf := []byte("search pommesfrites.fr\nnameserver 12.34.56.78\nnameserver 2001:4860:4860::8888\n")
|
||||
@@ -1635,7 +1635,7 @@ func TestEnableIPv6(t *testing.T) {
|
||||
|
||||
func TestResolvConfHost(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
tmpResolvConf := []byte("search localhost.net\nnameserver 127.0.0.1\nnameserver 2001:4860:4860::8888\n")
|
||||
@@ -1714,7 +1714,7 @@ func TestResolvConfHost(t *testing.T) {
|
||||
|
||||
func TestResolvConf(t *testing.T) {
|
||||
if !netutils.IsRunningInContainer() {
|
||||
defer netutils.SetupTestNetNS(t)()
|
||||
defer osl.SetupTestOSContext(t)()
|
||||
}
|
||||
|
||||
tmpResolvConf1 := []byte("search pommesfrites.fr\nnameserver 12.34.56.78\nnameserver 2001:4860:4860::8888\n")
|
||||
|
||||
Reference in New Issue
Block a user