diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2020-06-11 13:06:21 +0200 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2020-06-11 13:06:26 +0200 |
commit | 8ef1b461ae4187cc508cc8d9b73d68d04503467f (patch) | |
tree | e2fa103a9127d89996eec523c85cc00825409ee4 /libpod | |
parent | 7b85d5c6d272da17bcdb9fb266859c3e5ec8fd09 (diff) | |
download | podman-8ef1b461ae4187cc508cc8d9b73d68d04503467f.tar.gz podman-8ef1b461ae4187cc508cc8d9b73d68d04503467f.tar.bz2 podman-8ef1b461ae4187cc508cc8d9b73d68d04503467f.zip |
libpod: fix check for slirp4netns netns
fix the check for c.state.NetNS == nil. Its value is changed in the
first code block, so the condition is always true in the second one
and we end up running slirp4netns twice.
Closes: https://github.com/containers/libpod/issues/6538
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_internal_linux.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index e3ca3f6b2..9afe11b2b 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -79,7 +79,8 @@ func (c *Container) prepare() error { go func() { defer wg.Done() // Set up network namespace if not already set up - if c.config.CreateNetNS && c.state.NetNS == nil && !c.config.PostConfigureNetNS { + noNetNS := c.state.NetNS == nil + if c.config.CreateNetNS && noNetNS && !c.config.PostConfigureNetNS { netNS, networkStatus, createNetNSErr = c.runtime.createNetNS(c) if createNetNSErr != nil { return @@ -94,7 +95,7 @@ func (c *Container) prepare() error { } // handle rootless network namespace setup - if c.state.NetNS != nil && c.config.NetMode.IsSlirp4netns() && !c.config.PostConfigureNetNS { + if noNetNS && c.config.NetMode.IsSlirp4netns() && !c.config.PostConfigureNetNS { createNetNSErr = c.runtime.setupRootlessNetNS(c) } }() |