Re: Failing dhcp



Implemented those patches, but ... i still get the same errors :(

I attached the patch i made with the patches i found containing "dbus", hope it helps.

On 10/21/05, Dan Williams < dcbw redhat com> wrote:
On Fri, 2005-10-21 at 00:01 +0200, Theetjuh wrote:
> Hi,
>
>
> I finally got NetworkManager 0.5.0 builded, but dhcp doesn't work for
> me.
> I search through the ML and found that out that dhcp needs to be
> patched for dhcdbd and dbus
> I also had contact with Nico, who said he uses the
> dhclient-3.0.2-22.FC4.i386.rpm , i downloaded the latest source rpm of
> 3.0.3 which is used default by slackware, but found 50+ patches !!!
>
> Surely i don't need every single one, so the question ... which
> patches do i need for dhcp to start working ?

Correct, you'll need two bits.  First, you'll see some stuff at the top
of the 'dhclient-script' file that uses dbus-send to send the DHCP
values to dhcdbd.  You'll need to copy that to your own DHCP script in
slackware that your dhclient calls.

Second, you'll need at least the patches from the Red Hat dhclient RPM
that contain the word "dbus".

Dan





--


Greetz
Theetjuh
--- client/scripts/linux.orig	2002-11-15 02:09:09.000000000 +0100
+++ client/scripts/linux	2005-10-21 20:38:21.000000000 +0200
@@ -22,6 +22,19 @@
 # 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious
 # of the $1 in its args.
 
+if [ -n "${dhc_dbus}" ]; then
+   /usr/bin/dbus-send \
+       --system \
+       --dest=com.redhat.dhcp \
+       --type=method_call \
+       /com/redhat/dhcp/$interface \
+       com.redhat.dhcp.set \
+       'string:'"`env | /bin/egrep -v '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`";
+       if (( ( dhc_dbus & 31 ) == 31 )); then
+	   exit 0;
+       fi;
+fi;
+
 make_resolv_conf() {
   if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
     echo search $new_domain_name >/etc/resolv.conf
@@ -58,6 +71,205 @@ release=`expr $release : '\(.*\)\..*'`
 relminor=`echo $release |sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'`
 relmajor=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
 
+function dhconfig()
+{
+    if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
+	if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
+		[ x$alias_ip_address != x$old_ip_address ]; then
+         # Possible new alias. Remove old alias.
+	    ifconfig $interface:0- inet 0
+	fi
+
+	if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
+        # IP address changed. Bringing down the interface will delete all routes,
+        # and clear the ARP cache.
+	    ifconfig $interface inet 0 down
+	fi
+    fi
+    if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
+	    [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
+
+	if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
+	    ifconfig $interface inet $new_ip_address $new_subnet_arg \
+		$new_broadcast_arg
+	    if [ -n "$new_interface_mtu" ]; then
+		/sbin/ip link set $interface mtu $new_interface_mtu;
+	    fi;
+	    if [ -x /etc/dhclient-${interface}-up-hooks ]; then
+		. /etc/dhclient-${interface}-up-hooks;
+	    elif [ -x /etc/dhclient-up-hooks ]; then
+		. /etc/dhclient-up-hooks;
+	    fi;
+	fi;
+	
+	if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 4 ) != 4 )); then
+	    prefix_bits=`mask_bits $new_subnet_mask`
+            # Add a network route to the computed network address.
+	    if [ $relmajor -lt 2 ] || \
+		( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
+		/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" )  || ( "$GATEWAYDEV" = "$interface" ) ) && ( ( -z "$GATEWAY" )  || ( ( -n "$DHCLIENT_IGNORE_GATEWAY" ) && ( "$DHCLIENT_IGNORE_GATEWAY" = [Yy]* ) ) ) ]]; then
+		metric='';
+		let i=0;
+		default_routers=()
+		for router in $new_routers; do
+		    if [ -z "$router" ] || [ `IFS=. ip2num $router` -le 0 ] || [[ $router = *255* ]] || [[ "${default_routers[ ]}" == *"$router"* ]]; then
+			continue;
+		    fi;
+		    default_routers=(${default_routers[ ]} $router)
+		    add_default_gateway $router $metric;		    
+		    let i=i+1;
+		    metric=$i; 
+		done
+	    elif [[ ( ( -z "$GATEWAYDEV" ) || ( "$GATEWAYDEV" = "$interface" ) ) && ( -n "$GATEWAY" ) ]]; then
+		routerSubnet=`mask $GATEWAY $new_subnet_mask`
+		mySubnet=`mask $new_ip_address $new_subnet_mask`
+		if [ "$routerSubnet" = "$mySubnet" ]; then
+		    /sbin/ip route replace default via $GATEWAY dev $interface 
+		fi;
+	    fi;
+            # static routes
+	    if [ "x$new_static_routes" != x ]; then
+		IFS=', 	' static_routes=($new_static_routes)
+		route_targets=()
+		for((i=0; i<${#static_routes[ ]}; i+=2)); do
+		    target=${static_routes[$i]}
+		    gateway=${static_routes[$i+1]}
+		    metric=''
+		    for t in ${route_targets[ ]}; do
+			if [ $t == $target ]; then
+			    if [ -z "$metric" ]; then
+				metric=1;
+			    else
+				((metric=metric+1));
+			    fi;
+			fi;
+		    done;
+		    if [ -n "$metric" ]; then
+			metric="metric $metric";
+		    fi;		    
+		    if routerReachable $gateway; then
+			/sbin/ip route replace ${target}/`class_bits $target` via ${gateway} dev $interface ${metric}
+			if [ $? -ne 0 ]; then
+			   /usr/bin/logger -p local7.notice -t 'NET' 'dhclient: failed to create static route:' ${target}/`class_bits $target` via ${gateway} dev $interface ${metric};			
+			else			    
+ 			   route_targets=(${route_targets[ ]} $target);
+			fi;
+		    fi;
+		done
+	    fi
+	fi
+    fi
+    if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
+	if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
+	    then
+	    ifconfig $interface:0- inet 0
+	    ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
+	    /sbin/ip route replace ${alias_ip_address}/32 dev $interface:0
+	fi
+    fi
+    if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 1 ) != 1 )); then
+	make_resolv_conf
+
+	if [ -n "$new_host_name" ] && need_hostname; then
+	    hostname $new_host_name
+	fi
+    fi;
+    if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 8 ) != 8 )); then
+	if [ "${PEERNIS}" = no ]; then
+	    :
+	elif [ -n "$new_nis_domain" ]; then
+	    domainname "$new_nis_domain"
+	    save_previous /etc/yp.conf
+	    let contents=0
+	    echo '# generated by /sbin/dhclient-script' > /etc/yp.conf
+	    if [ -n "$new_nis_servers" ]; then
+		for I in $new_nis_servers; do
+		    echo "domain $new_nis_domain server $I" >> /etc/yp.conf
+		    let contents=contents+1
+		done
+	    else
+		echo "domain $new_nis_domain broadcast" >> /etc/yp.conf
+		let contents=contents+1
+	    fi
+	    level=`/sbin/runlevel`
+	    level=${level##*\ }
+	    if [ "$level" = "unknown" ]; then
+		level=1;
+	    fi
+	    if [ $contents -gt 0 ] && [[ "$level" = [0-6] ]] && /sbin/chkconfig --level=$level ypbind && [ -r /var/run/ypbind.pid ] && yppid=`cat /var/run/ypbind.pid` && [ -d /proc/${yppid} ] && [ "`if [ -x /sbin/busybox ]; then /sbin/busybox readlink /proc/${yppid}/exe; else echo /sbin/ypbind; fi`" = "/sbin/ypbind" ]; then
+	       kill -HUP $yppid;
+	    fi
+	elif [ -n "$new_nis_servers" ]; then
+	    save_previous /etc/yp.conf
+	    echo '# generated by /sbin/dhclient-script' > /etc/yp.conf
+	    let contents=0
+	    for I in $new_nis_servers; do
+		echo "ypserver $I" >> /etc/yp.conf
+		let contents=contents+1
+	    done
+	    level=`/sbin/runlevel`
+	    level=${level##*\ }
+	    if [ "$level" = "unknown" ]; then
+		level=1;
+	    fi
+	    if [ $contents -gt 0 ] && [[ "$level" = [0-6] ]] && /sbin/chkconfig --level=$level ypbind && [ -r /var/run/ypbind.pid ] && yppid=`cat /var/run/ypbind.pid` && [ -d /proc/${yppid} ] && [ "`if [ -x /sbin/busybox ]; then /sbin/busybox readlink /proc/${yppid}/exe; else echo /sbin/ypbind; fi`" = "/sbin/ypbind" ] ; then
+	       kill -HUP $yppid;
+	    fi
+	fi
+    fi
+    if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 16 ) != 16 )); then
+	if [ -n "$DHCP_TIME_OFFSET_SETS_TIMEZONE" ] && [[ "$DHCP_TIME_OFFSET_SETS_TIMEZONE" = [yY1]* ]]; then
+	    if [ -n "$new_time_offset" ]; then
+	    #   DHCP option "time-offset" is requested by default and should be handled.
+	    #   The geographical zone abbreviation cannot be determined from the GMT offset,
+	    #   but the $ZONEINFO/Etc/GMT$offset file can be used - note: this disables DST.
+		((z=new_time_offset/3600));
+		((hoursWest=`printf '%+d' $z`))
+		if (( $hoursWest < 0 )); then
+		   # tzdata treats negative 'hours west' as positive 'gmtoff' !
+		   ((hoursWest*=-1));
+		fi
+		tzfile=/usr/share/zoneinfo/Etc/GMT`printf '%+d' $hoursWest`;
+		if [ -e $tzfile ]; then
+		    /bin/mv -f /etc/localtime /etc/localtime.predhclient;
+		    /bin/cp -fp $tzfile /etc/localtime;
+		    /bin/touch /etc/localtime;
+		fi;
+	    fi;
+	fi;
+	if [ "${PEERNTP}" = no ]; then
+	    :
+	elif [ -n "$new_ntp_servers" ] && [ -e /etc/ntp.conf ]; then
+	    save_previous /etc/ntp.conf
+	    /bin/egrep -v '(^[\ \	]*server)|(generated by /sbin/dhclient-script)'< /etc/ntp.conf.predhclient > /etc/ntp.conf
+	    echo '# servers generated by /sbin/dhclient-script' >> /etc/ntp.conf
+	    localClocks=(`/bin/egrep '^[\ \	]*server[\ \	]+127\.127' /etc/ntp.conf.predhclient | while read s addr rest; do echo $addr; done`)      
+	    for s in $new_ntp_servers ${localClocks[ ]};
+	      do
+	      echo 'server '$s >> /etc/ntp.conf;
+	    done
+	    if [ -e /etc/ntp/step-tickers ]; then
+		save_previous /etc/ntp/step-tickers
+		echo '' > /etc/ntp/step-tickers
+		for s in $new_ntp_servers ${localClocks[ ]}; 
+		  do
+		  echo $s >> /etc/ntp/step-tickers
+		done;
+	    fi;
+	    if [ -x /usr/bin/diff ] && /usr/bin/diff -q /etc/ntp.conf /etc/ntp.conf.predhclient >/dev/null 2>&1; then
+		: ;
+	    else
+		/sbin/service ntpd condrestart >/dev/null 2>&1
+	    fi;
+	fi
+    fi;
+}
+
 if [ x$new_broadcast_address != x ]; then
   new_broadcast_arg="broadcast $new_broadcast_address"
 fi
@@ -80,74 +292,45 @@ if [ x$reason = xMEDIUM ]; then
 fi
 
 if [ x$reason = xPREINIT ]; then
-  if [ x$alias_ip_address != x ]; then
+  if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
+    if [ x$alias_ip_address != x ]; then
     # Bring down alias interface. Its routes will disappear too.
     ifconfig $interface:0- inet 0
-  fi
-  if [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] )
-   then
-    ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
+    fi
+    if [ x$keep_old_ip == xyes ]; then
+      ifconfig $interface up
+    elif [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] )   then
+      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
-  else
-    ifconfig $interface 0 up
-  fi
-
+      # Add route to make broadcast work. Do not omit netmask.
+      /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
-
-  exit_with_hooks 0
+  #	sleep 1
+  # I don't think this is necessary with modern kernels - no problems found during testing -
+  # JVD, 2005-06-17
+  # but just in case:
+    if [ -n "$DHCLIENT_DELAY" ] && [ "$DHCLIENT_DELAY" -gt 0 ] ; then
+      sleep $DHCLIENT_DELAY;
+    fi;
+    exit_with_hooks 0
+  fi;
 fi
 
 if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
-  exit_with_hooks 0
+    if [ -z "$new_ip_address" ] || [ -z "$interface" ] ||  /sbin/arping -q -f -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 ] || \
-   [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
-  current_hostname=`hostname`
-  if [ x$current_hostname = x ] || \
-     [ x$current_hostname = x$old_host_name ]; then
-    if [ x$current_hostname = x ] || \
-       [ x$new_host_name != x$old_host_name ]; then
-      hostname $new_host_name
-    fi
-  fi
-    
-  if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
-		[ x$alias_ip_address != x$old_ip_address ]; then
-    # Possible new alias. Remove old alias.
-    ifconfig $interface:0- inet 0
-  fi
-  if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
-    # IP address changed. Bringing down the interface will delete all routes,
-    # and clear the ARP cache.
-    ifconfig $interface inet 0 down
-
-  fi
-  if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
-     [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
-
-    ifconfig $interface inet $new_ip_address $new_subnet_arg \
-							$new_broadcast_arg
-    # 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
-    fi
-    for router in $new_routers; do
-      route add default gw $router
-    done
-  fi
-  if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
-   then
-    ifconfig $interface:0- inet 0
-    ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
-    route add -host $alias_ip_address $interface:0
-  fi
-  make_resolv_conf
-  exit_with_hooks 0
+   [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then    
+    dhconfig ;
+    exit_with_hooks 0
 fi
 
 if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
@@ -162,37 +345,28 @@ if [ x$reason = xEXPIRE ] || [ x$reason 
   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
-  fi
+    /sbin/ip route replace ${alias_ip_address}/32 $interface:0  fi
   exit_with_hooks 0
 fi
 
-if [ x$reason = xTIMEOUT ]; then
-  if [ x$alias_ip_address != x ]; then
-    ifconfig $interface:0- inet 0
-  fi
-  ifconfig $interface inet $new_ip_address $new_subnet_arg \
+if [ x$reason = xTIMEOUT ] && [ "x$new_routers" != 'x' ]; then
+    if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
+	if [ x$alias_ip_address != x ]; then
+	    ifconfig $interface:0- inet 0
+	fi
+	ifconfig $interface inet $new_ip_address $new_subnet_arg \
 					$new_broadcast_arg
-  set $new_routers
-  ############## what is -w in ping?
-  if ping -q -c 1 $1; then
-    if [ x$new_ip_address != x$alias_ip_address ] && \
-			[ x$alias_ip_address != x ]; then
-      ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
-      route add -host $alias_ip_address dev $interface:0
+    fi;
+    set $new_routers
+    if ping -q -c 1 -w 10 -I $interface $1; then
+	dhconfig ;
+	exit_with_hooks 0
     fi
-    if [ $relmajor -lt 2 ] || \
-		( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
-      route add -net $new_network_number
-    fi
-    for router in $new_routers; do
-      route add default gw $router
-    done
-    make_resolv_conf
-    exit_with_hooks 0
-  fi
-  ifconfig $interface inet 0 down
+    if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
+	ifconfig $interface inet 0 down
+    fi;
+    exit_with_hooks 1
+elif [ x$reason = xTIMEOUT ]; then
   exit_with_hooks 1
 fi
-
 exit_with_hooks 0


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