From 98a7d3fc99314b804b31ea4d62d349b1afe49194 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Thu, 3 Dec 2015 15:08:53 +0000 Subject: [PATCH] `weave run` and `weave attach` accept --no-multicast-route --- weave | 58 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/weave b/weave index bd3c49dc..cc4beb64 100755 --- a/weave +++ b/weave @@ -59,7 +59,8 @@ weave connect [--replace] [ ...] weave forget ... weave status [targets | connections | peers | dns] weave report [-f ] -weave run [--with-dns | --without-dns] [--no-rewrite-hosts] +weave run [--with-dns | --without-dns] + [--no-rewrite-hosts] [--no-multicast-route] [ ...] ... weave start [ ...] weave attach [ ...] @@ -258,20 +259,42 @@ elif [ "$1" = "run" -a -z "$IS_LOCAL" ] ; then # because we are passing arbitrary arguments on to docker run, and # we can't rely on our baked-in docker to support those arguments. shift 1 + if [ "$1" != "--without-dns" ] ; then DNS_ARGS=$(exec_remote dns-args "$@" || true) fi shift $(dns_arg_count "$@") - if [ "$1" = "--no-rewrite-hosts" ] ; then + + REWRITE_HOSTS=1 + NO_MULTICAST_ROUTE= + while [ $# -gt 0 ]; do + case "$1" in + --no-rewrite-hosts) + REWRITE_HOSTS= + ;; + --no-multicast-route) + NO_MULTICAST_ROUTE=1 + ;; + *) + break + ;; + esac shift - else + done + + if [ -n "$REWRITE_HOSTS" ] ; then extra_hosts_args "$@" DNS_EXTRA_HOSTS_ARGS="--rewrite-hosts $DNS_EXTRA_HOSTS_ARGS" fi + + if [ -n "$NO_MULTICAST_ROUTE" ] ; then + ATTACH_ARGS="--no-multicast-route" + fi + collect_cidr_args "$@" shift $CIDR_ARG_COUNT CONTAINER=$(docker $DOCKER_CLIENT_ARGS run -e WEAVE_CIDR=none $DNS_ARGS -d "$@") - exec_remote attach $CIDR_ARGS --or-die $DNS_EXTRA_HOSTS_ARGS $CONTAINER >/dev/null + exec_remote attach $CIDR_ARGS --or-die $DNS_EXTRA_HOSTS_ARGS $ATTACH_ARGS $CONTAINER >/dev/null echo $CONTAINER exit 0 fi @@ -841,8 +864,10 @@ attach() { # multicast packets. Since RFC1122 prohibits sending of ICMP # errors for packets with multicast destinations, that causes # packets larger than the PMTU to be dropped silently. - if ! netnsenter ip route show | grep '^224\.0\.0\.0/4' >/dev/null ; then - netnsenter ip route add 224.0.0.0/4 dev $CONTAINER_IFNAME mtu lock $MTU + if [ -z "$NO_MULTICAST_ROUTE" ] ; then + if ! netnsenter ip route show | grep '^224\.0\.0\.0/4' >/dev/null ; then + netnsenter ip route add 224.0.0.0/4 dev $CONTAINER_IFNAME mtu lock $MTU + fi fi } @@ -1914,10 +1939,21 @@ EOF dns_args "$@" shift $(dns_arg_count "$@") REWRITE_HOSTS=1 - if [ "$1" = "--no-rewrite-hosts" ] ; then - REWRITE_HOSTS= + NO_MULTICAST_ROUTE= + while [ $# -gt 0 ]; do + case "$1" in + --no-rewrite-hosts) + REWRITE_HOSTS= + ;; + --no-multicast-route) + NO_MULTICAST_ROUTE=1 + ;; + *) + break + ;; + esac shift - fi + done collect_cidr_args "$@" shift $CIDR_ARG_COUNT CONTAINER=$(docker run -e WEAVE_CIDR=none $DNS_ARGS -d "$@") @@ -1954,6 +1990,7 @@ EOF attach) DNS_EXTRA_HOSTS= REWRITE_HOSTS= + NO_MULTICAST_ROUTE= collect_cidr_args "$@" shift $CIDR_ARG_COUNT while [ $# -gt 0 ]; do @@ -1971,6 +2008,9 @@ EOF --add-host=*) DNS_EXTRA_HOSTS="${1#*=} $DNS_EXTRA_HOSTS" ;; + --no-multicast-route) + NO_MULTICAST_ROUTE=1 + ;; *) break ;;