This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
Re: DHCP failure
Jonathan Larmour wrote:
Gary Thomas wrote:
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.
While I agree it does seem flawed with multiple interfaces, I agree it
is less bad than before. Perhaps an explanatory comment alongside it
might be useful, just to say what's wrong and that this needs to be
fixed up properly.
Thanks - attached patch (including comments) applied.
--
------------------------------------------------------------
Gary Thomas | Consulting for the
MLB Associates | Embedded world
------------------------------------------------------------
Index: net/common/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos-opt/net/net/common/current/ChangeLog,v
retrieving revision 1.80
diff -u -5 -p -r1.80 ChangeLog
--- net/common/current/ChangeLog 9 Jan 2007 16:04:39 -0000 1.80
+++ net/common/current/ChangeLog 15 Jan 2007 18:35:55 -0000
@@ -1,5 +1,11 @@
+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
not being thread-safe.
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 18:36:26 -0000
@@ -194,23 +194,43 @@ 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 );
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