tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[PATCH] dhcpcd hooks in rc.d/network



Hi List!

snj has kindly pulled dhcpcd-5 into netbsd-5.
This has brought some issues to my attention, regarding interaction with the rc.d scripts.

1) dhcpcd -n $int fails
   This is now fixed in dhcpcd-5.0.2 and I've imported dhcpcd-5.0.3
   I'll request a pull for this over the next few days unless anyone
   finds anything critical.

2) rc.d/network stop should not remove an interface from rc.d/dhcpcd
   Attached patch checks how user is running dhcp and decided whether to
   actually start dhcpcd against the interface or not.
   Also, it only stops dhcpcd for the interface if a dhcpcd pidfile
   exists for the interface.

This allows the following in /etc/rc.conf

ifconfig_iwi0=dhcp
dhcpcd=YES

Comments?

Thanks

Roy
Index: network
===================================================================
RCS file: /cvsroot/src/etc/rc.d/network,v
retrieving revision 1.57
diff -u -p -r1.57 network
--- network     11 Oct 2008 17:28:03 -0000      1.57
+++ network     12 May 2009 08:27:17 -0000
@@ -36,7 +36,9 @@ network_start()
                # DHCP later, as we will probably get the
                # hostname at that time.
                #
-               if ! checkyesno dhclient && [ -z "$(hostname)" ]; then
+               if ! checkyesno dhclient && ! checkyesno dhcpcd && \
+                       [ -z "$(hostname)" ]
+               then
                        warn "\$hostname not set."
                fi
        fi
@@ -266,7 +268,10 @@ network_start()
                                        ( eval "${args#*!}" )
                                        ;;
                                dhcp)
-                                       /sbin/dhcpcd -n ${dhcpcd_flags} $int
+                                       if ! checkyesno dhcpcd; then
+                                               /sbin/dhcpcd -n \
+                                                       ${dhcpcd_flags} $int
+                                       fi
                                        ;;
                                *)
                                        # Pass args to ifconfig.  Note
@@ -442,7 +447,9 @@ network_stop()
                        eval args=\$ifconfig_$int
                        if [ -n "$args" ] || [ -f /etc/ifconfig.$int ]; then
                                echo -n " $int"
-                               /sbin/dhcpcd -k $int 2> /dev/null
+                               if [ -f /var/run/dhcpcd-$int.pid ]; then
+                                       /sbin/dhcpcd -k $int 2> /dev/null
+                               fi
                                /sbin/ifconfig $int down
                                if /sbin/ifconfig $int destroy 2>/dev/null && \
                                   checkyesno ipfilter; then
@@ -462,5 +469,6 @@ network_stop()
 
 load_rc_config $name
 load_rc_config_var dhclient dhclient
+load_rc_config_var dhcpcd dhcpcd
 load_rc_config_var ipfilter ipfilter
 run_rc_command "$1"


Home | Main Index | Thread Index | Old Index