From 1ba1f637760f2e79e71bfc4ff11c76b54f2c7632 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Thu, 27 Nov 2014 10:07:30 +0000 Subject: [PATCH] refactor --- weave | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/weave b/weave index 406d9381..cb3ff449 100755 --- a/weave +++ b/weave @@ -201,19 +201,18 @@ 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 - if ! ip link set $GUEST_IFNAME netns $NETNS ; then + if ip link set $LOCAL_IFNAME master $BRIDGE && + ip link set $LOCAL_IFNAME up && + ip link set $GUEST_IFNAME netns $NETNS ; then + ip netns exec $NETNS ip link set $GUEST_IFNAME name $CONTAINER_IFNAME + else # failed before we assigned the veth to the container's # namespace - delete it ip link del $LOCAL_IFNAME type veth || true return 1 fi - - 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 } - launch() { connect_container_to_bridge && check_command_and_run_anything ethtool ip netns exec $NETNS ethtool -K eth0 tx off >/dev/null &&