Optional intermediary bridge netdev

This commit is contained in:
Adam Harrison committed 2015-11-25 16:31:32 +00:00
1 parent c420c21219
commit a31e7118b4
1 file changed
+72 -3
+72 -3
View File
@@ -293,6 +293,9 @@ PROCFS=${PROCFS:-/proc}
DOCKER_BRIDGE=${DOCKER_BRIDGE:-docker0}
CONTAINER_NAME=${WEAVE_CONTAINER_NAME:-weave}
BRIDGE=weave
FASTDP_BRIDGE=fdp-bridge
BRIDGE_IFNAME=${BRIDGE}-link
FASTDP_BRIDGE_IFNAME=${FASTDP_BRIDGE}-link
CONTAINER_IFNAME=ethwe
# ROUTER_HOSTNETNS_IFNAME is only used for fastdp with encryption
ROUTER_HOSTNETNS_IFNAME=veth-weave
@@ -404,7 +407,13 @@ create_bridge() {
if [ -n "$WEAVE_NO_FASTDP" ] ; then
BRIDGE_TYPE=bridge
elif docker run --rm --privileged --net=host $IMAGE $COVERAGE_ARGS --create-datapath --datapath=$BRIDGE ; then
BRIDGE_TYPE=fastdp
# This is not meant to be exercised by users; to be
# replaced by autodetection as part of #1681.
if [ -n "$WEAVE_NO_BRIDGED_FASTDP" ]; then
BRIDGE_TYPE=fastdp
else
BRIDGE_TYPE=bridged_fastdp
fi
elif [ $? = 17 ] ; then
# Exit status of 17 means the kernel doesn't have ODP
BRIDGE_TYPE=bridge
@@ -449,7 +458,11 @@ EOF
return 1
fi
else
BRIDGE_TYPE=fastdp
if [ -d /sys/class/net/$FASTDP_BRIDGE ] ; then
BRIDGE_TYPE=bridged_fastdp
else
BRIDGE_TYPE=fastdp
fi
if [ -n "$WEAVE_NO_FASTDP" ] ; then
cat <<EOF >&1
@@ -490,6 +503,39 @@ init_bridge_fastdp() {
ip link set dev $BRIDGE mtu $MTU
}
init_bridge_bridged_fastdp() {
# Initialise the datapath as normal. NB sets MTU for use below
init_bridge_fastdp
# Create linking veth pair
ip link del $FASTDP_BRIDGE_IFNAME >/dev/null 2>&1 || true
ip link del $BRIDGE_IFNAME >/dev/null 2>&1 || true
ip link add name $FASTDP_BRIDGE_IFNAME mtu $MTU type veth peer name $BRIDGE_IFNAME mtu $MTU || return 1
# Create intermediary bridge netdev
ip link add name $FASTDP_BRIDGE type bridge
# Set random MAC
ip link set dev $FASTDP_BRIDGE address $(random_mac)
# Set MTU
ip link add name v${CONTAINER_IFNAME}du mtu $MTU type dummy
ip link set dev v${CONTAINER_IFNAME}du master $FASTDP_BRIDGE
ip link del dev v${CONTAINER_IFNAME}du
# Link intermediary bridge and datapath
if ! ip link set $FASTDP_BRIDGE_IFNAME up ||
! ip link set $BRIDGE_IFNAME up ||
! add_iface_fastdp $BRIDGE_IFNAME || ! ip link set $FASTDP_BRIDGE_IFNAME master $FASTDP_BRIDGE ; then
ip link del $BRIDGE_IFNAME >/dev/null 2>&1 || true
ip link del $FASTDP_BRIDGE >/dev/null 2>&1 || true
docker run --rm --privileged --net=host $IMAGE $COVERAGE_ARGS --delete-datapath --datapath=$BRIDGE >/dev/null 2>&1 || true
return 1
fi
ip link set dev $FASTDP_BRIDGE up
}
init_bridge_bridge() {
MTU=${WEAVE_MTU:-65535}
@@ -513,6 +559,10 @@ ethtool_tx_off_fastdp() {
true
}
ethtool_tx_off_bridged_fastdp() {
true
}
ethtool_tx_off_bridge() {
ethtool -K $1 tx off >/dev/null
}
@@ -526,6 +576,13 @@ destroy_bridge() {
fi
fi
if [ -d /sys/class/net/$FASTDP_BRIDGE ] ; then
ip link del dev $FASTDP_BRIDGE
fi
ip link del $FASTDP_BRIDGE_IFNAME >/dev/null 2>&1 || true
ip link del $BRIDGE_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
fi
@@ -632,6 +689,10 @@ add_iface_fastdp() {
docker run --rm --privileged --net=host $IMAGE $COVERAGE_ARGS --datapath=$BRIDGE --add-datapath-iface=$1
}
add_iface_bridged_fastdp() {
ip link set $1 master $FASTDP_BRIDGE
}
add_iface_bridge() {
ip link set $1 master $BRIDGE
}
@@ -669,6 +730,10 @@ router_opts_fastdp() {
fi
}
router_opts_bridged_fastdp() {
router_opts_fastdp
}
router_opts_bridge() {
echo "--iface $CONTAINER_IFNAME"
}
@@ -689,6 +754,10 @@ setup_router_iface_fastdp() {
fi
}
setup_router_iface_bridged_fastdp() {
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
@@ -1466,7 +1535,7 @@ launch_router() {
fi
fi
if [ "$BRIDGE_TYPE" = fastdp ] ; then
if [ "$BRIDGE_TYPE" = fastdp -o "$BRIDGE_TYPE" = bridged_fastdp ] ; then
NETHOST_OPT="--net=host"
HTTP_IP=127.0.0.1
# In case there is a lingering veth-weave netdev