diff options
author | Ashley Cui <acui@redhat.com> | 2020-09-25 10:00:43 -0400 |
---|---|---|
committer | Ashley Cui <acui@redhat.com> | 2020-09-25 21:34:23 -0400 |
commit | b6176d8987a0049a253fd7a70b2cd8e17bd50b53 (patch) | |
tree | e4ce740ebc925079ab223b41acec4c15b85b6fd9 /libpod/options.go | |
parent | 98aa458c7a13c72fabe02cd0ed2919c2801ef207 (diff) | |
download | podman-b6176d8987a0049a253fd7a70b2cd8e17bd50b53.tar.gz podman-b6176d8987a0049a253fd7a70b2cd8e17bd50b53.tar.bz2 podman-b6176d8987a0049a253fd7a70b2cd8e17bd50b53.zip |
Add support for slirp network for pods
flag --network=slirp4netns[options] for root and rootless pods
Signed-off-by: Ashley Cui <acui@redhat.com>
Diffstat (limited to 'libpod/options.go')
-rw-r--r-- | libpod/options.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libpod/options.go b/libpod/options.go index f7b3419e5..f7190d0e3 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -2203,3 +2203,23 @@ func WithPodInfraExitCommand(exitCmd []string) PodCreateOption { return nil } } + +// WithPodSlirp4netns tells the pod to use slirp4netns. +func WithPodSlirp4netns(networkOptions map[string][]string) PodCreateOption { + return func(pod *Pod) error { + if pod.valid { + return define.ErrPodFinalized + } + + if !pod.config.InfraContainer.HasInfraContainer { + return errors.Wrapf(define.ErrInvalidArg, "cannot configure pod networking as no infra container is being created") + } + if pod.config.InfraContainer.HostNetwork { + return errors.Wrapf(define.ErrInvalidArg, "cannot set both HostNetwork and Slirp4netns") + } + pod.config.InfraContainer.Slirp4netns = true + pod.config.InfraContainer.NetworkOptions = networkOptions + + return nil + } +} |