diff --git a/weave b/weave index a4994867..8a1bbcf0 100755 --- a/weave +++ b/weave @@ -175,7 +175,7 @@ with_container_netns () { return $STATUS } -launch() { +connect_container_to_bridge() { if ! ip link add name $LOCAL_IFNAME mtu $MTU type veth peer name $GUEST_IFNAME mtu $MTU ; then return 1 fi @@ -188,7 +188,12 @@ launch() { ip link set $LOCAL_IFNAME master $BRIDGE && ip link set $LOCAL_IFNAME up && - ip netns exec $NETNS ip link set $GUEST_IFNAME name $CONTAINER_IFNAME && + ip netns exec $NETNS ip link set $GUEST_IFNAME name $CONTAINER_IFNAME + } + + +launch() { + connect_container_to_bridge && ip netns exec $NETNS ip link set $CONTAINER_IFNAME up && check_command_and_run ethtool ip netns exec $NETNS ethtool -K eth0 tx off >/dev/null } @@ -209,20 +214,7 @@ attach() { return 0 fi - if ! ip link add name $LOCAL_IFNAME mtu $MTU type veth peer name $GUEST_IFNAME mtu $MTU ; then - return 1 - fi - - if ! ip link set $GUEST_IFNAME netns $NETNS ; then - # failed before we assigned the veth to the container's - # namespace - delete it - ip link del $LOCAL_IFNAME type veth || true - return 1 - fi - - if ! ip link set $LOCAL_IFNAME master $BRIDGE || - ! ip link set $LOCAL_IFNAME up || - ! ip netns exec $NETNS ip link set $GUEST_IFNAME name $CONTAINER_IFNAME || + if ! connect_container_to_bridge || ! ip netns exec $NETNS ip addr add $1 dev $CONTAINER_IFNAME || ! ip netns exec $NETNS ip link set $CONTAINER_IFNAME up || ! check_command_and_run ethtool ip netns exec $NETNS ethtool -K $CONTAINER_IFNAME tx off >/dev/null ; then