This is the mail archive of the
ecos-maintainers@sources.redhat.com
mailing list for the eCos project.
FWD: dhcp_prot.c: some fixes
- From: Andrew Lunn <andrew dot lunn at ascom dot ch>
- To: eCos Maintainers <ecos-maintainers at sources dot redhat dot com>
- Date: Tue, 29 Jul 2003 18:06:14 +0200
- Subject: FWD: dhcp_prot.c: some fixes
I don't claim to understand the subtleties of DHCP, but this looks OK
to me. Could some else take a look as well, particularly the second
hunk.
Thanks
Andrew
----- Forwarded message from Motoya Kurotsu <kurotsu@allied-telesis.co.jp> -----
Date: Tue, 29 Jul 2003 11:38:18 +0900
From: Motoya Kurotsu <kurotsu@allied-telesis.co.jp>
To: ecos-patches@sources.redhat.com
Subject: dhcp_prot.c: some fixes
Hi all;
The attachment fixes the following problems.
1) When dhcp is reinitialized by calling init_all_network_interfaces()
(from management thread), or retried due to the failute at the
previous trial, the lease is left the previous state. It causes
unexpected problems. For example, if the previous do_dhcp exits
with the lease as DHCP_LEASE_T1, *pstate changes into
DHCPSTATE_RENEWING from DHCPSTATE_INIT immediately before
the switch sentence in the next do_dhcp().
2) If the state falls into DHCPSTATE_NOTBOUND, do_dhcp_down_net() is
not called from dhcp_halt() because ethX_up is false at the time.
Motoya Kurotsu
Allied Telesis K.K.
diff -Nurp common.orig/current/ChangeLog common/current/ChangeLog
--- common.orig/current/ChangeLog Fri Jul 25 03:07:45 2003
+++ common/current/ChangeLog Tue Jul 29 11:04:19 2003
@@ -1,3 +1,9 @@
+2003-07-29 Motoya Kurotsu <kurotsu@allied-telesis.co.jp>
+
+ * src/dhcp_prot.c (do_dhcp): Initialize the lease when
+ dhcp is (re)initialized or retried.
+ Return true when the state falls into DHCPSTATE_NOTBOUND.
+
2003-07-24 Nick Garnett <nickg@balti.calivar.com>
* src/dhcp_prot.c: Added a declaration for cyg_arc4random() to
diff -Nurp common.orig/current/src/dhcp_prot.c common/current/src/dhcp_prot.c
--- common.orig/current/src/dhcp_prot.c Fri Jul 25 03:07:46 2003
+++ common/current/src/dhcp_prot.c Mon Jul 28 18:54:36 2003
@@ -592,6 +592,7 @@ do_dhcp(const char *intf, struct bootp *
return false;
*pstate = DHCPSTATE_INIT;
+ lease->which = lease->next = 0;
}
s = socket(AF_INET, SOCK_DGRAM, 0);
@@ -1189,7 +1190,7 @@ do_dhcp(const char *intf, struct bootp *
// No lease active
no_lease( lease );
// Leave interface up so app can tidy.
- return false;
+ return true;
case DHCPSTATE_FAILED:
// All done with socket
----- End forwarded message -----