[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

rpms/dhcp/FC-3 dhcp-3.0.1-dhclient-script-update.patch,NONE,1.1



Author: jvdias

Update of /cvs/dist/rpms/dhcp/FC-3
In directory cvs.devel.redhat.com:/tmp/cvs-serv19176

Added Files:
	dhcp-3.0.1-dhclient-script-update.patch 
Log Message:
remove 1 second sleep on PREINIT; further replacement of /sbin/route by /sbin/ip; fix determination of runlevel in init state 1; add class A,B,C static route support; add ARPCHECK support

dhcp-3.0.1-dhclient-script-update.patch:
 linux |   77 ++++++++++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 56 insertions(+), 21 deletions(-)

--- NEW FILE dhcp-3.0.1-dhclient-script-update.patch ---
--- dhcp-3.0.1/client/scripts/linux.dhclient-script-update	2005-07-07 17:15:05.565524000 -0400
+++ dhcp-3.0.1/client/scripts/linux	2005-07-07 18:36:48.445308000 -0400
@@ -141,6 +141,30 @@
     num2ip $n;
 }
 
+function mask_bits()
+{
+    ip=$1
+    let ip=`IFS='.' ip2num $ip`;
+    let bits=0
+    for ((bit=1; '((ip&bit)==0) && (bits < 32)'; 'bit<<=1')) do
+        let bits+=1
+    done
+    let n_bits=32-bits
+    echo $n_bits
+}
+
+function class_bits()
+{
+    let bits=0
+    IFS='.' os="$1"
+    for b in $os; do
+       if [ $b -ne 0 ]; then
+	   let bits=bits+8;
+       fi;
+    done
+    echo $bits
+}
+
 function add_default_gateway()
 {
         router=$1
@@ -150,7 +174,7 @@
 	routerUnreachable=0
 	if [ "$routerSubnet" != "$mySubnet" ]; then
            if /sbin/arping -q -I $interface -w2 $router; then
-	       route add -host $router dev $interface;
+	       /sbin/ip route replace ${router}/32 dev $interface;
            else
 	       routerUnreachable=1;
 	       echo "dhclient: DHCP router $router is unreachable on DHCP subnet $mySubnet"
@@ -187,10 +211,11 @@
     # Add a network route to the computed network address.
     if [ $relmajor -lt 2 ] || \
 		( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
-      route add -net $new_network_number $new_subnet_arg dev $interface
-      if [ $added_old_broadcast_route -eq 1 ]; then
-	  route del default;
-      fi;
+	prefix_bits=`mask_bits $new_subnet_mask`
+	/sbin/ip route replace ${new_network_number}/${prefix_bits} dev $interface
+	if [ $added_old_broadcast_route -eq 1 ]; then
+	    /sbin/ip route del default;
+	fi;
     fi;
     if [[ ( -z "$GATEWAYDEV" &&  (-z "$GATEWAY" || -z "$DHCLIENT_USE_GATEWAY") ) || ( (-z "$GATEWAY" || -z "$DHCLIENT_USE_GATEWAY") &&  ( "$GATEWAYDEV" = "$interface") )  ]]; then
 	for router in $new_routers; do
@@ -205,15 +230,14 @@
     fi;
     # static routes
     if [ "x$new_static_routes" != x ]; then
-      len=`echo $new_static_routes | awk '{print NF}'`
-      i=1
-      while [ $i -lt $len ]; do
-        target=`echo $new_static_routes | awk "{print \\$$i}"`
-        let i=i+1
-        gateway=`echo $new_static_routes | awk "{print \\$$i}"`
-        let i=i+1
-        route add -host $target gw $gateway $interface
-      done
+	IFS=', 	' static_routes=($new_static_routes)
+	let i=0
+	while [ $i -lt ${#static_routes[ ]} ]; do
+	    target=${static_routes[$i]}
+	    gateway=${static_routes[$i+1]}
+	    let i=i+2
+	    /sbin/ip route replace ${target}/`class_bits $target` via ${gateway} dev $interface
+	done
     fi
   fi
 
@@ -221,7 +245,7 @@
    then
     ifconfig $interface:0- inet 0
     ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
-    route add -host $alias_ip_address $interface:0
+    /sbin/ip route replace $alias_ip_address/32 dev $interface:0
   fi
 
   make_resolv_conf
@@ -242,9 +266,12 @@
 	    echo "domain $new_nis_domain broadcast" >> /etc/yp.conf
 	    let contents=contents+1
 	fi
+	[ -x /sbin/restorecon ] && /sbin/restorecon /etc/yp.conf >/dev/null 2>&1
         level=`/sbin/runlevel`
 	level=${level##*\ }
-	[ -x /sbin/restorecon ] && /sbin/restorecon /etc/yp.conf >/dev/null 2>&1
+	if [ "$level" = "unknown" ]; then
+	    level=1;
+	fi
 	if ! pkill -HUP ypbind && [ $contents -gt 0 ] && chkconfig --level=$level ypbind; then
 	   service ypbind start >/dev/null 2>&1;
         fi
@@ -256,9 +283,12 @@
 	    echo "ypserver $I" >> /etc/yp.conf
 	    let contents=contents+1
         done
+	[ -x /sbin/restorecon ] && /sbin/restorecon /etc/yp.conf >/dev/null 2>&1
         level=`/sbin/runlevel`
 	level=${level##*\ }
-	[ -x /sbin/restorecon ] && /sbin/restorecon /etc/yp.conf >/dev/null 2>&1
+	if [ "$level" = "unknown" ]; then
+	    level=1;
+	fi
         if ! pkill -HUP ypbind && [ $contents -gt 0 ] && chkconfig --level=$level ypbind; then
 	    service ypbind start >/dev/null 2>&1;
         fi
@@ -329,19 +359,24 @@
     ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
 		broadcast 255.255.255.255 up
     # Add route to make broadcast work. Do not omit netmask.
-    route add default dev $interface netmask 0.0.0.0 && added_old_broadcast_route=1;
+    /sbin/ip route replace default dev $interface && added_old_broadcast_route=1;
   else
     ifconfig $interface 0 up
   fi
 
   # We need to give the kernel some time to get the interface up.
-  sleep 1
+  # sleep 1
+  # I don't think we need to do this with modern kernels - JVD .
 
   exit_with_hooks 0
 fi
 
 if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
-  exit_with_hooks 0
+    if [ -z "$new_ip_address" ] || [ -z "$interface" ] ||  /sbin/arping -q -c 2 -w 3 -D -I ${interface} ${new_ip_address}; then
+	exit_with_hooks 0
+    else
+	exit_with_hooks 1
+    fi;
 fi
   
 if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
@@ -380,7 +415,7 @@
   fi
   if [ x$alias_ip_address != x ]; then
     ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
-    route add -host $alias_ip_address $interface:0
+    /sbin/ip route replace $alias_ip_address dev $interface:0
   fi
   exit_with_hooks 0
 fi


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]