Skip to content

Commit

Permalink
Merge pull request #78 from openshift-cherrypick-robot/cherry-pick-77…
Browse files Browse the repository at this point in the history
…-to-release-4.14

[release-4.14] OCPBUGS-19850: Ensure that IP forwarding is enabled
  • Loading branch information
openshift-merge-robot committed Sep 29, 2023
2 parents 657df81 + d6724ef commit afffdd4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/macvlan/macvlan.go
Expand Up @@ -3,7 +3,6 @@ package macvlan
import (
"encoding/json"
"fmt"
"github.com/openshift/egress-router-cni/pkg/util"
"net"
"os"
"strconv"
Expand All @@ -17,6 +16,7 @@ import (
"github.com/containernetworking/plugins/pkg/utils/sysctl"
"github.com/coreos/go-iptables/iptables"
"github.com/j-keck/arping"
"github.com/openshift/egress-router-cni/pkg/util"
"github.com/vishvananda/netlink"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -444,6 +444,17 @@ func macvlanCmdAdd(args *skel.CmdArgs) error {
return fmt.Errorf("couldn't get interface eth0: %v", err)
}

// Enable IP forwarding
ipFamily := "ipv4"
if isIPv6 {
ipFamily = "ipv6"
}
_, err = sysctl.Sysctl(fmt.Sprintf("net.%s.ip_forward", ipFamily), "1")
if err != nil {
logging.Errorf("failed to enable %s forwarding: %v", ipFamily, err)
return fmt.Errorf("failed to enable %s forwarding: %v", ipFamily, err)
}

// Delete default route
var routes []netlink.Route
if isIPv6 {
Expand Down

0 comments on commit afffdd4

Please sign in to comment.