Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default sysctl to "net.ipv6.conf.all.accept_dad=0" if slirp4netns #12093

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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