aboutsummaryrefslogtreecommitdiff
path: root/libpod/container_internal_linux.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-06-03 22:00:47 +0200
committerGitHub <noreply@github.com>2021-06-03 22:00:47 +0200
commitc7e96edfb2a5a6187fbbf066d9fe9ae02686be9c (patch)
tree86e6e37a3fb2bcc2b160c6c21a2dc6cc9415dad4 /libpod/container_internal_linux.go
parent326c758bfd74f48a16a02db1d9d950f128156683 (diff)
parent9647d88449f44028c9b870af74e5e44cb819ff9d (diff)
downloadpodman-c7e96edfb2a5a6187fbbf066d9fe9ae02686be9c.tar.gz
podman-c7e96edfb2a5a6187fbbf066d9fe9ae02686be9c.tar.bz2
podman-c7e96edfb2a5a6187fbbf066d9fe9ae02686be9c.zip
Merge pull request #10552 from mheon/bump_320
Bump to v3.2.0
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r--libpod/container_internal_linux.go34
1 files changed, 26 insertions, 8 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 17b894ce0..df9e03e78 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -1666,17 +1666,16 @@ func (c *Container) generateResolvConf() (string, error) {
return "", err
}
- // Ensure that the container's /etc/resolv.conf is compatible with its
- // network configuration.
- // TODO: set ipv6 enable bool more sanely
- resolv, err := resolvconf.FilterResolvDNS(contents, true, c.config.CreateNetNS)
- if err != nil {
- return "", errors.Wrapf(err, "error parsing host resolv.conf")
- }
-
+ ipv6 := false
// Check if CNI gave back and DNS servers for us to add in
cniResponse := c.state.NetworkStatus
for _, i := range cniResponse {
+ for _, ip := range i.IPs {
+ // Note: only using To16() does not work since it also returns a vaild ip for ipv4
+ if ip.Address.IP.To4() == nil && ip.Address.IP.To16() != nil {
+ ipv6 = true
+ }
+ }
if i.DNS.Nameservers != nil {
cniNameServers = append(cniNameServers, i.DNS.Nameservers...)
logrus.Debugf("adding nameserver(s) from cni response of '%q'", i.DNS.Nameservers)
@@ -1687,6 +1686,25 @@ func (c *Container) generateResolvConf() (string, error) {
}
}
+ if c.config.NetMode.IsSlirp4netns() {
+ ctrNetworkSlipOpts := []string{}
+ if c.config.NetworkOptions != nil {
+ ctrNetworkSlipOpts = append(ctrNetworkSlipOpts, c.config.NetworkOptions["slirp4netns"]...)
+ }
+ slirpOpts, err := parseSlirp4netnsNetworkOptions(c.runtime, ctrNetworkSlipOpts)
+ if err != nil {
+ return "", err
+ }
+ ipv6 = slirpOpts.enableIPv6
+ }
+
+ // Ensure that the container's /etc/resolv.conf is compatible with its
+ // network configuration.
+ resolv, err := resolvconf.FilterResolvDNS(contents, ipv6, c.config.CreateNetNS)
+ if err != nil {
+ return "", errors.Wrapf(err, "error parsing host resolv.conf")
+ }
+
dns := make([]net.IP, 0, len(c.runtime.config.Containers.DNSServers))
for _, i := range c.runtime.config.Containers.DNSServers {
result := net.ParseIP(i)