Skip to content

Commit c38e8f6

Browse files
ericmurali-reddy
authored andcommitted
Change append to insert for iptables rules (#596)
* Change append to insert for iptables rules Updates how iptables FORWARD rules are applied to accommodate an existing final DROP rule for the chain. * Fix the calls to Insert() to include a position * iptables rules indexes are 1-based
1 parent 853b75b commit c38e8f6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/controllers/routing/network_routes_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ func (nrc *NetworkRoutingController) enableForwarding() error {
605605
return fmt.Errorf("Failed to run iptables command: %s", err.Error())
606606
}
607607
if !exists {
608-
err := iptablesCmdHandler.AppendUnique("filter", "FORWARD", args...)
608+
err := iptablesCmdHandler.Insert("filter", "FORWARD", 1, args...)
609609
if err != nil {
610610
return fmt.Errorf("Failed to run iptables command: %s", err.Error())
611611
}
@@ -618,7 +618,7 @@ func (nrc *NetworkRoutingController) enableForwarding() error {
618618
return fmt.Errorf("Failed to run iptables command: %s", err.Error())
619619
}
620620
if !exists {
621-
err = iptablesCmdHandler.AppendUnique("filter", "FORWARD", args...)
621+
err = iptablesCmdHandler.Insert("filter", "FORWARD", 1, args...)
622622
if err != nil {
623623
return fmt.Errorf("Failed to run iptables command: %s", err.Error())
624624
}
@@ -631,7 +631,7 @@ func (nrc *NetworkRoutingController) enableForwarding() error {
631631
return fmt.Errorf("Failed to run iptables command: %s", err.Error())
632632
}
633633
if !exists {
634-
err = iptablesCmdHandler.AppendUnique("filter", "FORWARD", args...)
634+
err = iptablesCmdHandler.Insert("filter", "FORWARD", 1, args...)
635635
if err != nil {
636636
return fmt.Errorf("Failed to run iptables command: %s", err.Error())
637637
}

0 commit comments

Comments
 (0)