Move creation of bridge inside router

This commit is contained in:
Bryan Boreham committed 2017-04-17 19:41:47 +00:00
1 parent dd232775e6
commit e7e3608642
2 files changed
+20 -21

No files matched your search

+14
View File
@@ -125,6 +125,7 @@ func main() {
var (
justVersion bool
config mesh.Config
bridgeConfig weavenet.BridgeConfig
networkConfig weave.NetworkConfig
protocolMinVersion int
resume bool
@@ -169,6 +170,8 @@ func main() {
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)")
mflag.StringVar(&nickName, []string{"#nickname", "-nickname"}, "", "nickname of peer (defaults to hostname)")
mflag.StringVar(&password, []string{"#password", "-password"}, "", "network password")
@@ -178,6 +181,7 @@ func main() {
mflag.IntVar(&config.ConnLimit, []string{"#connlimit", "#-connlimit", "-conn-limit"}, 30, "connection limit (0 for unlimited)")
mflag.BoolVar(&noDiscovery, []string{"#nodiscovery", "#-nodiscovery", "-no-discovery"}, false, "disable peer discovery")
mflag.IntVar(&bufSzMB, []string{"#bufsz", "-bufsz"}, 8, "capture buffer size in MB")
mflag.IntVar(&bridgeConfig.MTU, []string{"-mtu"}, 0, "MTU size")
mflag.StringVar(&httpAddr, []string{"#httpaddr", "#-httpaddr", "-http-addr"}, "", "address to bind HTTP interface to (disabled if blank, absolute path indicates unix domain socket)")
mflag.StringVar(&statusAddr, []string{"-status-addr"}, "", "address to bind status+metrics interface to (disabled if blank, absolute path indicates unix domain socket)")
mflag.StringVar(&ipamConfig.Mode, []string{"-ipalloc-init"}, "", "allocator initialisation strategy (consensus, seed or observer)")
@@ -244,6 +248,16 @@ 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)
}
}
bridgeType, err := weavenet.CreateBridge(&bridgeConfig)
checkFatal(err)
Log.Println("Bridge type is", bridgeType)
config.Password = determinePassword(password)
overlay, bridge := createOverlay(datapathName, ifaceName, isAWSVPC, config.Host, config.Port, bufSzMB, config.Password != nil)
+6 -21
View File
@@ -281,7 +281,6 @@ DATAPATH=datapath
CONTAINER_IFNAME=ethwe
BRIDGE_IFNAME=v${CONTAINER_IFNAME}-bridge
DATAPATH_IFNAME=v${CONTAINER_IFNAME}-datapath
PCAP_IFNAME=v${CONTAINER_IFNAME}-pcap
PORT=${WEAVE_PORT:-6783}
HTTP_ADDR=${WEAVE_HTTP_ADDR:-127.0.0.1:6784}
STATUS_ADDR=${WEAVE_STATUS_ADDR:-127.0.0.1:6782}
@@ -576,16 +575,9 @@ configure_veth_attached_bridge() {
ip link set $GUEST_IFNAME master $bridge
}
router_opts_fastdp() {
echo "--datapath $DATAPATH"
}
router_opts_bridge() {
echo "--iface $PCAP_IFNAME"
}
router_opts_bridged_fastdp() {
router_opts_fastdp "$@"
router_bridge_opts() {
echo --docker-bridge "$DOCKER_BRIDGE" --weave-bridge "$BRIDGE" --datapath "$DATAPATH"
[ -z "$WEAVE_MTU" ] || echo --mtu "$WEAVE_MTU"
}
ask_version() {
@@ -1287,8 +1279,6 @@ common_launch_args() {
launch_router() {
LAUNCHING_ROUTER=1
check_forwarding_rules
enforce_docker_bridge_addr_assign_type
# backward compatibility...
if is_cidr "$1" ; then
echo "WARNING: $1 parameter ignored; 'weave launch' no longer takes a CIDR as the first parameter" >&2
@@ -1358,11 +1348,7 @@ launch_router() {
eval "set -- $ARGS"
setup_cni
create_bridge
# We set the router name to the bridge MAC, which in turn is
# derived from the system UUID (if available), and thus stable
# across reboots.
PEERNAME=$(cat /sys/class/net/$BRIDGE/address)
validate_bridge_type
if [ -z "$IPRANGE_SPECIFIED" ] ; then
IPRANGE="10.32.0.0/12"
@@ -1415,8 +1401,8 @@ launch_router() {
-e WEAVE_PASSWORD \
-e CHECKPOINT_DISABLE \
$WEAVE_DOCKER_ARGS $IMAGE $COVERAGE_ARGS \
--port $CONTAINER_PORT --name "$PEERNAME" --nickname "$(hostname)" \
$(router_opts_$BRIDGE_TYPE) \
--port $CONTAINER_PORT --nickname "$(hostname)" \
$(router_bridge_opts) \
--ipalloc-range "$IPRANGE" \
--dns-effective-listen-address $DOCKER_BRIDGE_IP \
$DNS_ROUTER_OPTS $NO_DNS_OPT \
@@ -1705,7 +1691,6 @@ EOF
enforce_docker_bridge_addr_assign_type
# We cannot use detect_awsvpc here, because HTTP server might not be started
! docker inspect -f '{{.Config.Cmd}}' $CONTAINER_NAME | grep -q -- "--awsvpc" || AWSVPC=1
create_bridge
fetch_router_args
wait_for_status $CONTAINER_NAME http_call $HTTP_ADDR
setup_awsvpc