Only check ipv6 when an IPv6 is configured
Signed-off-by: Michael Cambria <mccv1r0@gmail.com>
This commit is contained in:
parent
c4d24e80d6
commit
fb5d195fc5
@ -117,11 +117,22 @@ func forwardPorts(config *PortMapConf, containerNet net.IPNet) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkPorts(config *PortMapConf, containerNet net.IPNet) error {
|
func checkPorts(config *PortMapConf, containerNet net.IPNet) error {
|
||||||
|
isV6 := (containerNet.IP.To4() == nil)
|
||||||
dnatChain := genDnatChain(config.Name, config.ContainerID)
|
dnatChain := genDnatChain(config.Name, config.ContainerID)
|
||||||
fillDnatRules(&dnatChain, config, containerNet)
|
fillDnatRules(&dnatChain, config, containerNet)
|
||||||
|
|
||||||
ip4t, err4 := maybeGetIptables(false)
|
// check is called for each address, not once for all addresses
|
||||||
ip6t, err6 := maybeGetIptables(true)
|
var ip4t *iptables.IPTables
|
||||||
|
var err4 error
|
||||||
|
var ip6t *iptables.IPTables
|
||||||
|
var err6 error
|
||||||
|
|
||||||
|
if isV6 {
|
||||||
|
ip6t, err6 = maybeGetIptables(true)
|
||||||
|
} else {
|
||||||
|
ip4t, err4 = maybeGetIptables(false)
|
||||||
|
}
|
||||||
|
|
||||||
if ip4t == nil && ip6t == nil {
|
if ip4t == nil && ip6t == nil {
|
||||||
err := fmt.Errorf("neither iptables nor ip6tables is usable")
|
err := fmt.Errorf("neither iptables nor ip6tables is usable")
|
||||||
err = fmt.Errorf("%v, (iptables) %v", err, err4)
|
err = fmt.Errorf("%v, (iptables) %v", err, err4)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user