diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2022-04-27 17:06:30 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2022-05-03 13:39:17 -0400 |
commit | 66500b82a645428e1a59ce25fda1b76965df21cf (patch) | |
tree | a3b1a3c86dafff6c687a16395f46a7e3e748047b /libpod | |
parent | 8627b5151079cde65594c0c1588cdd5c1114ff94 (diff) | |
download | podman-66500b82a645428e1a59ce25fda1b76965df21cf.tar.gz podman-66500b82a645428e1a59ce25fda1b76965df21cf.tar.bz2 podman-66500b82a645428e1a59ce25fda1b76965df21cf.zip |
Report properly whether pod shares host network
Fixes: https://github.com/containers/podman/issues/14028
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/pod.go | 9 | ||||
-rw-r--r-- | libpod/pod_api.go | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/libpod/pod.go b/libpod/pod.go index ed2d97b37..6cfe76a18 100644 --- a/libpod/pod.go +++ b/libpod/pod.go @@ -159,6 +159,15 @@ func (p *Pod) CPUQuota() int64 { return 0 } +// NetworkMode returns the Network mode given by the user ex: pod, private... +func (p *Pod) NetworkMode() string { + infra, err := p.runtime.GetContainer(p.state.InfraContainerID) + if err != nil { + return "" + } + return infra.NetworkMode() +} + // PidMode returns the PID mode given by the user ex: pod, private... func (p *Pod) PidMode() string { infra, err := p.runtime.GetContainer(p.state.InfraContainerID) diff --git a/libpod/pod_api.go b/libpod/pod_api.go index 48049798b..ba30d878e 100644 --- a/libpod/pod_api.go +++ b/libpod/pod_api.go @@ -593,7 +593,7 @@ func (p *Pod) Inspect() (*define.InspectPodData, error) { return nil, err } infraConfig = new(define.InspectPodInfraConfig) - infraConfig.HostNetwork = !infra.config.ContainerNetworkConfig.UseImageHosts + infraConfig.HostNetwork = p.NetworkMode() == "host" infraConfig.StaticIP = infra.config.ContainerNetworkConfig.StaticIP infraConfig.NoManageResolvConf = infra.config.UseImageResolvConf infraConfig.NoManageHosts = infra.config.UseImageHosts |