On 15/10/10 14:43, Harald Hoyer wrote: > > please use [ -n "$var" ] >
Done, and added a couple of comments. cheers, Pádraig. >From 3030d23e31f3975c0c44207b0faae0792d5cc9b0 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com> Date: Fri, 15 Oct 2010 12:58:31 +0100 Subject: [PATCH] network: don't die if gateway is down and root server is local * modules.d/40network/netroot: Don't arping the gateway if we don't need to --- modules.d/40network/netroot | 28 ++++++++++++++++++++++------ 1 files changed, 22 insertions(+), 6 deletions(-) diff --git a/modules.d/40network/netroot b/modules.d/40network/netroot index 81a9ad3..948f68b 100755 --- a/modules.d/40network/netroot +++ b/modules.d/40network/netroot @@ -83,21 +83,37 @@ done [ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts -# Handle STP Timeout: arping default router or if not available the -# root server. Note: This assumes that if no router is present the +# Handle STP Timeout: arping the default router if root server is +# unknown or not local, or if not available the root server. +# Note: This assumes that if no router is present the # root server is on the same subnet. # # TODO There's some netroot variants that don't (yet) have their # server-ip netroot -[ -n "$new_routers" ] && dest=${new_routers%%,*} -[ -n "$gw" ] && dest=$gw -if [ -z "$dest" ] ; then + +# Get router IP if set +[ -n "$new_routers" ] && gw_ip=${new_routers%%,*} +[ -n "$gw" ] && gw_ip=$gw +# Get root server IP if set +if [ -n "$netroot" ]; then dummy=${netroot#*:} dummy=${dummy%%:*} case "$dummy" in - [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) dest=$dummy;; + [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) netroot_ip=$dummy;; esac fi +# Default arping dest to router +dest="$gw_ip" +# Change to arping root server if appropriate +if [ -n "$netroot_ip" ]; then + if [ -z "$dest" ]; then + # no gateway so check root server + dest="$netroot_ip" + elif ! ip route get "$netroot_ip" | grep -qF ' via ' ; then + # local root server, so don't arping gateway + dest="$netroot_ip" + fi +fi if [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then die "Resolving $dest via ARP on $netif failed" fi -- 1.6.2.5 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html