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>
* 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_
char *pkt_recv = NULL;
int recv_sk = -1;
struct sockaddr_in addr;
int tries = -1;
int tries = 0;
int dhcp_send_len, err = RET_DHCP_TIMEOUT;
dhcpMessage *dhcp_send = NULL;
struct timeval recv_timeout, overall_end, diff, current;
......@@ -487,6 +487,9 @@ int dhcp_handle_transaction (dhcp_interface *iface, unsigned int expected_reply_
char ethPacket[ETH_FRAME_LEN];
int len;
if (iface->cease)
goto out;
/* Send the DHCP request */
syslog (LOG_INFO, "DHCP: Sending request packet...");
do
......@@ -518,13 +521,13 @@ int dhcp_handle_transaction (dhcp_interface *iface, unsigned int expected_reply_
tries++;
gettimeofday (&recv_timeout, NULL);
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)
memcpy (&recv_timeout, &overall_end, sizeof (struct timeval));
/* Wait for some kind of data to appear on the socket */
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)
continue;
......
......@@ -58,7 +58,7 @@
#define DHCP_RELEASE 7
#define DHCP_INFORM 8
/* DHCP RETRANSMISSION TIMEOUT (seconds) */
#define DHCP_INITIAL_RTO (4)
#define DHCP_INITIAL_RTO (5)
#define DHCP_MAX_RTO (64)
#define DHCP_OPTIONS_LENGTH 312
......
......@@ -151,7 +151,7 @@ dhcp_interface *dhcp_interface_init (const char *if_name, dhcp_client_options *i
memset (&addr, 0, sizeof (addr));
addr.sin_family = AF_INET;
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");
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