Commit 9cb5f78d authored by Dan Williams's avatar Dan Williams
Browse files

2004-12-06 Dan Williams <dcbw@redhat.com>

	* dhcpcd/client.c
		- Fix some minor errors in dhcp_handle_transaction() that caused
			unexpected early timeouts of DHCP transactions

	* dhcpcd/client.h
		- DHCP retransmit time from 4s -> 5s


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@338 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 6c73ebcd
2004-12-06 Dan Williams <dcbw@redhat.com>
* dhcpcd/client.c
- Fix some minor errors in dhcp_handle_transaction() that caused
unexpected early timeouts of DHCP transactions
* dhcpcd/client.h
- DHCP retransmit time from 4s -> 5s
2004-12-05 Dan Williams <dcbw@redhat.com> 2004-12-05 Dan Williams <dcbw@redhat.com>
* Major rework of the DHCP code, taking some cues from pump. We don't * Major rework of the DHCP code, taking some cues from pump. We don't
......
...@@ -437,7 +437,7 @@ int dhcp_handle_transaction (dhcp_interface *iface, unsigned int expected_reply_ ...@@ -437,7 +437,7 @@ int dhcp_handle_transaction (dhcp_interface *iface, unsigned int expected_reply_
char *pkt_recv = NULL; char *pkt_recv = NULL;
int recv_sk = -1; int recv_sk = -1;
struct sockaddr_in addr; struct sockaddr_in addr;
int tries = -1; int tries = 0;
int dhcp_send_len, err = RET_DHCP_TIMEOUT; int dhcp_send_len, err = RET_DHCP_TIMEOUT;
dhcpMessage *dhcp_send = NULL; dhcpMessage *dhcp_send = NULL;
struct timeval recv_timeout, overall_end, diff, current; struct timeval recv_timeout, overall_end, diff, current;
...@@ -487,6 +487,9 @@ int dhcp_handle_transaction (dhcp_interface *iface, unsigned int expected_reply_ ...@@ -487,6 +487,9 @@ int dhcp_handle_transaction (dhcp_interface *iface, unsigned int expected_reply_
char ethPacket[ETH_FRAME_LEN]; char ethPacket[ETH_FRAME_LEN];
int len; int len;
if (iface->cease)
goto out;
/* Send the DHCP request */ /* Send the DHCP request */
syslog (LOG_INFO, "DHCP: Sending request packet..."); syslog (LOG_INFO, "DHCP: Sending request packet...");
do do
...@@ -518,13 +521,13 @@ int dhcp_handle_transaction (dhcp_interface *iface, unsigned int expected_reply_ ...@@ -518,13 +521,13 @@ int dhcp_handle_transaction (dhcp_interface *iface, unsigned int expected_reply_
tries++; tries++;
gettimeofday (&recv_timeout, NULL); gettimeofday (&recv_timeout, NULL);
recv_timeout.tv_sec += (tries * DHCP_INITIAL_RTO); recv_timeout.tv_sec += (tries * DHCP_INITIAL_RTO);
recv_timeout.tv_sec += (random () % 200000); recv_timeout.tv_usec += (random () % 200000);
if (timeval_subtract (&diff, &overall_end, &recv_timeout) != 0) if (timeval_subtract (&diff, &overall_end, &recv_timeout) != 0)
memcpy (&recv_timeout, &overall_end, sizeof (struct timeval)); memcpy (&recv_timeout, &overall_end, sizeof (struct timeval));
/* Wait for some kind of data to appear on the socket */ /* Wait for some kind of data to appear on the socket */
syslog (LOG_INFO, "DHCP: Waiting for reply..."); syslog (LOG_INFO, "DHCP: Waiting for reply...");
if ((err = peekfd (iface, recv_sk, &recv_timeout) != RET_DHCP_SUCCESS)) if ((err = peekfd (iface, recv_sk, &recv_timeout)) != RET_DHCP_SUCCESS)
{ {
if (err == RET_DHCP_TIMEOUT) if (err == RET_DHCP_TIMEOUT)
continue; continue;
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
#define DHCP_RELEASE 7 #define DHCP_RELEASE 7
#define DHCP_INFORM 8 #define DHCP_INFORM 8
/* DHCP RETRANSMISSION TIMEOUT (seconds) */ /* DHCP RETRANSMISSION TIMEOUT (seconds) */
#define DHCP_INITIAL_RTO (4) #define DHCP_INITIAL_RTO (5)
#define DHCP_MAX_RTO (64) #define DHCP_MAX_RTO (64)
#define DHCP_OPTIONS_LENGTH 312 #define DHCP_OPTIONS_LENGTH 312
......
...@@ -151,7 +151,7 @@ dhcp_interface *dhcp_interface_init (const char *if_name, dhcp_client_options *i ...@@ -151,7 +151,7 @@ dhcp_interface *dhcp_interface_init (const char *if_name, dhcp_client_options *i
memset (&addr, 0, sizeof (addr)); memset (&addr, 0, sizeof (addr));
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons (DHCP_CLIENT_PORT); addr.sin_port = htons (DHCP_CLIENT_PORT);
if ( bind (iface->sk, (struct sockaddr *)&addr, sizeof(addr)) != 0 ) if (bind (iface->sk, (struct sockaddr *)&addr, sizeof(addr)) != 0)
syslog (LOG_ERR,"dhcp_interface_init: bind: %m\n"); syslog (LOG_ERR,"dhcp_interface_init: bind: %m\n");
if (ioctl (iface->sk, SIOCGIFHWADDR, &ifr)) if (ioctl (iface->sk, SIOCGIFHWADDR, &ifr))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment