diff --git a/pkg/cri/sbserver/podsandbox/sandbox_run_linux.go b/pkg/cri/sbserver/podsandbox/sandbox_run_linux.go index 462ad6f8c..576d66c79 100644 --- a/pkg/cri/sbserver/podsandbox/sandbox_run_linux.go +++ b/pkg/cri/sbserver/podsandbox/sandbox_run_linux.go @@ -146,6 +146,9 @@ func (c *Controller) sandboxContainerSpec(id string, config *runtime.PodSandboxC if c.config.EnableUnprivilegedPorts && !ipUnprivilegedPortStart { sysctls["net.ipv4.ip_unprivileged_port_start"] = "0" } + // TODO (rata): We need to set this only if the pod will + // **not** use user namespaces either. + // This will be done when user namespaces is ported to sbserver. if c.config.EnableUnprivilegedICMP && !pingGroupRange && !userns.RunningInUserNS() { sysctls["net.ipv4.ping_group_range"] = "0 2147483647" } diff --git a/pkg/cri/server/sandbox_run_linux.go b/pkg/cri/server/sandbox_run_linux.go index 380e85d02..f69413766 100644 --- a/pkg/cri/server/sandbox_run_linux.go +++ b/pkg/cri/server/sandbox_run_linux.go @@ -95,6 +95,7 @@ func (c *criService) sandboxContainerSpec(id string, config *runtime.PodSandboxC usernsOpts := nsOptions.GetUsernsOptions() uids, gids, err := parseUsernsIDs(usernsOpts) + var usernsEnabled bool if err != nil { return nil, fmt.Errorf("user namespace configuration: %w", err) } @@ -105,6 +106,7 @@ func (c *criService) sandboxContainerSpec(id string, config *runtime.PodSandboxC specOpts = append(specOpts, customopts.WithoutNamespace(runtimespec.UserNamespace)) case runtime.NamespaceMode_POD: specOpts = append(specOpts, oci.WithUserNamespace(uids, gids)) + usernsEnabled = true default: return nil, fmt.Errorf("unsupported user namespace mode: %q", mode) } @@ -164,7 +166,7 @@ func (c *criService) sandboxContainerSpec(id string, config *runtime.PodSandboxC if c.config.EnableUnprivilegedPorts && !ipUnprivilegedPortStart { sysctls["net.ipv4.ip_unprivileged_port_start"] = "0" } - if c.config.EnableUnprivilegedICMP && !pingGroupRange && !userns.RunningInUserNS() { + if c.config.EnableUnprivilegedICMP && !pingGroupRange && !userns.RunningInUserNS() && !usernsEnabled { sysctls["net.ipv4.ping_group_range"] = "0 2147483647" } }