File dhcpcd-3.2.3-lastlease.diff of Package dhcpcd
--- dhcpcd-3.2.3/client.c
+++ dhcpcd-3.2.3/client.c 2008/12/03 14:13:39
@@ -217,10 +217,9 @@ static bool get_old_lease (state_t *stat
#ifdef ENABLE_ARP
/* Check that no-one is using the address */
- if ((options->dolastlease ||
- (IN_LINKLOCAL (ntohl (dhcp->address.s_addr)) &&
+ if ( IN_LINKLOCAL (ntohl (dhcp->address.s_addr)) &&
(! options->doipv4ll ||
- arp_claim (iface, dhcp->address)))))
+ arp_claim (iface, dhcp->address)))
{
memset (&dhcp->address, 0, sizeof (dhcp->address));
memset (&dhcp->netmask, 0, sizeof (dhcp->netmask));
@@ -321,8 +320,10 @@ static bool client_setup (state_t *state
if (! get_old_lease (state, options))
#endif
{
- free (dhcp);
- return (false);
+ free_dhcp (dhcp);
+ memset (dhcp, 0, sizeof (*dhcp));
+ // do not fail when there is no old lease!
+ //return (false);
}
state->timeout = 0;
@@ -475,9 +476,7 @@ static int wait_for_packet (struct pollf
int timeout = 0;
int retval = 0;
- if (! (state->timeout > 0 ||
- (options->timeout == 0 &&
- (state->state != STATE_INIT || state->xid)))) {
+ if (! (state->timeout > 0 )) {
/* We need to zero our signal fd, otherwise we will block
* trying to read a signal. */
fds[POLLFD_SIGNAL].revents = 0;
@@ -486,9 +485,8 @@ static int wait_for_packet (struct pollf
fds[POLLFD_IFACE].fd = iface->fd;
- if ((options->timeout == 0 && state->xid) ||
- (dhcp->leasetime == (unsigned) -1 &&
- state->state == STATE_BOUND))
+ if ( dhcp->leasetime == (unsigned) -1 &&
+ state->state == STATE_BOUND)
{
logger (LOG_DEBUG, "waiting for infinity");
while (retval == 0) {
@@ -644,8 +642,6 @@ static int handle_timeout (state_t *stat
{
if (errno == EINTR)
return (0);
- if (options->dolastlease)
- return (-1);
free_dhcp (dhcp);
memset (dhcp, 0, sizeof (*dhcp));
} else if (errno == EINTR)
@@ -705,7 +701,7 @@ static int handle_timeout (state_t *stat
}
#endif
- if (! state->daemonised)
+ if (! state->daemonised && options->timeout != 0)
return (-1);
}
@@ -713,7 +709,7 @@ static int handle_timeout (state_t *stat
case STATE_INIT:
state->xid = (uint32_t) random ();
do_socket (state, SOCKET_OPEN);
- state->timeout = options->timeout;
+ state->timeout = options->timeout ? options->timeout : DEFAULT_TIMEOUT ;
iface->start_uptime = uptime ();
if (dhcp->address.s_addr == 0) {
if (! IN_LINKLOCAL (ntohl (iface->previous_address.s_addr)))