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))) } 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 7f5ef95d..bd748cba 100755 --- a/weave +++ b/weave @@ -1773,7 +1773,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() {