diff --git a/test/100_cross_hosts_test.sh b/test/100_cross_hosts_test.sh index 6d2e4875..425749e9 100755 --- a/test/100_cross_hosts_test.sh +++ b/test/100_cross_hosts_test.sh @@ -18,7 +18,7 @@ start_container $HOST2 $C2/24 --name=c2 assert_raises "exec_on $HOST1 c1 $PING $C2" start_container $HOST1 --name=c3 -start_container $HOST2 --name=c4 +start_container $HOST2 --subnet default --name=c4 C4=$(container_ip $HOST2 c4) assert_raises "exec_on $HOST1 c3 $PING $C4" diff --git a/weave b/weave index 9bbd98cc..ec7b34f8 100755 --- a/weave +++ b/weave @@ -108,6 +108,12 @@ collect_cidr_args() { while is_cidr "$1" || [ "$1" = "--subnet" ] ; do CIDR_ARGS="$CIDR_ARGS $1" CIDR_COUNT=$((CIDR_COUNT + 1)) + # only accept 'default' after '--subnet', in case someone has a container called 'default' + if [ "$1" = "--subnet" -a "$2" = "default" ] ; then + CIDR_ARGS="$CIDR_ARGS $2" + CIDR_COUNT=$((CIDR_ARG_COUNT + 1)) + shift 1 + fi shift 1 done } @@ -762,7 +768,11 @@ ipam_cidrs() { while [ $# -gt 0 ] ; do if [ $# -gt 1 -a "$1" = "--subnet" ] ; then shift 1 - CIDR=$(http_call $CONTAINER_NAME $HTTP_PORT POST /ip/$CONTAINER_ID/$1) + if [ "$1" = "default" ] ; then + CIDR=$(http_call $CONTAINER_NAME $HTTP_PORT POST /ip/$CONTAINER_ID) + else + CIDR=$(http_call $CONTAINER_NAME $HTTP_PORT POST /ip/$CONTAINER_ID/$1) + fi if [ "$CIDR" = "404 page not found" ] ; then echo "IP address allocation must be enabled to use --subnet (use the -iprange option on 'weave launch')" >&2 return 1