mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
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>
This commit is contained in:
@ -79,7 +79,8 @@ func (c *Container) prepare() error {
|
|||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
// Set up network namespace if not already set up
|
// 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)
|
netNS, networkStatus, createNetNSErr = c.runtime.createNetNS(c)
|
||||||
if createNetNSErr != nil {
|
if createNetNSErr != nil {
|
||||||
return
|
return
|
||||||
@ -94,7 +95,7 @@ func (c *Container) prepare() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle rootless network namespace setup
|
// 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)
|
createNetNSErr = c.runtime.setupRootlessNetNS(c)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
Reference in New Issue
Block a user