"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "vendor/github.com/docker/libnetwork/drivers/bridge/port_mapping.go" between
moby-20.10.6.tar.gz and moby-20.10.7.tar.gz

About: Moby is a framework to assemble specialized container systems (formerly project name Docker; see here to clarify the relationship between the projects).

port_mapping.go  (moby-20.10.6):port_mapping.go  (moby-20.10.7)
package bridge package bridge
import ( import (
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"net" "net"
"sync"
"github.com/docker/libnetwork/types" "github.com/docker/libnetwork/types"
"github.com/ishidawataru/sctp" "github.com/ishidawataru/sctp"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
func (n *bridgeNetwork) allocatePorts(ep *bridgeEndpoint, reqDefBindIP net.IP, u lPxyEnabled bool) ([]types.PortBinding, error) { func (n *bridgeNetwork) allocatePorts(ep *bridgeEndpoint, reqDefBindIP net.IP, u lPxyEnabled bool) ([]types.PortBinding, error) {
if ep.extConnConfig == nil || ep.extConnConfig.PortBindings == nil { if ep.extConnConfig == nil || ep.extConnConfig.PortBindings == nil {
return nil, nil return nil, nil
} }
skipping to change at line 53 skipping to change at line 54
if err := n.allocatePort(&bIPv4, ulPxyEnabled); err != ni l { if err := n.allocatePort(&bIPv4, ulPxyEnabled); err != ni l {
// On allocation failure, release previously allo cated ports. On cleanup error, just log a warning message // On allocation failure, release previously allo cated ports. On cleanup error, just log a warning message
if cuErr := n.releasePortsInternal(bs); cuErr != nil { if cuErr := n.releasePortsInternal(bs); cuErr != nil {
logrus.Warnf("allocation failure for %v, failed to clear previously allocated ipv4 port bindings: %v", bIPv4, cuErr) logrus.Warnf("allocation failure for %v, failed to clear previously allocated ipv4 port bindings: %v", bIPv4, cuErr)
} }
return nil, err return nil, err
} }
bs = append(bs, bIPv4) bs = append(bs, bIPv4)
} }
// skip adding implicit v6 addr, when the kernel was booted with
`ipv6.disable=1`
// https://github.com/moby/moby/issues/42288
isV6Binding := c.HostIP != nil && c.HostIP.To4() == nil
if !isV6Binding && !IsV6Listenable() {
continue
}
// Allocate IPv6 Port mappings // Allocate IPv6 Port mappings
// If the container has no IPv6 address, allow proxying host IPv6 traffic to it // If the container has no IPv6 address, allow proxying host IPv6 traffic to it
// by setting up the binding with the IPv4 interface if the userl and proxy is enabled // by setting up the binding with the IPv4 interface if the userl and proxy is enabled
// This change was added to keep backward compatibility // This change was added to keep backward compatibility
containerIP := containerIPv6 containerIP := containerIPv6
if ulPxyEnabled && (containerIPv6 == nil) { if ulPxyEnabled && (containerIPv6 == nil) {
containerIP = containerIPv4 containerIP = containerIPv4
} }
if ok := n.validatePortBindingIPv6(&bIPv6, containerIP, defHostIP ); ok { if ok := n.validatePortBindingIPv6(&bIPv6, containerIP, defHostIP ); ok {
if err := n.allocatePort(&bIPv6, ulPxyEnabled); err != ni l { if err := n.allocatePort(&bIPv6, ulPxyEnabled); err != ni l {
skipping to change at line 214 skipping to change at line 222
} }
portmapper := n.portMapper portmapper := n.portMapper
if bnd.HostIP.To4() == nil { if bnd.HostIP.To4() == nil {
portmapper = n.portMapperV6 portmapper = n.portMapperV6
} }
return portmapper.Unmap(host) return portmapper.Unmap(host)
} }
var (
v6ListenableCached bool
v6ListenableOnce sync.Once
)
// IsV6Listenable returns true when `[::1]:0` is listenable.
// IsV6Listenable returns false mostly when the kernel was booted with `ipv6.dis
able=1` option.
func IsV6Listenable() bool {
v6ListenableOnce.Do(func() {
ln, err := net.Listen("tcp6", "[::1]:0")
if err != nil {
// When the kernel was booted with `ipv6.disable=1`,
// we get err "listen tcp6 [::1]:0: socket: address famil
y not supported by protocol"
// https://github.com/moby/moby/issues/42288
logrus.Debugf("port_mapping: v6Listenable=false (%v)", er
r)
} else {
v6ListenableCached = true
ln.Close()
}
})
return v6ListenableCached
}
 End of changes. 3 change blocks. 
0 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)