Enable AWSVPC

This requires the following additional steps:

- Setting proxy_arp on on the bridge, because that's how we do
  the routing (check the comment at the place where we set it on).
- Disable ARP requests queueing, because it introduces unnecessary
  delay for the first ARP request resulting in a high latency of
  the first packet (on t2.micro machines I've encountered ~700ms
  latency). Also, the queue is bounded, so we might risking to drop
  the requests.
This commit is contained in:
Martynas Pumputis authored and Bryan Boreham committed 2016-06-08 16:44:54 +01:00
1 parent 7670fed72c
commit fb9b4ddec0
1 file changed
+36 -8
+36 -8
View File
@@ -181,6 +181,7 @@ exec_remote() {
-e PROXY_HOST="$PROXY_HOST" \
-e COVERAGE \
-e CHECKPOINT_DISABLE \
-e AWSVPC \
$WEAVEEXEC_DOCKER_ARGS $EXEC_IMAGE --local "$@"
}
@@ -532,9 +533,10 @@ random_mac() {
util_op() {
if command_exists weaveutil ; then
weaveutil "$@"
WEAVE_HTTP_ADDR=$WEAVE_HTTP_ADDR weaveutil "$@"
else
docker run --rm --privileged --net=host --pid=host $(docker_sock_options) \
-e WEAVE_HTTP_ADDR \
--entrypoint=/usr/bin/weaveutil $EXEC_IMAGE "$@"
fi
}
@@ -645,7 +647,7 @@ EOF
fi
fi
[ "$1" = "--without-ethtool" ] || ethtool_tx_off_$BRIDGE_TYPE $BRIDGE
[ "$1" = "--without-ethtool" -o -n "$AWSVPC" ] || ethtool_tx_off_$BRIDGE_TYPE $BRIDGE
ip link set dev $BRIDGE up
@@ -660,6 +662,12 @@ expose_ip() {
if ! ip addr show dev $BRIDGE | grep -qF $CIDR ; then
ip addr add dev $BRIDGE $CIDR
arp_update $BRIDGE $CIDR || true
# Remove a default route installed by the kernel, because awsvpc
# has installed it as well
if [ -n "$AWSVPC" ]; then
RCIDR=$(ip route list exact $CIDR proto kernel | head -n1 | cut -d' ' -f1)
[ -n "$RCIDR" ] && ip route del dev $BRIDGE proto kernel $RCIDR
fi
fi
[ -z "$FQDN" ] || when_weave_running put_dns_fqdn_no_check_alive weave:expose $FQDN $CIDR
done
@@ -1501,22 +1509,19 @@ launch_router() {
LAUNCHING_ROUTER=1
check_forwarding_rules
enforce_docker_bridge_addr_assign_type
create_bridge
docker_bridge_ip
# 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)
# backward compatibility...
if is_cidr "$1" ; then
echo "WARNING: $1 parameter ignored; 'weave launch' no longer takes a CIDR as the first parameter" >&2
shift 1
fi
CONTAINER_PORT=$PORT
ARGS=
IPRANGE=
IPRANGE_SPECIFIED=
docker_bridge_ip
DNS_ROUTER_OPTS="--dns-listen-address $DOCKER_BRIDGE_IP:53"
NO_DNS_OPT=
@@ -1558,6 +1563,10 @@ launch_router() {
--no-restart)
RESTART_POLICY=
;;
--awsvpc)
AWSVPC_ARGS="--awsvpc"
AWSVPC=1
;;
*)
ARGS="$ARGS '$(echo "$1" | sed "s|'|'\"'\"'|g")'"
;;
@@ -1565,6 +1574,13 @@ launch_router() {
shift
done
eval "set -- $ARGS"
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)
if [ -z "$IPRANGE_SPECIFIED" ] ; then
IPRANGE="10.32.0.0/12"
if ! check_overlap $IPRANGE ; then
@@ -1601,11 +1617,23 @@ launch_router() {
--ipalloc-range "$IPRANGE" \
--dns-effective-listen-address $DOCKER_BRIDGE_IP \
$DNS_ROUTER_OPTS $NO_DNS_OPT \
$AWSVPC_ARGS \
--http-addr $HTTP_ADDR \
"$@")
setup_router_iface_$BRIDGE_TYPE
wait_for_status $CONTAINER_NAME http_call $HTTP_ADDR
populate_router
if [ -n "$AWSVPC" ]; then
expose_ip
# Set proxy_arp on the bridge, so that it could accept packets destined
# to containers within the same subnet but running on remote hosts.
# Without it, exact routes on each container are required.
echo 1 >/proc/sys/net/ipv4/conf/$BRIDGE/proxy_arp
# Avoid delaying the first ARP request. Also, setting it to 0 avoids
# placing the request into a bounded queue as it can be seen:
# https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/net/ipv4/arp.c?id=refs/tags/v4.6.1#n819
echo 0 >/proc/sys/net/ipv4/neigh/$BRIDGE/proxy_delay
fi
}
# Recreate the parameter values that are set when the router is first launched