|
@@ -4,11 +4,11 @@ import (
|
|
"errors"
|
|
"errors"
|
|
"fmt"
|
|
"fmt"
|
|
"net"
|
|
"net"
|
|
- "strings"
|
|
|
|
"sync"
|
|
"sync"
|
|
|
|
|
|
"github.com/docker/docker/daemon/networkdriver/portallocator"
|
|
"github.com/docker/docker/daemon/networkdriver/portallocator"
|
|
"github.com/docker/docker/pkg/iptables"
|
|
"github.com/docker/docker/pkg/iptables"
|
|
|
|
+ "github.com/docker/docker/pkg/log"
|
|
)
|
|
)
|
|
|
|
|
|
type mapping struct {
|
|
type mapping struct {
|
|
@@ -127,10 +127,7 @@ func Unmap(host net.Addr) error {
|
|
containerIP, containerPort := getIPAndPort(data.container)
|
|
containerIP, containerPort := getIPAndPort(data.container)
|
|
hostIP, hostPort := getIPAndPort(data.host)
|
|
hostIP, hostPort := getIPAndPort(data.host)
|
|
if err := forward(iptables.Delete, data.proto, hostIP, hostPort, containerIP.String(), containerPort); err != nil {
|
|
if err := forward(iptables.Delete, data.proto, hostIP, hostPort, containerIP.String(), containerPort); err != nil {
|
|
- // skip "no chain" errors because we can safely release port in this case
|
|
|
|
- if !strings.Contains(err.Error(), "No chain/target/match by that name") {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
|
|
+ log.Errorf("Error on iptables delete: %s", err)
|
|
}
|
|
}
|
|
|
|
|
|
switch a := host.(type) {
|
|
switch a := host.(type) {
|
|
@@ -139,7 +136,6 @@ func Unmap(host net.Addr) error {
|
|
case *net.UDPAddr:
|
|
case *net.UDPAddr:
|
|
return portallocator.ReleasePort(a.IP, "udp", a.Port)
|
|
return portallocator.ReleasePort(a.IP, "udp", a.Port)
|
|
}
|
|
}
|
|
-
|
|
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|