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

cni: always enable ipv6 #4435

Merged
merged 1 commit into from
Oct 11, 2024
Merged
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
4 changes: 4 additions & 0 deletions cmd/cni/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func cmdAdd(args *skel.CmdArgs) error {
netConf.Provider = util.OvnProvider
}

if err = sysctlEnableIPv6(args.Netns); err != nil {
return err
}

client := request.NewCniServerClient(netConf.ServerSocket)
response, err := client.Add(request.CniRequest{
CniType: netConf.Type,
Expand Down
32 changes: 32 additions & 0 deletions cmd/cni/sysctl.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//go:build !windows
// +build !windows

package main

import (
"fmt"

"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/utils/sysctl"
)

// For docker version >=17.x the "none" network will disable ipv6 by default.
// We have to enable ipv6 here to add v6 address and gateway.
// See https://github.com/containernetworking/cni/issues/531
func sysctlEnableIPv6(nsPath string) error {
return ns.WithNetNSPath(nsPath, func(_ ns.NetNS) error {
for _, conf := range [...]string{"all", "default"} {
name := fmt.Sprintf("net.ipv6.conf.%s.disable_ipv6", conf)
value, err := sysctl.Sysctl(name)
if err != nil {
return fmt.Errorf("failed to get sysctl variable %s: %w", name, err)
}
if value != "0" {
if _, err = sysctl.Sysctl(name, "0"); err != nil {
return fmt.Errorf("failed to set sysctl variable %s to 0: %w", name, err)
}
}
}
return nil
})
}
6 changes: 6 additions & 0 deletions cmd/cni/sysctl_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package main

func sysctlEnableIPv6(nsPath string) error {
// nothing to do on Windows
return nil
}
Loading