Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 3 additions & 4 deletions cmd/dnet/dnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ import (
"os"
"os/signal"
"strings"
"syscall"
"time"

"github.com/BurntSushi/toml"
"github.com/codegangsta/cli"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/opts"
"github.com/docker/docker/pkg/discovery"
"github.com/docker/docker/pkg/reexec"

"github.com/docker/docker/api/types/network"
"github.com/docker/docker/pkg/term"
"github.com/docker/libnetwork"
"github.com/docker/libnetwork/api"
Expand All @@ -37,6 +35,7 @@ import (
"github.com/gorilla/mux"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
"golang.org/x/sys/unix"
)

const (
Expand Down Expand Up @@ -351,7 +350,7 @@ func (d *dnetConnection) WaitForDetachment(context.Context, string, string, stri

func handleSignals(controller libnetwork.NetworkController) {
c := make(chan os.Signal, 1)
signals := []os.Signal{os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT}
signals := []os.Signal{os.Interrupt, unix.SIGTERM, unix.SIGQUIT}
signal.Notify(c, signals...)
go func() {
for range c {
Expand Down
4 changes: 2 additions & 2 deletions cmd/dnet/dnet_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package main
import (
"os"
"os/signal"
"syscall"

psignal "github.com/docker/docker/pkg/signal"
"golang.org/x/sys/unix"
)

func setupDumpStackTrap() {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGUSR1)
signal.Notify(c, unix.SIGUSR1)
go func() {
for range c {
psignal.DumpStacks("")
Expand Down
4 changes: 2 additions & 2 deletions cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"net"
"os"
"os/signal"
"syscall"

"github.com/ishidawataru/sctp"
"golang.org/x/sys/unix"
)

func main() {
Expand Down Expand Up @@ -62,7 +62,7 @@ func parseHostContainerAddrs() (host net.Addr, container net.Addr) {

func handleStopSignals(p Proxy) {
s := make(chan os.Signal, 10)
signal.Notify(s, os.Interrupt, syscall.SIGTERM)
signal.Notify(s, os.Interrupt, unix.SIGTERM)

for range s {
p.Close()
Expand Down
5 changes: 3 additions & 2 deletions cmd/proxy/udp_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"net"
"strings"
"sync"
"syscall"
"time"

"golang.org/x/sys/unix"
)

const (
Expand Down Expand Up @@ -81,7 +82,7 @@ func (proxy *UDPProxy) replyLoop(proxyConn *net.UDPConn, clientAddr *net.UDPAddr
again:
read, err := proxyConn.Read(readBuf)
if err != nil {
if err, ok := err.(*net.OpError); ok && err.Err == syscall.ECONNREFUSED {
if err, ok := err.(*net.OpError); ok && err.Err == unix.ECONNREFUSED {
// This will happen if the last write failed
// (e.g: nothing is actually listening on the
// proxied port on the container), ignore it
Expand Down
5 changes: 3 additions & 2 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import (
"github.com/docker/libnetwork/netlabel"
"github.com/docker/libnetwork/osl"
"github.com/docker/libnetwork/types"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -1255,7 +1256,7 @@ func (c *controller) loadDriver(networkType string) error {
}

if err != nil {
if err == plugins.ErrNotFound {
if errors.Cause(err) == plugins.ErrNotFound {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes:

--- FAIL: TestUnknownDriver (15.00s)
	libnetwork_test.go:213: Did not fail with expected error. Actual error: could not find plugin unknowndriver in v1 plugin registry: plugin not found

--- FAIL: TestNilRemoteDriver (15.00s)
	libnetwork_test.go:225: Did not fail with expected error. Actual error: could not find plugin framerelay in v1 plugin registry: plugin not found

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if this is an actual issue currently; this was revealed due to docker/docker being bumped here, but likely is an issue in the current version in that repository

return types.NotFoundErrorf(err.Error())
}
return err
Expand All @@ -1274,7 +1275,7 @@ func (c *controller) loadIPAMDriver(name string) error {
}

if err != nil {
if err == plugins.ErrNotFound {
if errors.Cause(err) == plugins.ErrNotFound {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the above, but not sure if there's a test case covering this;

--- FAIL: TestUnknownDriver (15.00s)
	libnetwork_test.go:213: Did not fail with expected error. Actual error: could not find plugin unknowndriver in v1 plugin registry: plugin not found

--- FAIL: TestNilRemoteDriver (15.00s)
	libnetwork_test.go:225: Did not fail with expected error. Actual error: could not find plugin framerelay in v1 plugin registry: plugin not found

return types.NotFoundErrorf(err.Error())
}
return err
Expand Down
4 changes: 2 additions & 2 deletions drivers/bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"path/filepath"
"strconv"
"sync"
"syscall"

"github.com/docker/libnetwork/datastore"
"github.com/docker/libnetwork/discoverapi"
Expand All @@ -25,6 +24,7 @@ import (
"github.com/docker/libnetwork/types"
"github.com/sirupsen/logrus"
"github.com/vishvananda/netlink"
"golang.org/x/sys/unix"
)

const (
Expand Down Expand Up @@ -855,7 +855,7 @@ func addToBridge(nlh *netlink.Handle, ifaceName, bridgeName string) error {

func setHairpinMode(nlh *netlink.Handle, link netlink.Link, enable bool) error {
err := nlh.LinkSetHairpin(link, enable)
if err != nil && err != syscall.EINVAL {
if err != nil && err != unix.EINVAL {
// If error is not EINVAL something else went wrong, bail out right away
return fmt.Errorf("unable to set hairpin mode on %s via netlink: %v",
link.Attrs().Name, err)
Expand Down
28 changes: 14 additions & 14 deletions drivers/bridge/netlink_deprecated_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"fmt"
"math/rand"
"net"
"syscall"
"time"
"unsafe"

"github.com/docker/libnetwork/netutils"
"golang.org/x/sys/unix"
)

const (
Expand All @@ -24,7 +24,7 @@ type ifreqIndex struct {

type ifreqHwaddr struct {
IfrnName [ifNameSize]byte
IfruHwaddr syscall.RawSockaddr
IfruHwaddr unix.RawSockaddr
}

var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
Expand All @@ -34,11 +34,11 @@ var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
// WHICH SHIP WITH OLDER NOT ENTIRELY FUNCTIONAL VERSION OF NETLINK
func getIfSocket() (fd int, err error) {
for _, socket := range []int{
syscall.AF_INET,
syscall.AF_PACKET,
syscall.AF_INET6,
unix.AF_INET,
unix.AF_PACKET,
unix.AF_INET6,
} {
if fd, err = syscall.Socket(socket, syscall.SOCK_DGRAM, 0); err == nil {
if fd, err = unix.Socket(socket, unix.SOCK_DGRAM, 0); err == nil {
break
}
}
Expand All @@ -57,13 +57,13 @@ func ifIoctBridge(iface, master *net.Interface, op uintptr) error {
if err != nil {
return err
}
defer syscall.Close(s)
defer unix.Close(s)

ifr := ifreqIndex{}
copy(ifr.IfrnName[:len(ifr.IfrnName)-1], master.Name)
ifr.IfruIndex = int32(iface.Index)

if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s), op, uintptr(unsafe.Pointer(&ifr))); err != 0 {
if _, _, err := unix.Syscall(unix.SYS_IOCTL, uintptr(s), op, uintptr(unsafe.Pointer(&ifr))); err != 0 {
return err
}

Expand All @@ -90,17 +90,17 @@ func ioctlSetMacAddress(name, addr string) error {
if err != nil {
return err
}
defer syscall.Close(s)
defer unix.Close(s)

ifr := ifreqHwaddr{}
ifr.IfruHwaddr.Family = syscall.ARPHRD_ETHER
ifr.IfruHwaddr.Family = unix.ARPHRD_ETHER
copy(ifr.IfrnName[:len(ifr.IfrnName)-1], name)

for i := 0; i < 6; i++ {
ifr.IfruHwaddr.Data[i] = ifrDataByte(hw[i])
}

if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s), syscall.SIOCSIFHWADDR, uintptr(unsafe.Pointer(&ifr))); err != 0 {
if _, _, err := unix.Syscall(unix.SYS_IOCTL, uintptr(s), unix.SIOCSIFHWADDR, uintptr(unsafe.Pointer(&ifr))); err != 0 {
return err
}
return nil
Expand All @@ -115,13 +115,13 @@ func ioctlCreateBridge(name string, setMacAddr bool) error {
if err != nil {
return err
}
defer syscall.Close(s)
defer unix.Close(s)

nameBytePtr, err := syscall.BytePtrFromString(name)
nameBytePtr, err := unix.BytePtrFromString(name)
if err != nil {
return err
}
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s), ioctlBrAdd, uintptr(unsafe.Pointer(nameBytePtr))); err != 0 {
if _, _, err := unix.Syscall(unix.SYS_IOCTL, uintptr(s), ioctlBrAdd, uintptr(unsafe.Pointer(nameBytePtr))); err != 0 {
return err
}
if setMacAddr {
Expand Down
18 changes: 7 additions & 11 deletions drivers/bridge/setup_bridgenetfiltering.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"
"io/ioutil"
"os"
"syscall"

"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
)

// Enumeration type saying which versions of IP protocol to process.
Expand All @@ -31,16 +31,12 @@ func getIPVersion(config *networkConfiguration) ipVersion {

func setupBridgeNetFiltering(config *networkConfiguration, i *bridgeInterface) error {
err := checkBridgeNetFiltering(config, i)
if err != nil {
if ptherr, ok := err.(*os.PathError); ok {
if errno, ok := ptherr.Err.(syscall.Errno); ok && errno == syscall.ENOENT {
if isRunningInContainer() {
logrus.Warnf("running inside docker container, ignoring missing kernel params: %v", err)
err = nil
} else {
err = errors.New("please ensure that br_netfilter kernel module is loaded")
}
}
if err != nil && err.(*os.PathError).Err == unix.ENOENT {
if isRunningInContainer() {
logrus.Warnf("running inside docker container, ignoring missing kernel params: %v", err)
err = nil
} else {
err = errors.New("please ensure that br_netfilter kernel module is loaded")
}
if err != nil {
return fmt.Errorf("cannot restrict inter-container communication: %v", err)
Expand Down
6 changes: 3 additions & 3 deletions drivers/overlay/encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"hash/fnv"
"net"
"sync"
"syscall"

"strconv"

Expand All @@ -17,6 +16,7 @@ import (
"github.com/docker/libnetwork/types"
"github.com/sirupsen/logrus"
"github.com/vishvananda/netlink"
"golang.org/x/sys/unix"
)

const (
Expand Down Expand Up @@ -372,7 +372,7 @@ func saExists(sa *netlink.XfrmState) (bool, error) {
switch err {
case nil:
return true, nil
case syscall.ESRCH:
case unix.ESRCH:
return false, nil
default:
err = fmt.Errorf("Error while checking for SA existence: %v", err)
Expand All @@ -386,7 +386,7 @@ func spExists(sp *netlink.XfrmPolicy) (bool, error) {
switch err {
case nil:
return true, nil
case syscall.ENOENT:
case unix.ENOENT:
return false, nil
default:
err = fmt.Errorf("Error while checking for SP existence: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions drivers/overlay/joinleave.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package overlay
import (
"fmt"
"net"
"syscall"

"github.com/docker/libnetwork/driverapi"
"github.com/docker/libnetwork/ns"
"github.com/docker/libnetwork/types"
"github.com/gogo/protobuf/proto"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
)

// Join method is invoked when a Sandbox is attached to an endpoint.
Expand All @@ -34,7 +34,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,

nlh := ns.NlHandle()

if n.secure && !nlh.SupportsNetlinkFamily(syscall.NETLINK_XFRM) {
if n.secure && !nlh.SupportsNetlinkFamily(unix.NETLINK_XFRM) {
return fmt.Errorf("cannot join secure network: required modules to install IPSEC rules are missing on host")
}

Expand Down
Loading