From: Philippe Seewer Date: Thu, 17 Sep 2009 15:16:45 +0000 (+0200) Subject: Add simple STP timeout handler X-Git-Tag: 003~121 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=98f25e9694b5b527e342fa1a7b1f67df3aaa569b;p=thirdparty%2Fdracut.git Add simple STP timeout handler This patch adds STP timeout error handling with arping. It's rather simple since it only cares about the primary interface and blindly assumes that if no gateway is available the root server is on the same subnet. --- diff --git a/modules.d/40network/check b/modules.d/40network/check index f2b137c1b..e5cd87e7b 100755 --- a/modules.d/40network/check +++ b/modules.d/40network/check @@ -2,7 +2,7 @@ . $dracutfunctions -for program in ip hostname; do +for program in ip arping; do which $program >/dev/null 2>&1 if [ $? -ne 0 ]; then dwarning "Could not find program \"$program\" required by network." diff --git a/modules.d/40network/install b/modules.d/40network/install index c16848d09..ee7c87118 100755 --- a/modules.d/40network/install +++ b/modules.d/40network/install @@ -1,5 +1,5 @@ #!/bin/bash -dracut_install ip dhclient brctl +dracut_install ip dhclient brctl arping inst "$moddir/ifup" "/sbin/ifup" inst "$moddir/netroot" "/sbin/netroot" inst "$moddir/dhclient-script" "/sbin/dhclient-script" diff --git a/modules.d/40network/netroot b/modules.d/40network/netroot index b905c1e6d..6f1ff77c2 100755 --- a/modules.d/40network/netroot +++ b/modules.d/40network/netroot @@ -77,6 +77,29 @@ done [ -e /tmp/net.$netif.hostname ] && . /tmp/net.$netif.hostname [ -e /tmp/resolv.conf ] && cp -f /tmp/resolv.conf /etc/resolv.conf +# Load interface options +[ -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 +# 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 + dummy=${netroot#*:} + dummy=${dummy%%:*} + case "$dummy" in + [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) dest=$dummy;; + esac +fi +if [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then + die "Resolving $dest via ARP on $netif failed" +fi + # Source netroot hooks before we start the handler source_all netroot