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

Disable iptables bridge forwarding on initialization (backport #83) #120

Merged
merged 1 commit into from
Sep 19, 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
6 changes: 1 addition & 5 deletions pkg/network/iface/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ func NewBridge(name string) *Bridge {
// Ensure bridge
// set promiscuous mod default
func (br *Bridge) Ensure() error {
if err := disableBridgeNF(); err != nil {
return fmt.Errorf("disable net.bridge.bridge-nf-call-iptables failed, error: %w", err)
}

if err := netlink.LinkAdd(br); err != nil && err != syscall.EEXIST {
return fmt.Errorf("add iface failed, error: %w, iface: %v", err, br)
}
Expand Down Expand Up @@ -67,7 +63,7 @@ func (br *Bridge) Ensure() error {
return br.Fetch()
}

func disableBridgeNF() error {
func DisableBridgeNF() error {
return utils.EnsureSysctlValue(bridgeNFCallIptables, "0")
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/network/vlan/vlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,9 @@ func (v *Vlan) Bridge() *iface.Bridge {
func (v *Vlan) Uplink() *iface.Link {
return v.uplink
}

func init() {
if err := iface.DisableBridgeNF(); err != nil {
klog.Fatalf("disable net.bridge.bridge-nf-call-iptables failed, error: %v", err)
}
}
Loading