Skip to content

Commit

Permalink
feat: add rp filter nic
Browse files Browse the repository at this point in the history
Signed-off-by: OrangeBao <[email protected]>
  • Loading branch information
OrangeBao committed Nov 24, 2023
1 parent e923865 commit abc7606
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions pkg/clusterlink/network/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package network
import (
"fmt"
"net"
"os"
"strings"
"syscall"

"github.com/pkg/errors"
Expand Down Expand Up @@ -323,14 +325,24 @@ func UpdateDefaultIptablesAndKernalConfig(name string, ipFamily int) error {
return err
}

// tunl0 device
if err := UpdateDefaultIp4tablesBehavior("tunl0"); err != nil {
klog.Errorf("Try to add iptables rule for tunl0: %v", err)
nicNames := []string{"tunl0", "vxlan.calico"}

deviceNameStr := os.Getenv("AGENT_RP_FILTER_DEVICES")
if len(deviceNameStr) > 0 {
nicNames = append(nicNames, strings.Split(deviceNameStr, ",")...)
}

// tunl0 device
if err := EnableLooseModeByIFaceNmae("tunl0"); err != nil {
klog.Errorf("Try to change kernel parameters(rp_filter) for tunl0: %v", err)
for _, nicName := range nicNames {
if len(nicName) == 0 {
continue
}
if err := UpdateDefaultIp4tablesBehavior(nicName); err != nil {
klog.Errorf("Try to add iptables rule for %s: %v", nicName, err)
}

if err := EnableLooseModeByIFaceNmae(nicName); err != nil {
klog.Errorf("Try to change kernel parameters(rp_filter) for %s: %v", nicName, err)
}
}
}

Expand Down

0 comments on commit abc7606

Please sign in to comment.