[PATCH] patch to speed up bootpc queries

Phil pbi at cartel-info.fr
Thu Jan 3 16:11:23 CET 2002


Hi,

When rcS_fai tries to get bootp parameters, it does a query on every
interface the machine has. This can take a lot of time for nothing.

the following patch tries the defaut interface first, and break the loop
after the first successfull query. (use the attached file to avoid
copy-paste diff problems)


---------------------8<--------------------------
--- /usr/lib/fai/nfsroot/usr/share/fai/subroutines~     Fri Nov 16 17:56:16 2001
+++ /usr/lib/fai/nfsroot/usr/share/fai/subroutines      Thu Jan  3 16:00:23 2002
@@ -228,11 +228,14 @@

     local device
     local bootlog=/tmp/bootp.log
+    # test the default interface first!
+    testdev="`route -n | awk '/^0.0.0.0/ { print $8}'` $netdevices"
     # define all bootpc information as variables
-    for device in $netdevices; do
+    for device in $testdev; do
        echo "Sending BOOTP request using device $device"
        echo "* --- network device $device ---" >> $bootlog
        bootpc --dev $device --timeoutwait $timeout --returniffail >> $bootlog 2>&1
+       if [ $? -eq 0 ]; then break; fi
     done

     [ -n "$verbose" -a -f $bootlog ] && echo "Reading $bootlog"
---------------------8<--------------------------

-- 
Philippe Biondi <pbi@ cartel-info.fr>   Cartel Informatique
Security Consultant/R&D                 http://www.cartel-info.fr
Phone: +33 1 44 06 97 94                Fax: +33 1 44 06 97 99
PGP KeyID:3D9A43E2  FingerPrint:C40A772533730E39330DC0985EE8FF5F3D9A43E2


-------------- next part --------------
--- /usr/lib/fai/nfsroot/usr/share/fai/subroutines~	Fri Nov 16 17:56:16 2001
+++ /usr/lib/fai/nfsroot/usr/share/fai/subroutines	Thu Jan  3 16:00:23 2002
@@ -228,11 +228,14 @@
 
     local device
     local bootlog=/tmp/bootp.log
+    # test the default interface first!
+    testdev="`route -n | awk '/^0.0.0.0/ { print $8}'` $netdevices"
     # define all bootpc information as variables
-    for device in $netdevices; do
+    for device in $testdev; do
 	echo "Sending BOOTP request using device $device"
 	echo "* --- network device $device ---" >> $bootlog
 	bootpc --dev $device --timeoutwait $timeout --returniffail >> $bootlog 2>&1
+	if [ $? -eq 0 ]; then break; fi
     done
 
     [ -n "$verbose" -a -f $bootlog ] && echo "Reading $bootlog"


More information about the linux-fai mailing list