summaryrefslogtreecommitdiff
path: root/libpod/networking_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/networking_linux.go')
-rw-r--r--libpod/networking_linux.go28
1 files changed, 13 insertions, 15 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index de6f75d3e..c1b2c694d 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -22,13 +22,13 @@ import (
cnitypes "github.com/containernetworking/cni/pkg/types/current"
"github.com/containernetworking/plugins/pkg/ns"
- "github.com/containers/podman/v2/libpod/define"
- "github.com/containers/podman/v2/libpod/events"
- "github.com/containers/podman/v2/libpod/network"
- "github.com/containers/podman/v2/pkg/errorhandling"
- "github.com/containers/podman/v2/pkg/netns"
- "github.com/containers/podman/v2/pkg/rootless"
- "github.com/containers/podman/v2/pkg/rootlessport"
+ "github.com/containers/podman/v3/libpod/define"
+ "github.com/containers/podman/v3/libpod/events"
+ "github.com/containers/podman/v3/libpod/network"
+ "github.com/containers/podman/v3/pkg/errorhandling"
+ "github.com/containers/podman/v3/pkg/netns"
+ "github.com/containers/podman/v3/pkg/rootless"
+ "github.com/containers/podman/v3/pkg/rootlessport"
"github.com/cri-o/ocicni/pkg/ocicni"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -1139,13 +1139,12 @@ func (c *Container) NetworkDisconnect(nameOrID, netName string, force bool) erro
return err
}
- exists, err := network.Exists(c.runtime.config, netName)
+ // check if network exists and if the input is a ID we get the name
+ // ocicni only uses names so it is important that we only use the name
+ netName, err = network.NormalizeName(c.runtime.config, netName)
if err != nil {
return err
}
- if !exists {
- return errors.Wrap(define.ErrNoSuchNetwork, netName)
- }
index, nameExists := networks[netName]
if !nameExists && len(networks) > 0 {
@@ -1196,13 +1195,12 @@ func (c *Container) NetworkConnect(nameOrID, netName string, aliases []string) e
return err
}
- exists, err := network.Exists(c.runtime.config, netName)
+ // check if network exists and if the input is a ID we get the name
+ // ocicni only uses names so it is important that we only use the name
+ netName, err = network.NormalizeName(c.runtime.config, netName)
if err != nil {
return err
}
- if !exists {
- return errors.Wrap(define.ErrNoSuchNetwork, netName)
- }
c.lock.Lock()
defer c.lock.Unlock()