From ac4246e1f55c269d8734bc3ab617b3c16746dd0f Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 6 Sep 2016 12:05:51 +0100 Subject: [PATCH 1/2] Pass in default subnet when creating 'weave' plugin network. New behaviour in Docker 1.12 means it disregards a plugin-supplied address pool that overlaps an existing route, which causes a hang as noted in #2469. When we pass in the subnet, Docker believes we really do want that address range and avoids the hang. --- prog/weaveutil/plugin_network.go | 12 ++++++++---- weave | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/prog/weaveutil/plugin_network.go b/prog/weaveutil/plugin_network.go index 9ff52314..33c3a79a 100644 --- a/prog/weaveutil/plugin_network.go +++ b/prog/weaveutil/plugin_network.go @@ -10,11 +10,12 @@ import ( ) func createPluginNetwork(args []string) error { - if len(args) != 2 { - cmdUsage("create-plugin-network", " ") + if len(args) != 3 { + cmdUsage("create-plugin-network", " ") } networkName := args[0] driverName := args[1] + subnet := args[2] d, err := newDockerClient() if err != nil { return err @@ -24,8 +25,11 @@ func createPluginNetwork(args []string) error { Name: networkName, CheckDuplicate: true, Driver: driverName, - IPAM: docker.IPAMOptions{Driver: driverName}, - Options: map[string]interface{}{plugin.MulticastOption: "true"}, + IPAM: docker.IPAMOptions{ + Driver: driverName, + Config: []docker.IPAMConfig{{Subnet: subnet}}, + }, + Options: map[string]interface{}{plugin.MulticastOption: "true"}, }) if err != docker.ErrNetworkAlreadyExists && err != nil { // Despite appearances to the contrary, CreateNetwork does diff --git a/weave b/weave index c23570d2..97d6a25a 100755 --- a/weave +++ b/weave @@ -1782,7 +1782,8 @@ launch_plugin_if_not_running() { return 1 fi wait_for_status $PLUGIN_CONTAINER_NAME http_call_unix $PLUGIN_CONTAINER_NAME status.sock - util_op create-plugin-network weave weavemesh + WEAVE_IPAM_SUBNET=$(call_weave GET /ipinfo/defaultsubnet) + util_op create-plugin-network weave weavemesh $WEAVE_IPAM_SUBNET } plugin_disabled() { From c69e140e9e43d456b6fe5812a2bc61bc67953b93 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 7 Sep 2016 12:57:45 +0100 Subject: [PATCH 2/2] Check current tx value before trying to set it --- net/ethtool.go | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/net/ethtool.go b/net/ethtool.go index 34209f0d..053a30ec 100644 --- a/net/ethtool.go +++ b/net/ethtool.go @@ -6,6 +6,7 @@ import "unsafe" const ( SIOCETHTOOL = 0x8946 // linux/sockios.h + ETHTOOL_GTXCSUM = 0x00000016 // linux/ethtool.h ETHTOOL_STXCSUM = 0x00000017 // linux/ethtool.h IFNAMSIZ = 16 // linux/if.h ) @@ -22,31 +23,38 @@ type EthtoolValue struct { Data uint32 } +func ioctlEthtool(fd int, argp uintptr) error { + _, _, errno := syscall.RawSyscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(SIOCETHTOOL), argp) + if errno != 0 { + return errno + } + return nil +} + // Disable TX checksum offload on specified interface func EthtoolTXOff(name string) error { if len(name)+1 > IFNAMSIZ { return fmt.Errorf("name too long") } - value := EthtoolValue{ETHTOOL_STXCSUM, 0} - request := IFReqData{Data: uintptr(unsafe.Pointer(&value))} - - copy(request.Name[:], name) - socket, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_DGRAM, 0) if err != nil { return err } defer syscall.Close(socket) - _, _, errno := syscall.RawSyscall(syscall.SYS_IOCTL, - uintptr(socket), - uintptr(SIOCETHTOOL), - uintptr(unsafe.Pointer(&request))) + // Request current value + value := EthtoolValue{Cmd: ETHTOOL_GTXCSUM} + request := IFReqData{Data: uintptr(unsafe.Pointer(&value))} + copy(request.Name[:], name) - if errno != 0 { - return errno + if err := ioctlEthtool(socket, uintptr(unsafe.Pointer(&request))); err != nil { + return err + } + if value.Data == 0 { // if already off, don't try to change + return nil } - return nil + value = EthtoolValue{ETHTOOL_STXCSUM, 0} + return ioctlEthtool(socket, uintptr(unsafe.Pointer(&request))) }