Skip to content

Commit

Permalink
Merge pull request #62 from mccv1r0/nf-tables
Browse files Browse the repository at this point in the history
Remove iptables mode dependent existsErr code work-around.
  • Loading branch information
Casey Callendrello authored Jun 27, 2019
2 parents 2ed0620 + a5f18ed commit f1d0510
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions iptables/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,18 +373,13 @@ func (ipt *IPTables) NewChain(table, chain string) error {
return ipt.run("-t", table, "-N", chain)
}

const existsErr = 1

// ClearChain flushed (deletes all rules) in the specified table/chain.
// If the chain does not exist, a new one will be created
func (ipt *IPTables) ClearChain(table, chain string) error {
err := ipt.NewChain(table, chain)

// the exit code for "this table already exists" is different for
// different iptables modes
existsErr := 1
if ipt.mode == "nf_tables" {
existsErr = 4
}

eerr, eok := err.(*Error)
switch {
case err == nil:
Expand Down

0 comments on commit f1d0510

Please sign in to comment.