Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszWojciechO committed Oct 11, 2024
1 parent a661057 commit 512b0c3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions daemon/firewall/iptables/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package iptables

import (
"fmt"
"log"
"net"
"net/netip"
"os/exec"
Expand Down Expand Up @@ -134,6 +135,7 @@ func generateFlushRules(rules string) []string {
}

func (ipt *IPTables) Flush() error {
var finalErr error = nil
for _, iptableVersion := range ipt.supportedIPTables {
out, err := exec.Command(iptableVersion, "-S").CombinedOutput()
if err != nil {
Expand All @@ -144,13 +146,13 @@ func (ipt *IPTables) Flush() error {
for _, rule := range generateFlushRules(rules) {
err := exec.Command(iptableVersion, strings.Split(rule, " ")...).Run()
if err != nil {
return fmt.Errorf("deleting %s rule: %w", rule, err)

log.Printf("%s failed to delete rule %s: %s", internal.ErrorPrefix, rule, err)
finalErr = fmt.Errorf("failed to delete all rules")
}
}
}

return nil
return finalErr
}

// FilterSupportedIPTables filter supported versions based on what exists in the system
Expand Down

0 comments on commit 512b0c3

Please sign in to comment.