summaryrefslogtreecommitdiff
path: root/libpod/container_internal_linux.go
diff options
context:
space:
mode:
authorGabi Beyer <gabrielle.n.beyer@intel.com>2019-06-12 17:31:18 +0000
committerMarco Vedovati <mvedovati@suse.com>2019-09-24 11:01:28 +0200
commit5813c8246eb32205cc3e68a293c6cf3eb2ba291d (patch)
tree1e497c09fbe9cb762fd1f0c8ee0554f2fd060e9e /libpod/container_internal_linux.go
parent6ce8d05a5b06d97a2897411fcbd4da6a3abb4d65 (diff)
downloadpodman-5813c8246eb32205cc3e68a293c6cf3eb2ba291d.tar.gz
podman-5813c8246eb32205cc3e68a293c6cf3eb2ba291d.tar.bz2
podman-5813c8246eb32205cc3e68a293c6cf3eb2ba291d.zip
rootless: Rearrange setup of rootless containers
In order to run Podman with VM-based runtimes unprivileged, the network must be set up prior to the container creation. Therefore this commit modifies Podman to run rootless containers by: 1. create a network namespace 2. pass the netns persistent mount path to the slirp4netns to create the tap inferface 3. pass the netns path to the OCI spec, so the runtime can enter the netns Closes #2897 Signed-off-by: Gabi Beyer <gabrielle.n.beyer@intel.com>
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r--libpod/container_internal_linux.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 230b5b888..e7b4b2b22 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -78,15 +78,21 @@ func (c *Container) prepare() (Err error) {
// Set up network namespace if not already set up
if c.config.CreateNetNS && c.state.NetNS == nil && !c.config.PostConfigureNetNS {
netNS, networkStatus, createNetNSErr = c.runtime.createNetNS(c)
+ if createNetNSErr != nil {
+ return
+ }
tmpStateLock.Lock()
defer tmpStateLock.Unlock()
// Assign NetNS attributes to container
- if createNetNSErr == nil {
- c.state.NetNS = netNS
- c.state.NetworkStatus = networkStatus
- }
+ c.state.NetNS = netNS
+ c.state.NetworkStatus = networkStatus
+ }
+
+ // handle rootless network namespace setup
+ if c.state.NetNS != nil && c.config.NetMode == "slirp4netns" && !c.config.PostConfigureNetNS {
+ createNetNSErr = c.runtime.setupRootlessNetNS(c)
}
}()
// Mount storage if not mounted