]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
DHCPv6 released resources are now marked as released by the client
authorFrancis Dupont <fdupont@isc.org>
Wed, 20 Feb 2008 23:20:58 +0000 (23:20 +0000)
committerFrancis Dupont <fdupont@isc.org>
Wed, 20 Feb 2008 23:20:58 +0000 (23:20 +0000)
RELNOTES
client/clparse.c
client/dhc6.c
client/dhclient.c
includes/dhcpd.h

index 19cdb311bad24b6a1249053d18a0ff45791dd49f..35f6d5e5bad05e0c78839987109ab641bb560b00 100644 (file)
--- 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
index 01e8f28842a8d50ec5957bb4434bea3d8174e928..34fa93da2502ba57e8df7bd1384d6020f58b1c89 100644 (file)
@@ -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;
index 908262234f47c05b4b0733095f879d054f9ab19e..dd27584780fbb363bbe99bd1beefbcbfc7a0a855 100644 (file)
@@ -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;
index c9ba9a6bdcc37b0778d6cf45adeaef89067c88fd..38afe7214e4a6874b73a9382814dc3bc323792d6 100644 (file)
@@ -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, "  ");
 
index 7f04e0cb50490427ba62f3fe88549776f9cd919f..9bfdf73617d9c6556812a6e263739126e24b44da 100644 (file)
@@ -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;