Skip to content

Commit

Permalink
Default sysctl to "net.ipv6.conf.all.accept_dad=0" if slirp4netns
Browse files Browse the repository at this point in the history
Fixes: #11062

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Oct 25, 2021
1 parent dbe770e commit dfd5ff9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/specgen/generate/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/namespaces"
"github.com/containers/podman/v3/pkg/specgen"
"github.com/containers/podman/v3/pkg/util"
"github.com/opencontainers/runtime-tools/generate"
Expand Down Expand Up @@ -239,6 +240,11 @@ func securityConfigureGenerator(s *specgen.SpecGenerator, g *generate.Generator,
g.AddLinuxSysctl(sysctlKey, sysctlVal)
}

// Fixes #11062, speeds up creation of network.
if namespaces.NetworkMode(s.NetNS.NSMode).IsSlirp4netns() {
g.AddLinuxSysctl("net.ipv6.conf.all.accept_dad", "0")
}

for sysctlKey, sysctlVal := range s.Sysctl {
if s.IpcNS.IsHost() && strings.HasPrefix(sysctlKey, "fs.mqueue.") {
return errors.Wrapf(define.ErrInvalidArg, "sysctl %s=%s can't be set since IPC Namespace set to host", sysctlKey, sysctlVal)
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/run_networking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,13 @@ var _ = Describe("Podman run networking", func() {
Expect(ncBusy).To(ExitWithError())
})

It("podman run slirp4netns verify net.ipv6.conf.all.accept_dad=0", func() {
session := podmanTest.Podman([]string{"run", "--network", "slirp4netns", ALPINE, "cat", "/proc/sys/net/ipv6/conf/all/accept_dad"})
session.Wait(30)
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(Equal("0"))
})

It("podman run network expose host port 18082 to container port 8000 using slirp4netns port handler", func() {
session := podmanTest.Podman([]string{"run", "--network", "slirp4netns:port_handler=slirp4netns", "-dt", "-p", "18082:8000", ALPINE, "/bin/sh"})
session.Wait(30)
Expand Down

0 comments on commit dfd5ff9

Please sign in to comment.