浏览代码

Merge pull request #2603 from bboehmke/ipv6_portmapper_chain

Fixed IPv6 portmapper iptables chain initialization
Arko Dasgupta 4 年之前
父节点
当前提交
09be71b900
共有 2 个文件被更改,包括 8 次插入2 次删除
  1. 5 1
      libnetwork/drivers/bridge/setup_ip_tables.go
  2. 3 1
      libnetwork/iptables/iptables.go

+ 5 - 1
libnetwork/drivers/bridge/setup_ip_tables.go

@@ -178,7 +178,11 @@ func (n *bridgeNetwork) setupIPTables(ipVersion iptables.IPVersion, maskedAddr *
 			return iptable.ProgramChain(filterChain, config.BridgeName, hairpinMode, false)
 		})
 
-		n.portMapper.SetIptablesChain(natChain, n.getNetworkBridgeName())
+		if ipVersion == iptables.IPv4 {
+			n.portMapper.SetIptablesChain(natChain, n.getNetworkBridgeName())
+		} else {
+			n.portMapperV6.SetIptablesChain(natChain, n.getNetworkBridgeName())
+		}
 	}
 
 	d.Lock()

+ 3 - 1
libnetwork/iptables/iptables.go

@@ -533,8 +533,10 @@ func (iptable IPTable) raw(args ...string) ([]byte, error) {
 	}
 
 	path := iptablesPath
+	commandName := "iptables"
 	if iptable.Version == IPv6 {
 		path = ip6tablesPath
+		commandName = "ip6tables"
 	}
 
 	logrus.Debugf("%s, %v", path, args)
@@ -542,7 +544,7 @@ func (iptable IPTable) raw(args ...string) ([]byte, error) {
 	startTime := time.Now()
 	output, err := exec.Command(path, args...).CombinedOutput()
 	if err != nil {
-		return nil, fmt.Errorf("iptables failed: iptables %v: %s (%s)", strings.Join(args, " "), output, err)
+		return nil, fmt.Errorf("iptables failed: %s %v: %s (%s)", commandName, strings.Join(args, " "), output, err)
 	}
 
 	return filterOutput(startTime, output, args...), err