From ffbaa8801ec3e4806ac70acbeaaa672b0024fe22 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Thu, 12 Jun 2008 13:38:41 +0000 Subject: [PATCH] dhclient -6 -1 --- RELNOTES | 2 ++ client/dhc6.c | 25 ++++++++++++++++++++++--- client/dhclient.8 | 10 ++++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/RELNOTES b/RELNOTES index 56f664ff7..2c83a91b1 100644 --- a/RELNOTES +++ b/RELNOTES @@ -91,6 +91,8 @@ work on other platforms. Please report any problems and suggested fixes to - Fix handling of format code 'Z'. +- Support "-1" argument in DHCPv6. + Changes since 4.0.0 (new features) - Added DHCPv6 rapid commit support. diff --git a/client/dhc6.c b/client/dhc6.c index b8dbdd285..b9f79af78 100644 --- a/client/dhc6.c +++ b/client/dhc6.c @@ -110,6 +110,7 @@ static void script_write_params6(struct client_state *client, struct option_state *options); static isc_boolean_t active_prefix(struct client_state *client); +extern int onetry; extern int stateless; /* @@ -1316,7 +1317,11 @@ start_init6(struct client_state *client) client->IRT = SOL_TIMEOUT * 100; client->MRT = SOL_MAX_RT * 100; client->MRC = 0; - client->MRD = 0; + /* Default is 0 (no max) but -1 changes this. */ + if (!onetry) + client->MRD = 0; + else + client->MRD = client->config->timeout; dhc6_retrans_init(client); @@ -1368,7 +1373,11 @@ start_info_request6(struct client_state *client) client->IRT = INF_TIMEOUT * 100; client->MRT = INF_MAX_RT * 100; client->MRC = 0; - client->MRD = 0; + /* Default is 0 (no max) but -1 changes this. */ + if (!onetry) + client->MRD = 0; + else + client->MRD = client->config->timeout; dhc6_retrans_init(client); @@ -1490,8 +1499,17 @@ do_init6(void *input) elapsed.tv_sec -= 1; elapsed.tv_usec += 1000000; } + /* Check if finished (-1 argument). */ if ((client->MRD != 0) && (elapsed.tv_sec > client->MRD)) { log_info("Max retransmission duration exceeded."); + client->state = S_STOPPED; + if (client->active_lease != NULL) { + dhc6_lease_destroy(&client->active_lease, MDL); + client->active_lease = NULL; + } + /* Stop if and only if this is the last client. */ + if (stopping_finished()) + exit(2); return; } @@ -1901,9 +1919,10 @@ do_info_request6(void *input) elapsed.tv_sec -= 1; elapsed.tv_usec += 1000000; } + /* Check if finished (-1 argument). */ if ((client->MRD != 0) && (elapsed.tv_sec > client->MRD)) { log_info("Max retransmission duration exceeded."); - return; + exit(2); } memset(&ds, 0, sizeof(ds)); diff --git a/client/dhclient.8 b/client/dhclient.8 index 21f7ed275..49c36c440 100644 --- a/client/dhclient.8 +++ b/client/dhclient.8 @@ -1,4 +1,4 @@ -.\" $Id: dhclient.8,v 1.28 2008/05/23 13:56:07 fdupont Exp $ +.\" $Id: dhclient.8,v 1.29 2008/06/12 13:38:41 fdupont Exp $ .\" .\" Copyright (c) 2004,2007-2008 by Internet Systems Consortium, Inc. ("ISC") .\" Copyright (c) 1996-2003 by Internet Software Consortium @@ -294,7 +294,13 @@ at shutdown with the specific reason for calling the script set. The .B -1 flag will cause dhclient to try once to get a lease. If it fails, dhclient -exits with exit code two. +exits with exit code two. In DHCPv6 the +.B -1 +flag sets the max duration of the initial exchange to +.I timeout +(from +.IR dhclient.conf , +default sixty seconds). .PP The DHCP client normally gets its configuration information from .B ETCDIR/dhclient.conf, -- 2.39.5