From a26fc67ded1dce7193e314e7bbe5f814dde4d60b Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 18 May 2016 13:15:06 +0100 Subject: [PATCH] New way of initializing; remove --iface option --- prog/weaver/main.go | 25 ++++++++++--------------- weave | 1 + 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/prog/weaver/main.go b/prog/weaver/main.go index daccdd6f..fe222889 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -129,7 +129,6 @@ func main() { networkConfig weave.NetworkConfig protocolMinVersion int resume bool - ifaceName string routerName string nickName string password string @@ -145,7 +144,6 @@ func main() { peers []string noDNS bool dnsConfig dnsConfig - datapathName string trustedSubnetStr string dbPrefix string discoveryEndpoint string @@ -168,7 +166,6 @@ func main() { mflag.IntVar(&config.Port, []string{"#port", "-port"}, mesh.Port, "router port") mflag.IntVar(&protocolMinVersion, []string{"-min-protocol-version"}, mesh.ProtocolMinVersion, "minimum weave protocol version") mflag.BoolVar(&resume, []string{"-resume"}, false, "resume connections to previous peers") - mflag.StringVar(&ifaceName, []string{"#iface", "-iface"}, "", "name of interface to capture/inject from (disabled if blank)") mflag.StringVar(&bridgeConfig.WeaveBridgeName, []string{"-weave-bridge"}, "weave", "name of weave bridge") mflag.StringVar(&bridgeConfig.DockerBridgeName, []string{"-docker-bridge"}, "", "name of Docker bridge") mflag.StringVar(&routerName, []string{"#name", "-name"}, "", "name of router (defaults to MAC of interface)") @@ -195,7 +192,8 @@ func main() { mflag.DurationVar(&dnsConfig.ClientTimeout, []string{"-dns-fallback-timeout"}, nameserver.DefaultClientTimeout, "timeout for fallback DNS requests") mflag.StringVar(&dnsConfig.EffectiveListenAddress, []string{"-dns-effective-listen-address"}, "", "address DNS will actually be listening, after Docker port mapping") mflag.StringVar(&dnsConfig.ResolvConf, []string{"-resolv-conf"}, "", "path to resolver configuration for fallback DNS lookups") - mflag.StringVar(&datapathName, []string{"-datapath"}, "", "ODP datapath name") + mflag.StringVar(&bridgeConfig.DatapathName, []string{"-datapath"}, "", "ODP datapath name") + mflag.BoolVar(&bridgeConfig.NoFastdp, []string{"-no-fastdp"}, false, "Disable Fast Datapath") mflag.StringVar(&trustedSubnetStr, []string{"-trusted-subnets"}, "", "comma-separated list of trusted subnets in CIDR notation") mflag.StringVar(&dbPrefix, []string{"-db-prefix"}, "/weavedb/weave", "pathname/prefix of filename to store data") mflag.BoolVar(&bridgeConfig.IsAWSVPC, []string{"-awsvpc"}, false, "use AWS VPC for routing") @@ -247,7 +245,6 @@ func main() { networkConfig.PacketLogging = nopPacketLogging{} } - bridgeConfig.DatapathName = datapathName if bridgeConfig.DockerBridgeName != "" { if err := weavenet.EnforceAddrAssignType(bridgeConfig.DockerBridgeName); err != nil { Log.Errorf("While checking address assignment type of %s: %s", bridgeConfig.DockerBridgeName, err) @@ -259,7 +256,7 @@ func main() { config.Password = determinePassword(password) - overlay, bridge := createOverlay(datapathName, ifaceName, bridgeConfig, config.Host, config.Port, bufSzMB, config.Password != nil) + overlay, bridge := createOverlay(bridgeType, bridgeConfig, config.Host, config.Port, bufSzMB, config.Password != nil) networkConfig.Bridge = bridge if bridge != nil { @@ -466,29 +463,27 @@ func (nopPacketLogging) LogPacket(string, weave.PacketKey) { func (nopPacketLogging) LogForwardPacket(string, weave.ForwardPacketKey) { } -func createOverlay(datapathName string, ifaceName string, config weavenet.BridgeConfig, host string, port int, bufSzMB int, enableEncryption bool) (weave.NetworkOverlay, weave.Bridge) { +func createOverlay(bridgeType weavenet.BridgeType, config weavenet.BridgeConfig, host string, port int, bufSzMB int, enableEncryption bool) (weave.NetworkOverlay, weave.Bridge) { overlay := weave.NewOverlaySwitch() var bridge weave.Bridge var ignoreSleeve bool - switch { - case config.IsAWSVPC: + switch bridgeType { + case weavenet.AWSVPC: vpc := weave.NewAWSVPC() overlay.Add("awsvpc", vpc) bridge = weave.NullBridge{} // Currently, we do not support any overlay with AWSVPC ignoreSleeve = true - case datapathName != "" && ifaceName != "": - Log.Fatal("At most one of --datapath and --iface must be specified.") - case datapathName != "": - iface, err := weavenet.EnsureInterface(datapathName) + case weavenet.Fastdp, weavenet.BridgedFastdp: + iface, err := weavenet.EnsureInterface(config.DatapathName) checkFatal(err) fastdp, err := weave.NewFastDatapath(iface, port, enableEncryption) checkFatal(err) bridge = fastdp.Bridge() overlay.Add("fastdp", fastdp.Overlay()) - case ifaceName != "": - iface, err := weavenet.EnsureInterface(ifaceName) + case weavenet.Bridge: + iface, err := weavenet.EnsureInterface(weavenet.PcapIfaceName) checkFatal(err) bridge, err = weave.NewPcap(iface, bufSzMB*1024*1024) // bufsz flag is in MB checkFatal(err) diff --git a/weave b/weave index adbed5ba..95156f63 100755 --- a/weave +++ b/weave @@ -578,6 +578,7 @@ configure_veth_attached_bridge() { router_bridge_opts() { echo --docker-bridge "$DOCKER_BRIDGE" --weave-bridge "$BRIDGE" --datapath "$DATAPATH" [ -z "$WEAVE_MTU" ] || echo --mtu "$WEAVE_MTU" + [ -z $WEAVE_NO_FASTDP ] || echo --no-fastdp } ask_version() {