diff --git a/cmd/cni/sysctl.go b/cmd/cni/sysctl.go index d98fc596fa5..49f106376f0 100644 --- a/cmd/cni/sysctl.go +++ b/cmd/cni/sysctl.go @@ -5,6 +5,7 @@ package main import ( "fmt" + "os" "github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/utils/sysctl" @@ -19,10 +20,18 @@ func sysctlEnableIPv6(nsPath string) error { name := fmt.Sprintf("net.ipv6.conf.%s.disable_ipv6", conf) value, err := sysctl.Sysctl(name) if err != nil { + if os.IsNotExist(err) { + // The sysctl variable doesn't exist, so we can't set it + continue + } return fmt.Errorf("failed to get sysctl variable %s: %w", name, err) } if value != "0" { if _, err = sysctl.Sysctl(name, "0"); err != nil { + if os.IsPermission(err) { + // We don't have permission to set the sysctl variable, so we can't set it + continue + } return fmt.Errorf("failed to set sysctl variable %s to 0: %w", name, err) } }