diff --git a/libnetwork/iptables/iptables.go b/libnetwork/iptables/iptables.go index 610adab87c..e3eb477562 100644 --- a/libnetwork/iptables/iptables.go +++ b/libnetwork/iptables/iptables.go @@ -151,8 +151,11 @@ func GetIptable(version IPVersion) *IPTable { // NewChain adds a new chain to ip table. func (iptable IPTable) NewChain(name string, table Table, hairpinMode bool) (*ChainInfo, error) { + if name == "" { + return nil, fmt.Errorf("could not create chain: chain name is empty") + } if table == "" { - table = Filter + return nil, fmt.Errorf("could not create chain %s: invalid table name: table name is empty", name) } // Add chain if it doesn't exist if _, err := iptable.Raw("-t", string(table), "-n", "-L", name); err != nil { @@ -280,8 +283,11 @@ func (iptable IPTable) ProgramChain(c *ChainInfo, bridgeName string, hairpinMode // RemoveExistingChain removes existing chain from the table. func (iptable IPTable) RemoveExistingChain(name string, table Table) error { + if name == "" { + return fmt.Errorf("could not remove chain: chain name is empty") + } if table == "" { - table = Filter + return fmt.Errorf("could not remove chain %s: invalid table name: table name is empty", name) } c := &ChainInfo{ Name: name,