Skip to content

Commit

Permalink
Avoid failure to add interface when XFRM is not supported by the kern…
Browse files Browse the repository at this point in the history
…el (projectcalico#8710)

Avoid failing to create interface when XFRM is not supported by the kernel

By default, netlink.NewHandle() will return a handle with all netlink
families supported by the library (currently, ROUTE, XFRM, NETFILTER).
This causes calico to error out on kernels that don't support XFRM.

This fix limits the handle to the ROUTE netlink family only.
  • Loading branch information
carloslima authored and caseydavenport committed Apr 17, 2024
1 parent 1f3e081 commit 80f0ad1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cni-plugin/pkg/dataplane/linux/dataplane_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (d *linuxDataplane) DoNetworking(

d.logger.Infof("Setting the host side veth name to %s", hostVethName)

hostNlHandle, err := netlink.NewHandle()
hostNlHandle, err := netlink.NewHandle(syscall.NETLINK_ROUTE)
if err != nil {
return "", "", fmt.Errorf("failed to create host netlink handle: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cni-plugin/tests/calico_cni_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ var _ = Describe("CalicoCni", func() {
containerID, result, _, _, _, contNs, err := testutils.CreateContainerWithId(netconf, "", testutils.TEST_DEFAULT_NS, "", "meep1337")
Expect(err).ShouldNot(HaveOccurred())

hostNlHandle, err := netlink.NewHandle()
hostNlHandle, err := netlink.NewHandle(syscall.NETLINK_ROUTE)
Expect(err).ShouldNot(HaveOccurred())
defer hostNlHandle.Close()

Expand Down
2 changes: 1 addition & 1 deletion felix/dataplane/linux/vxlan_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func newVXLANManager(
ipVersion uint8,
featureDetector environment.FeatureDetectorIface,
) *vxlanManager {
nlHandle, _ := netlink.NewHandle()
nlHandle, _ := netlink.NewHandle(syscall.NETLINK_ROUTE)

blackHoleProto := defaultVXLANProto
if dpConfig.DeviceRouteProtocol != syscall.RTPROT_BOOT {
Expand Down
3 changes: 2 additions & 1 deletion felix/k8sfv/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os/exec"
"strings"
"sync"
"syscall"
"time"

"github.com/containernetworking/plugins/pkg/ns"
Expand Down Expand Up @@ -66,7 +67,7 @@ func createPod(clientset *kubernetes.Clientset, d deployment, nsName string, spe
// the link but then LinkByName wouldn't find it. It's not clear why doing that helps but it
// may be that the kernel enforces consistency when you re-use the same socket, or, it may be
// that load causes the issue and we put less load on the kernel.
handle, err := netlink.NewHandle()
handle, err := netlink.NewHandle(syscall.NETLINK_ROUTE)
panicIfError(err)
defer handle.Close()

Expand Down

0 comments on commit 80f0ad1

Please sign in to comment.