diff --git a/libnetwork/iptables/iptables.go b/libnetwork/iptables/iptables.go index a29cddb0f46577ffe214abea0140636dd3b1b3a1..ce681f0ca6afb8b6d3f436fab7d13a2a7278b79c 100644 --- a/libnetwork/iptables/iptables.go +++ b/libnetwork/iptables/iptables.go @@ -450,21 +450,21 @@ func (iptable IPTable) ExistsNative(table Table, chain string, rule ...string) b } func (iptable IPTable) exists(native bool, table Table, chain string, rule ...string) bool { + if err := initCheck(); err != nil { + // The exists() signature does not allow us to return an error, but at least + // we can skip the (likely invalid) exec invocation. + return false + } + f := iptable.Raw if native { f = iptable.raw } - if string(table) == "" { + if table == "" { table = Filter } - if err := initCheck(); err != nil { - // The exists() signature does not allow us to return an error, but at least - // we can skip the (likely invalid) exec invocation. - return false - } - // if exit status is 0 then return true, the rule exists _, err := f(append([]string{"-t", string(table), "-C", chain}, rule...)...) return err == nil