Random Musings

2006-4-6

Spanning tree and NFS

Filed under: — PugMajere @ 3:45 pm

For the record, the fact that Debian’s startup tends to fail in the presence of smart switches that try to do spanning-tree detection gets really annoying when you have production machines that depend on NFS servers being available.

Technically, this would be solvable by building a proper hosts file on each server, but that’s what DNS is for.

So, I’m going to try a script like this on each server during the startup sequence, to try to delay the startup until the default gateway comes up:

#!/bin/bash -e

found_addr=0
loop_count=0

gw=$(/bin/netstat -rn | awk ‘/^0.0.0.0/{print $2}’)
echo “Gateway is $gw”
echo “Waiting for $gw to appear in the arp table.”

while [ $found_addr -eq 0 ]; do
echo “Triggering arp lookup with a single ping”
/bin/ping -c 1 -q $gw >/dev/null || true
info=$(/usr/sbin/arp -n $gw | grep “^$gw”)
addr=$(echo “$info” | awk ‘{print $1}’)
hwtype=$(echo “$info” | awk ‘{print $2}’)
echo “hwtype = $hwtype, addr = $addr”
if [ “$hwtype” = “ether” ]; then
found_addr=1
fi

loop_count=$(expr $loop_count + 1)
if [ $loop_count -gt 120 ];
then
echo “120 passes through the loop and nothing happening.”
echo “Giving up and moving on.”
exit 0
fi

if [ $found_addr -eq 0 ]; then
sleep 1
fi
done

3 Comments »

  1. We’ve found that this can be somewhat mitigated (at least on Cisco gear) by setting the variable “spanning-tree-port-fast” (or something like that, I’m not a netadmin) on the switch.

    Beware though; if you set that on a trunked switch port you’ll wind up with a really bad network (arp? don’t remember) storm that’ll nuke the whole network. Just use it on end-server ports.

    Comment by WildBill — 2006-4-7 @ 11:36 pm

  2. Bill is right, When you are working with switches and are using spanning tree its a good idea to enable port fast on ports that are going to have workstations or servers on them. That way you dont have to sit and wait the whole STP process before the port comes up.

    Comment by madmanx — 2006-4-8 @ 10:55 am

  3. Thanks for the information, it was very helpful.

    Comment by Ping — 2006-4-16 @ 9:31 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>


Powered by WordPress