diff options
author | Paul Holzinger <paul.holzinger@web.de> | 2021-02-21 16:27:25 +0100 |
---|---|---|
committer | Paul Holzinger <paul.holzinger@web.de> | 2021-02-22 15:51:49 +0100 |
commit | 9d818be7329929b05b93e432c408ee65726ec2c0 (patch) | |
tree | 866e87cfc163e1e4b9b6493a342f1c36e2d8d9e3 /libpod/networking_linux.go | |
parent | 6fbf73ed8bd34738f3f901df1e5d3b592a9c3354 (diff) | |
download | podman-9d818be7329929b05b93e432c408ee65726ec2c0.tar.gz podman-9d818be7329929b05b93e432c408ee65726ec2c0.tar.bz2 podman-9d818be7329929b05b93e432c408ee65726ec2c0.zip |
Fix podman network IDs handling
The libpod network logic knows about networks IDs but OCICNI
does not. We cannot pass the network ID to OCICNI. Instead we
need to make sure we only use network names internally. This
is also important for libpod since we also only store the
network names in the state. If we would add a ID there the
same networks could accidentally be added twice.
Fixes #9451
Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'libpod/networking_linux.go')
-rw-r--r-- | libpod/networking_linux.go | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go index 5f9ad0e27..c1b2c694d 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -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() |