From a5f18ede385f8f348d876635c8483640d6446d65 Mon Sep 17 00:00:00 2001 From: Michael Cambria Date: Mon, 24 Jun 2019 16:11:51 -0400 Subject: [PATCH] Remove iptables mode dependent existsErr code work-around. iptables fixed in iptables-1.8.1 commit c19fa5833a0bc0eb787799634bd26dea91fcdca1 --- iptables/iptables.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/iptables/iptables.go b/iptables/iptables.go index 1bcf631..2ed875b 100644 --- a/iptables/iptables.go +++ b/iptables/iptables.go @@ -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: