From e844753a21de99942fdc05d11ea2ebc3c909000c Mon Sep 17 00:00:00 2001 From: David Wragg Date: Mon, 16 Mar 2015 14:41:50 +0000 Subject: [PATCH] Don't duplicate ARP cache configuration --- weave | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/weave b/weave index 14d197b4..976cc4b9 100755 --- a/weave +++ b/weave @@ -151,9 +151,7 @@ create_bridge() { # Configure the ARP cache parameters on the bridge interface for # the sake of 'weave expose' - echo 5 >/proc/sys/net/ipv4/neigh/$BRIDGE/base_reachable_time - echo 2 >/proc/sys/net/ipv4/neigh/$BRIDGE/delay_first_probe_time - echo 1 >/proc/sys/net/ipv4/neigh/$BRIDGE/ucast_solicit + configure_arp_cache $BRIDGE } destroy_bridge() { @@ -241,11 +239,8 @@ connect_container_to_bridge() { return 1 fi - if ! ip netns exec $NETNS sh -c "\ - ip link set $GUEST_IFNAME name $CONTAINER_IFNAME && - echo 5 >/proc/sys/net/ipv4/neigh/$CONTAINER_IFNAME/base_reachable_time && - echo 2 >/proc/sys/net/ipv4/neigh/$CONTAINER_IFNAME/delay_first_probe_time && - echo 1 >/proc/sys/net/ipv4/neigh/$CONTAINER_IFNAME/ucast_solicit" ; then + if ! ip netns exec $NETNS ip link set $GUEST_IFNAME name $CONTAINER_IFNAME || + ! configure_arp_cache $CONTAINER_IFNAME "ip netns exec $NETNS" ; then # failed after we assigned the veth to the container's # namespace, and we don't know if it was renamed or not. ip netns exec $NETNS ip link del $GUEST_IFNAME type veth 2>/dev/null || true @@ -294,6 +289,13 @@ attach() { arp_update $CONTAINER_IFNAME $1 "ip netns exec $NETNS" } +# Configure the ARP cache parameters for the given interface +configure_arp_cache() { + $2 sh -c "echo 5 >/proc/sys/net/ipv4/neigh/$1/base_reachable_time && + echo 2 >/proc/sys/net/ipv4/neigh/$1/delay_first_probe_time && + echo 1 >/proc/sys/net/ipv4/neigh/$1/ucast_solicit" +} + # Send out an unsolicated ARP response to flush ARP cache entries arp_update() { # It's not the end of the world if this doesn't run - we configure