Merge pull request #44803 from akerouanton/fix-44721

libnetwork: Remove iptables nat rule when hairpin is disabled
This commit is contained in:
Bjorn Neergaard 2023-01-12 08:36:10 -07:00 committed by GitHub
commit dae48a8064
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -244,11 +244,10 @@ func setupIPTablesInternal(hostIP net.IP, bridgeIface string, addr *net.IPNet, i
}
}
// In hairpin mode, masquerade traffic from localhost
if hairpin {
if err := programChainRule(ipVersion, hpNatRule, "MASQ LOCAL HOST", enable); err != nil {
return err
}
// In hairpin mode, masquerade traffic from localhost. If hairpin is disabled or if we're tearing down
// that bridge, make sure the iptables rule isn't lying around.
if err := programChainRule(ipVersion, hpNatRule, "MASQ LOCAL HOST", enable && hairpin); err != nil {
return err
}
// Set Inter Container Communication.