Skip to content

Commit

Permalink
gdhcp: Use REQUEST_TIMEOUT for renew request
Browse files Browse the repository at this point in the history
Rearming the timer with start_renew_timeout is basically useless.

1) DHCP is answering the renew request: listener_event will
  stop the timer and change the state machine either from RENEWING to
  BOUND or INIT_SELECTING.
2) DHCP is not answering (uplink dead etc): the timer will expire
  and start_rewew_timeout will just rearm the timer.

What happens in 1) is normal operation mode and this patch does not
change normal operation. Instead 2) is now handled differently. We will
report via 'no lease' event that we were not able to renew the lease.
The DHCP client user needs to decide what to do.

In the log below you see the DHCP user decided to start IPv4LL when
the DHCP server was not reachable.

connmand[6580]: DHCP: switch listening mode (0 ==> 1)
connmand[6580]: DHCP: sending DHCP discover request
connmand[6580]: DHCP: sending DHCP discover request
connmand[6580]: DHCP: received DHCP packet xid 0x0000 (current state 0)
connmand[6580]: DHCP: start request (retries 0)
connmand[6580]: DHCP: sending DHCP select request
connmand[6580]: DHCP: received DHCP packet xid 0x0000 (current state 1)
connmand[6580]: DHCP: switch listening mode (1 ==> 0)
connmand[6580]: src/dhcp.c:lease_available_cb() Lease available
connmand[6580]: src/dhcp.c:lease_available_cb() last address 192.168.101.28
connmand[6580]: src/dhcp.c:lease_available_cb() c_address (null)
connmand[6580]: Setting domainname to bmw-carit.intra
connmand[6580]: DHCP: start bound
connmand[6580]: DHCP: processed DHCP packet (new state 2)
connmand[6580]: em1 {add} address 192.168.101.28/16 label em1 family 2
connmand[6580]: ntp: time slew -0.000669 s
connmand[6580]: em1 {add} route 192.168.0.0 gw 0.0.0.0 scope 253 <LINK>
connmand[6580]: em1 {add} route 192.168.0.254 gw 0.0.0.0 scope 253 <LINK>
connmand[6580]: em1 {add} route 0.0.0.0 gw 192.168.0.254 scope 0 <UNIVERSE>
connmand[6580]: em1 {add} route 81.169.141.235 gw 192.168.0.254 scope 0 <UNIVERSE>
connmand[6580]: Client-IP: 88.217.137.244
connmand[6580]: Client-Country: DE
connmand[6580]: Client-Region: 02
connmand[6580]: Client-Timezone: Europe/Berlin
connmand[6580]: em1 {del} route 81.169.141.235 gw 192.168.0.254 scope 0 <UNIVERSE>
connmand[6580]: DHCP: start renew timeout
connmand[6580]: DHCP: switch listening mode (0 ==> 2)
connmand[6580]: DHCP: sending DHCP renew request
connmand[6580]: DHCP: renew request timeout
connmand[6580]: src/dhcp.c:no_lease_cb() No lease available
connmand[6580]: src/dhcp.c:dhcp_invalidate() dhcp 0x7091a0 callback 0
connmand[6580]: src/dhcp.c:dhcp_invalidate() last address 192.168.101.28
connmand[6580]: em1 {del} address 192.168.101.28/16 label em1
connmand[6580]: em1 {del} route 192.168.0.0 gw 0.0.0.0 scope 253 <LINK>
connmand[6580]: IPV4LL: sending IPV4LL probe request
connmand[6580]: IPV4LL: switch listening mode (0 ==> 3)
connmand[6580]: IPV4LL: IPV4LL probe timeout (retries 1)
connmand[6580]: IPV4LL: sending IPV4LL probe request
connmand[6580]: IPV4LL: IPV4LL probe timeout (retries 2)
connmand[6580]: IPV4LL: sending IPV4LL probe request
connmand[6580]: IPV4LL: IPV4LL probe timeout (retries 3)
connmand[6580]: IPV4LL: sending IPV4LL announce request
connmand[6580]: IPV4LL: request timeout (retries 1)
connmand[6580]: IPV4LL: sending IPV4LL announce request
connmand[6580]: IPV4LL: request timeout (retries 2)
connmand[6580]: IPV4LL: switching to monitor mode
  • Loading branch information
Daniel Wagner authored and pfl committed Aug 6, 2013
1 parent 8bf42fc commit a063238
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions gdhcp/client.c
Expand Up @@ -1608,6 +1608,19 @@ static void start_rebound(GDHCPClient *dhcp_client)
NULL);
}

static gboolean start_renew_request_timeout(gpointer user_data)
{
GDHCPClient *dhcp_client = user_data;

debug(dhcp_client, "renew request timeout");

if (dhcp_client->no_lease_cb != NULL)
dhcp_client->no_lease_cb(dhcp_client,
dhcp_client->no_lease_data);

return false;
}

static gboolean start_renew_timeout(gpointer user_data)
{
GDHCPClient *dhcp_client = user_data;
Expand All @@ -1629,10 +1642,10 @@ static gboolean start_renew_timeout(gpointer user_data)

dhcp_client->timeout =
g_timeout_add_seconds_full(G_PRIORITY_HIGH,
dhcp_client->lease_seconds >> 1,
start_renew_timeout,
dhcp_client,
NULL);
REQUEST_TIMEOUT,
start_renew_request_timeout,
dhcp_client,
NULL);
}

return FALSE;
Expand Down

0 comments on commit a063238

Please sign in to comment.