From 29b3db6c05f5975df5ded18cb0a934db0291d0d2 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Thu, 27 Nov 2014 10:20:25 +0000 Subject: [PATCH] run ethtool outside container netns We want to run as little as possible inside the container netns. Unfortunately we cannot make that change for the weave container, since the interface on which we need to invoke ethtool is created by docker and already inside the container netns by the time we get control. --- weave | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/weave b/weave index cb3ff449..f3c8dfbc 100755 --- a/weave +++ b/weave @@ -198,9 +198,6 @@ with_container_netns () { } 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 $LOCAL_IFNAME master $BRIDGE && ip link set $LOCAL_IFNAME up && ip link set $GUEST_IFNAME netns $NETNS ; then @@ -214,6 +211,9 @@ connect_container_to_bridge() { } launch() { + if ! ip link add name $LOCAL_IFNAME mtu $MTU type veth peer name $GUEST_IFNAME mtu $MTU ; then + return 1 + fi connect_container_to_bridge && check_command_and_run_anything ethtool ip netns exec $NETNS ethtool -K eth0 tx off >/dev/null && ip netns exec $NETNS ip link set $CONTAINER_IFNAME up @@ -235,8 +235,12 @@ attach() { return 0 fi - if ! connect_container_to_bridge || - ! check_command_and_run_anything ethtool ip netns exec $NETNS ethtool -K $CONTAINER_IFNAME tx off >/dev/null || + if ! ip link add name $LOCAL_IFNAME mtu $MTU type veth peer name $GUEST_IFNAME mtu $MTU ; then + return 1 + fi + + if ! check_command_and_run ethtool -K $GUEST_IFNAME tx off >/dev/null || + ! 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 ; then return 1