Fixed issue where hostIP address family was not checked against the containerIP address family. closes #378

Signed-off-by: Niels van Oosterom <xcelsion@users.noreply.github.com>
This commit is contained in:
Niels van Oosterom 2019-08-30 13:03:06 +02:00
parent 7e68430081
commit e8365e126d

View File

@ -224,6 +224,16 @@ func fillDnatRules(c *chain, config *PortMapConf, containerIP net.IP) {
// the ordering is important here; the mark rules must be first.
c.rules = make([][]string, 0, 3*len(entries))
for _, entry := range entries {
// If a HostIP is given, only process the entry if host and container address families match
if entry.HostIP != "" {
hostIP := net.ParseIP(entry.HostIP)
isHostV6 := (hostIP.To4() == nil)
if isV6 != isHostV6 {
continue
}
}
ruleBase := []string{
"-p", entry.Protocol,
"--dport", strconv.Itoa(entry.HostPort)}