Move creation of bridge inside router
This commit is contained in:
1 parent
dd232775e6
commit
e7e3608642
2 files changed
+20
-21
No files matched your search
@@ -125,6 +125,7 @@ func main() {
|
|||||||
var (
|
var (
|
||||||
justVersion bool
|
justVersion bool
|
||||||
config mesh.Config
|
config mesh.Config
|
||||||
|
bridgeConfig weavenet.BridgeConfig
|
||||||
networkConfig weave.NetworkConfig
|
networkConfig weave.NetworkConfig
|
||||||
protocolMinVersion int
|
protocolMinVersion int
|
||||||
resume bool
|
resume bool
|
||||||
@@ -169,6 +170,8 @@ func main() {
|
|||||||
mflag.IntVar(&protocolMinVersion, []string{"-min-protocol-version"}, mesh.ProtocolMinVersion, "minimum weave protocol version")
|
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.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(&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(&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(&nickName, []string{"#nickname", "-nickname"}, "", "nickname of peer (defaults to hostname)")
|
||||||
mflag.StringVar(&password, []string{"#password", "-password"}, "", "network password")
|
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.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.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(&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(&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(&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)")
|
mflag.StringVar(&ipamConfig.Mode, []string{"-ipalloc-init"}, "", "allocator initialisation strategy (consensus, seed or observer)")
|
||||||
@@ -244,6 +248,16 @@ func main() {
|
|||||||
networkConfig.PacketLogging = nopPacketLogging{}
|
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)
|
config.Password = determinePassword(password)
|
||||||
|
|
||||||
overlay, bridge := createOverlay(datapathName, ifaceName, isAWSVPC, config.Host, config.Port, bufSzMB, config.Password != nil)
|
overlay, bridge := createOverlay(datapathName, ifaceName, isAWSVPC, config.Host, config.Port, bufSzMB, config.Password != nil)
|
||||||
|
|||||||
@@ -281,7 +281,6 @@ DATAPATH=datapath
|
|||||||
CONTAINER_IFNAME=ethwe
|
CONTAINER_IFNAME=ethwe
|
||||||
BRIDGE_IFNAME=v${CONTAINER_IFNAME}-bridge
|
BRIDGE_IFNAME=v${CONTAINER_IFNAME}-bridge
|
||||||
DATAPATH_IFNAME=v${CONTAINER_IFNAME}-datapath
|
DATAPATH_IFNAME=v${CONTAINER_IFNAME}-datapath
|
||||||
PCAP_IFNAME=v${CONTAINER_IFNAME}-pcap
|
|
||||||
PORT=${WEAVE_PORT:-6783}
|
PORT=${WEAVE_PORT:-6783}
|
||||||
HTTP_ADDR=${WEAVE_HTTP_ADDR:-127.0.0.1:6784}
|
HTTP_ADDR=${WEAVE_HTTP_ADDR:-127.0.0.1:6784}
|
||||||
STATUS_ADDR=${WEAVE_STATUS_ADDR:-127.0.0.1:6782}
|
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
|
ip link set $GUEST_IFNAME master $bridge
|
||||||
}
|
}
|
||||||
|
|
||||||
router_opts_fastdp() {
|
router_bridge_opts() {
|
||||||
echo "--datapath $DATAPATH"
|
echo --docker-bridge "$DOCKER_BRIDGE" --weave-bridge "$BRIDGE" --datapath "$DATAPATH"
|
||||||
}
|
[ -z "$WEAVE_MTU" ] || echo --mtu "$WEAVE_MTU"
|
||||||
|
|
||||||
router_opts_bridge() {
|
|
||||||
echo "--iface $PCAP_IFNAME"
|
|
||||||
}
|
|
||||||
|
|
||||||
router_opts_bridged_fastdp() {
|
|
||||||
router_opts_fastdp "$@"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ask_version() {
|
ask_version() {
|
||||||
@@ -1287,8 +1279,6 @@ common_launch_args() {
|
|||||||
launch_router() {
|
launch_router() {
|
||||||
LAUNCHING_ROUTER=1
|
LAUNCHING_ROUTER=1
|
||||||
check_forwarding_rules
|
check_forwarding_rules
|
||||||
enforce_docker_bridge_addr_assign_type
|
|
||||||
|
|
||||||
# backward compatibility...
|
# backward compatibility...
|
||||||
if is_cidr "$1" ; then
|
if is_cidr "$1" ; then
|
||||||
echo "WARNING: $1 parameter ignored; 'weave launch' no longer takes a CIDR as the first parameter" >&2
|
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"
|
eval "set -- $ARGS"
|
||||||
|
|
||||||
setup_cni
|
setup_cni
|
||||||
create_bridge
|
validate_bridge_type
|
||||||
# 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)
|
|
||||||
|
|
||||||
if [ -z "$IPRANGE_SPECIFIED" ] ; then
|
if [ -z "$IPRANGE_SPECIFIED" ] ; then
|
||||||
IPRANGE="10.32.0.0/12"
|
IPRANGE="10.32.0.0/12"
|
||||||
@@ -1415,8 +1401,8 @@ launch_router() {
|
|||||||
-e WEAVE_PASSWORD \
|
-e WEAVE_PASSWORD \
|
||||||
-e CHECKPOINT_DISABLE \
|
-e CHECKPOINT_DISABLE \
|
||||||
$WEAVE_DOCKER_ARGS $IMAGE $COVERAGE_ARGS \
|
$WEAVE_DOCKER_ARGS $IMAGE $COVERAGE_ARGS \
|
||||||
--port $CONTAINER_PORT --name "$PEERNAME" --nickname "$(hostname)" \
|
--port $CONTAINER_PORT --nickname "$(hostname)" \
|
||||||
$(router_opts_$BRIDGE_TYPE) \
|
$(router_bridge_opts) \
|
||||||
--ipalloc-range "$IPRANGE" \
|
--ipalloc-range "$IPRANGE" \
|
||||||
--dns-effective-listen-address $DOCKER_BRIDGE_IP \
|
--dns-effective-listen-address $DOCKER_BRIDGE_IP \
|
||||||
$DNS_ROUTER_OPTS $NO_DNS_OPT \
|
$DNS_ROUTER_OPTS $NO_DNS_OPT \
|
||||||
@@ -1705,7 +1691,6 @@ EOF
|
|||||||
enforce_docker_bridge_addr_assign_type
|
enforce_docker_bridge_addr_assign_type
|
||||||
# We cannot use detect_awsvpc here, because HTTP server might not be started
|
# 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
|
! docker inspect -f '{{.Config.Cmd}}' $CONTAINER_NAME | grep -q -- "--awsvpc" || AWSVPC=1
|
||||||
create_bridge
|
|
||||||
fetch_router_args
|
fetch_router_args
|
||||||
wait_for_status $CONTAINER_NAME http_call $HTTP_ADDR
|
wait_for_status $CONTAINER_NAME http_call $HTTP_ADDR
|
||||||
setup_awsvpc
|
setup_awsvpc
|
||||||
|
|||||||
Reference in new issue
Block a user