diff --git a/weave b/weave index cc49ace5..df82205c 100755 --- a/weave +++ b/weave @@ -349,8 +349,10 @@ BRIDGE=weave DATAPATH=datapath BRIDGE_IFNAME=vethwe-bridge DATAPATH_IFNAME=vethwe-datapath +PCAP_IFNAME=vethwe-pcap CONTAINER_IFNAME=ethwe PORT=${WEAVE_PORT:-6783} +HTTP_HOST=127.0.0.1 HTTP_PORT=6784 PROXY_PORT=12375 PROXY_CONTAINER_NAME=weaveproxy @@ -675,9 +677,10 @@ destroy_bridge() { fi done - # Remove any lingering bridged fastdp veth + # Remove any lingering bridged fastdp and pcap veths ip link del $DATAPATH_IFNAME >/dev/null 2>&1 || true ip link del $BRIDGE_IFNAME >/dev/null 2>&1 || true + ip link del $PCAP_IFNAME >/dev/null 2>&1 || true if [ "$DOCKER_BRIDGE" != "$BRIDGE" ] ; then run_iptables -t filter -D FORWARD -i $DOCKER_BRIDGE -o $BRIDGE -j DROP 2>/dev/null || true @@ -774,15 +777,7 @@ connect_container_to_bridge() { return 1 fi - # Versions of the 'ip' command differ in whether they create a - # veth pair in the 'up' or 'down' state. Furthermore, moving one - # end into a netns normally sets them to 'down'. But, moving an - # end into the default netns is a null operation, so they stay up, - # which leads to errors in 'set name' since that requires the - # interface to be down. So to get a consistent result, we set the - # interface 'down' to begin with. - if ! netnsenter ip link set $GUEST_IFNAME down || - ! netnsenter ip link set $GUEST_IFNAME name $1 || + if ! netnsenter ip link set $GUEST_IFNAME name $1 || ! ip link set $LOCAL_IFNAME up || ! add_iface_$BRIDGE_TYPE $LOCAL_IFNAME || ! configure_arp_cache $1 "netnsenter" ; then @@ -807,7 +802,7 @@ router_opts_fastdp() { } router_opts_bridge() { - echo "--iface $CONTAINER_IFNAME" + echo "--iface $PCAP_IFNAME" } router_opts_bridged_fastdp() { @@ -832,16 +827,15 @@ setup_router_iface_fastdp() { } setup_router_iface_bridge() { - if ! netnsenter ip link show eth0 >/dev/null ; then - echo "Perhaps you are running the docker daemon with container networking disabled (-b=none)." >&2 + ip link show $PCAP_IFNAME >/dev/null 2>&1 && return 0 + if ! ip link add name $BRIDGE_IFNAME mtu $MTU type veth peer name $PCAP_IFNAME mtu $MTU || + ! ip link set $BRIDGE_IFNAME up || + ! add_iface_bridge $BRIDGE_IFNAME || + ! ip link set $PCAP_IFNAME up ; then + ip link del $PCAP_IFNAME >/dev/null 2>&1 || true + ip link del $BRIDGE_IFNAME >/dev/null 2>&1 || true return 1 fi - # No-op if already attached - netnsenter ip link show $CONTAINER_IFNAME >/dev/null 2>&1 && return 0 - - connect_container_to_bridge $CONTAINER_IFNAME && - netnsenter ethtool -K eth0 tx off >/dev/null && - netnsenter ip link set $CONTAINER_IFNAME up } setup_router_iface_bridged_fastdp() { @@ -1565,10 +1559,6 @@ launch_router() { IPRANGE= IPRANGE_SPECIFIED= - # DNS_PORT_MAPPING is only used if the router runs in a container - # netns. DNS_ROUTER_OPTS is only used if the router runs in the - # host netns. - DNS_PORT_MAPPING="-p $DOCKER_BRIDGE_IP:53:53/udp -p $DOCKER_BRIDGE_IP:53:53/tcp" DNS_ROUTER_OPTS="--dns-listen-address $DOCKER_BRIDGE_IP:53" NO_DNS_OPT= @@ -1603,7 +1593,6 @@ launch_router() { IPRANGE_SPECIFIED=1 ;; --no-dns) - DNS_PORT_MAPPING= DNS_ROUTER_OPTS= NO_DNS_OPT="--no-dns" ARGS="$ARGS $1" @@ -1629,15 +1618,11 @@ launch_router() { fi fi - [ "$BRIDGE_TYPE" != bridge ] && NETHOST_OPT="--net=host" && HTTP_IP=127.0.0.1 - # Set WEAVE_DOCKER_ARGS in the environment in order to supply # additional parameters, such as resource limits, to docker # when launching the weave container. - ROUTER_CONTAINER=$(docker run --privileged -d --name=$CONTAINER_NAME \ + ROUTER_CONTAINER=$(docker run --privileged --net=host -d --name=$CONTAINER_NAME \ $(docker_sock_options) \ - -p $PORT:$CONTAINER_PORT/tcp -p $PORT:$CONTAINER_PORT/udp \ - ${NETHOST_OPT:-$DNS_PORT_MAPPING} \ -e WEAVE_PASSWORD \ -e WEAVE_CIDR=none \ $WEAVE_DOCKER_ARGS $IMAGE $COVERAGE_ARGS \ @@ -1645,10 +1630,10 @@ launch_router() { $(router_opts_$BRIDGE_TYPE) \ --ipalloc-range "$IPRANGE" \ --dns-effective-listen-address $DOCKER_BRIDGE_IP \ - ${NETHOST_OPT:+$DNS_ROUTER_OPTS} $NO_DNS_OPT \ - --http-addr $HTTP_IP:$HTTP_PORT \ + $DNS_ROUTER_OPTS $NO_DNS_OPT \ + --http-addr $HTTP_HOST:$HTTP_PORT \ "$@") - with_container_netns_or_die $CONTAINER_NAME setup_router_iface_$BRIDGE_TYPE + setup_router_iface_$BRIDGE_TYPE attach_router }