From: Francis Dupont Date: Wed, 20 Feb 2008 23:20:58 +0000 (+0000) Subject: DHCPv6 released resources are now marked as released by the client X-Git-Tag: v4_1_0a2~58 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cabdb9b1c575c4d083f7178941bfd537008ad928;p=thirdparty%2Fdhcp.git DHCPv6 released resources are now marked as released by the client --- diff --git a/RELNOTES b/RELNOTES index 19cdb311b..35f6d5e5b 100644 --- a/RELNOTES +++ b/RELNOTES @@ -163,6 +163,8 @@ work on other platforms. Please report any problems and suggested fixes to - Warn when attempting to use a hardware parameter in DHCPv6. +- DHCPv6 released resources are now marked as released by the client. + Changes since 4.0.0b3 - The reverse dns name for PTR updates on IPv6 addresses has been fixed to diff --git a/client/clparse.c b/client/clparse.c index 01e8f2884..34fa93da2 100644 --- a/client/clparse.c +++ b/client/clparse.c @@ -1403,6 +1403,11 @@ parse_client6_lease_statement(struct parse *cfile) no_semi = 1; break; + case TOKEN_RELEASED: + case TOKEN_ABANDONED: + lease->released = ISC_TRUE; + break; + default: parse_warn(cfile, "Unexpected token, %s.", val); no_semi = 1; diff --git a/client/dhc6.c b/client/dhc6.c index 908262234..dd2758478 100644 --- a/client/dhc6.c +++ b/client/dhc6.c @@ -519,6 +519,7 @@ dhc6_dup_addr(struct dhc6_addr *addr, const char *file, int line) /* Form a DHCPv6 lease structure based upon packet contents. Creates and * populates IA's and any IAADDR/IAPREFIX's they contain. + * Parsed options are deleted in order to not save them in the lease file. */ static struct dhc6_lease * dhc6_leaseify(struct packet *packet) @@ -557,6 +558,7 @@ dhc6_leaseify(struct packet *packet) data_string_forget(&ds, MDL); } + delete_option(&dhcpv6_universe, lease->options, D6O_PREFERENCE); /* Dig into recursive DHCPv6 pockets for IA_NA and contained IAADDR * options. @@ -710,6 +712,7 @@ dhc6_parse_ia_na(struct dhc6_ia **pia, struct packet *packet, return ISC_R_UNEXPECTED; } } + delete_option(&dhcpv6_universe, options, D6O_IA_NA); return ISC_R_SUCCESS; } @@ -792,6 +795,7 @@ dhc6_parse_ia_ta(struct dhc6_ia **pia, struct packet *packet, return ISC_R_UNEXPECTED; } } + delete_option(&dhcpv6_universe, options, D6O_IA_TA); return ISC_R_SUCCESS; } @@ -892,6 +896,7 @@ dhc6_parse_ia_pd(struct dhc6_ia **pia, struct packet *packet, return ISC_R_UNEXPECTED; } } + delete_option(&dhcpv6_universe, options, D6O_IA_PD); return ISC_R_SUCCESS; } @@ -986,6 +991,7 @@ dhc6_parse_addrs(struct dhc6_addr **paddr, struct packet *packet, return ISC_R_UNEXPECTED; } } + delete_option(&dhcpv6_universe, options, D6O_IAADDR); return ISC_R_SUCCESS; } @@ -1089,6 +1095,7 @@ dhc6_parse_prefs(struct dhc6_addr **ppref, struct packet *packet, return ISC_R_UNEXPECTED; } } + delete_option(&dhcpv6_universe, options, D6O_IAPREFIX); return ISC_R_SUCCESS; } @@ -1286,7 +1293,7 @@ start_confirm6(struct client_state *client) struct timeval tv; /* If there is no active lease, there is nothing to check. */ - if (client->active_lease == NULL) { + if ((client->active_lease == NULL) || client->active_lease->released) { start_init6(client); return; } @@ -1670,6 +1677,12 @@ start_release6(struct client_state *client) */ unconfigure6(client, "RELEASE6"); + /* Note this in the lease file. */ + if (client->active_lease == NULL) + return; + client->active_lease->released = ISC_TRUE; + write_client6_lease(client, client->active_lease, 0, 1); + /* Set timers per RFC3315 section 18.1.1. */ client->IRT = REL_TIMEOUT * 100; client->MRT = 0; @@ -3390,6 +3403,7 @@ start_bound(struct client_state *client) "is selected."); return; } + lease->released = ISC_FALSE; old = client->old_lease; client->v6_handler = bound_handler; diff --git a/client/dhclient.c b/client/dhclient.c index c9ba9a6bd..38afe7214 100644 --- a/client/dhclient.c +++ b/client/dhclient.c @@ -474,7 +474,8 @@ main(int argc, char **argv) { /* If we have a previous binding, Confirm * that we can (or can't) still use it. */ - if (client->active_lease != NULL) + if ((client->active_lease != NULL) && + !client->active_lease->released) start_confirm6(client); else start_init6(client); @@ -2601,6 +2602,12 @@ write_client6_lease(struct client_state *client, struct dhc6_lease *lease, return ISC_R_IOERROR; } + if (lease->released) { + stat = fprintf(leaseFile, " released;\n"); + if (stat <= 0) + return ISC_R_IOERROR; + } + if (lease->options != NULL) write_options(client, lease->options, " "); diff --git a/includes/dhcpd.h b/includes/dhcpd.h index 7f04e0cb5..9bfdf7361 100644 --- a/includes/dhcpd.h +++ b/includes/dhcpd.h @@ -928,6 +928,7 @@ struct dhc6_lease { struct dhc6_lease *next; struct data_string server_id; + isc_boolean_t released; int score; u_int8_t pref;