This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

DHCP failure


If you're running DHCP and the DHCP server is down when a
lease expires, then the DHCP management thread will get
permanently stuck and the interface with the failed lease
is left down.

The attached patch [not yet applied] fixes this.  Comments?
It works fine in my test environment and solves the problem.
If this seems reasonable, I'll commit it.

Note: this patch is sufficient to keep the existing management
thread working.  That said, this code should really be rewritten
to have separate management threads for each interface that wants
to run DHCP (and also additional CDL so that one interface might
run DHCP while another is manually set, etc).  I've no time for
this level of upgrade - this is just a suggestion for some eager
beaver... :-)

--
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------
Index: net/common/current/src/dhcp_support.c
===================================================================
RCS file: /misc/cvsfiles/ecos-opt/net/net/common/current/src/dhcp_support.c,v
retrieving revision 1.3
diff -u -5 -p -r1.3 dhcp_support.c
--- net/common/current/src/dhcp_support.c	7 Jan 2007 14:46:55 -0000	1.3
+++ net/common/current/src/dhcp_support.c	15 Jan 2007 14:49:09 -0000
@@ -197,20 +197,32 @@ int dhcp_release( void )
 // ------------------------------------------------------------------------
 // The management thread function
 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 );
             if ( ! dhcp_bind() ) // a lease expired
                 break; // If we need to re-bind
         }
         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
         SnmpdShutDown(0); // Cycle the snmpd state
 #endif

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]