changeset 2353:15a557139254

Fix for DHCP when server is down after lease expires (keep trying)
author gthomas
date Mon, 15 Jan 2007 18:37:52 +0000
parents bafbb0c01fb4
children c51f7186ed22
files packages/net/common/current/ChangeLog packages/net/common/current/src/dhcp_support.c
diffstat 2 files changed, 27 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/packages/net/common/current/ChangeLog
+++ b/packages/net/common/current/ChangeLog
@@ -1,3 +1,9 @@
+2007-01-15  Gary Thomas  <gary@mlbassoc.com>
+
+	* src/dhcp_support.c (dhcp_mgt_entry): Better handling when restarting
+	interfaces after expired lease(s).  Keep trying in case the DHCP server
+	has gone down.
+
 2007-01-09  Jonathan Larmour  <jifl@eCosCentric.com>
 
 	* doc/manpages/net/getaddrinfo.3: Remove obsolete comment about
--- a/packages/net/common/current/src/dhcp_support.c
+++ b/packages/net/common/current/src/dhcp_support.c
@@ -196,9 +196,19 @@ int dhcp_release( void )
 
 // ------------------------------------------------------------------------
 // The management thread function
+//
+// Note: 2007-01-15
+//  This single management thread attempts to keep all configured
+//  interfaces alive via DHCP.  While this may be sufficient for 
+//  many systems, it falls short of perfect.  There should probably
+//  be a separate thread for each possible interface, along with
+//  appropriate CDL to control how each inteface is managed.
+//
 void dhcp_mgt_entry( cyg_addrword_t loop_on_failure )
 {
     int j;
+    bool any_interfaces_up;
+
     while ( 1 ) {
         while ( 1 ) {
             cyg_semaphore_wait( &dhcp_needs_attention );
@@ -208,7 +218,17 @@ void dhcp_mgt_entry( cyg_addrword_t loop
         dhcp_halt(); // tear everything down
         if ( !loop_on_failure )
             return; // exit the thread/return
-        init_all_network_interfaces(); // re-initialize
+        do {
+            init_all_network_interfaces(); // re-initialize
+            // If at least one interface is up, then the DHCP machine will run
+            any_interfaces_up = false;
+#ifdef CYGHWR_NET_DRIVER_ETH0
+            any_interfaces_up |= eth0_up;
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+            any_interfaces_up |= eth1_up;
+#endif
+        } while (!any_interfaces_up);
         for ( j = 0; j < CYGPKG_NET_NLOOP; j++ )
             init_loopback_interface( j );
 #ifdef CYGPKG_SNMPAGENT