[PATCH 2/3] Make udhcpc continuously retry getting a lease until dhcp_timeout.
Signed-off-by: Ferenc Wagner <wferi@niif.hu>
---
packages/netcfg/dhcp.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/packages/netcfg/dhcp.c b/packages/netcfg/dhcp.c
index f706c5c..385799b 100644
--- a/packages/netcfg/dhcp.c
+++ b/packages/netcfg/dhcp.c
@@ -138,6 +138,7 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
int options_count;
enum { DHCLIENT, PUMP, UDHCPC } dhcp_client;
int dhcp_seconds;
+ char dhcp_seconds_str[16];
if (access("/sbin/dhclient", F_OK) == 0)
dhcp_client = DHCLIENT;
@@ -153,6 +154,7 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
debconf_get(client, "netcfg/dhcp_timeout");
dhcp_seconds = atoi(client->value);
+ snprintf(dhcp_seconds_str, sizeof dhcp_seconds_str, "%d", dhcp_seconds-1);
if ((dhcp_pid = fork()) == 0) { /* child */
/* disassociate from debconf */
@@ -202,10 +204,10 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
/* Allow space for:
options: options_count * 2
- params: 5
+ params: 9
hostname: 2
NULL: 1 */
- arguments = malloc((options_count * 2 + 5 + 2 + 1) * sizeof(char *));
+ arguments = malloc((options_count * 2 + 9 + 2 + 1) * sizeof(char *));
/* set the command options */
options_count = 0;
@@ -214,6 +216,10 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
arguments[options_count++] = interface;
arguments[options_count++] = "-V";
arguments[options_count++] = "d-i";
+ arguments[options_count++] = "-T";
+ arguments[options_count++] = "1";
+ arguments[options_count++] = "-t";
+ arguments[options_count++] = dhcp_seconds_str;
for (ptr = dhclient_request_options_udhcpc; *ptr; ptr++) {
arguments[options_count++] = "-O";
arguments[options_count++] = *ptr;
--
1.7.2.3
Reply to: