2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-28 12:57:42 +00:00

[master] Adds persist-eui-64-leases config parameter and support

Merges in rt45046.
This commit is contained in:
Thomas Markwalder 2017-12-11 07:45:10 -05:00
parent 7b4f284e50
commit c2e5ee2882
6 changed files with 87 additions and 19 deletions

View File

@ -298,6 +298,11 @@ dhcp-users@lists.isc.org.
default), hmac-sha1, hmac-sha224, hmac-sha256, hmac-sha384, and hmac-sha512. default), hmac-sha1, hmac-sha224, hmac-sha256, hmac-sha384, and hmac-sha512.
[ISC-Bugs #46771] [ISC-Bugs #46771]
- Added a server configuration parameter, persist-eui-64-leases, which
determines whether or not EUI-64 based leases are written to the
leases file. Default is true.
[ISC-Bugs #45046]
Changes since 4.3.0 (bug fixes) Changes since 4.3.0 (bug fixes)
- Tidy up several small tickets. - Tidy up several small tickets.

View File

@ -801,6 +801,7 @@ struct lease_state {
#define SV_ABANDON_LEASE_TIME 89 #define SV_ABANDON_LEASE_TIME 89
#ifdef EUI_64 #ifdef EUI_64
#define SV_USE_EUI_64 90 #define SV_USE_EUI_64 90
#define SV_PERSIST_EUI_64_LEASES 91
#endif #endif
#if defined (FAILOVER_PROTOCOL) #if defined (FAILOVER_PROTOCOL)
#define SV_CHECK_SECS_BYTE_ORDER 91 #define SV_CHECK_SECS_BYTE_ORDER 91
@ -2099,6 +2100,10 @@ extern u_int16_t ddns_conflict_mask;
extern int dont_use_fsync; extern int dont_use_fsync;
extern int server_id_check; extern int server_id_check;
#ifdef EUI_64
extern int persist_eui64;
#endif
extern int prefix_length_mode; extern int prefix_length_mode;
extern int authoring_byte_order; extern int authoring_byte_order;
extern int lease_id_format; extern int lease_id_format;

View File

@ -374,7 +374,7 @@ int write_host (host)
++errors; ++errors;
} }
} }
memset (&ip_addrs, 0, sizeof ip_addrs); memset (&ip_addrs, 0, sizeof ip_addrs);
if (host -> fixed_addr && if (host -> fixed_addr &&
evaluate_option_cache (&ip_addrs, (struct packet *)0, evaluate_option_cache (&ip_addrs, (struct packet *)0,
@ -384,7 +384,7 @@ int write_host (host)
(struct option_state *)0, (struct option_state *)0,
&global_scope, &global_scope,
host -> fixed_addr, MDL)) { host -> fixed_addr, MDL)) {
errno = 0; errno = 0;
fprintf (db_file, "\n fixed-address "); fprintf (db_file, "\n fixed-address ");
if (errno) if (errno)
@ -525,9 +525,30 @@ write_ia(const struct ia_xx *ia) {
char *s; char *s;
int fprintf_ret; int fprintf_ret;
/* #ifdef EUI_64
* If the lease file is corrupt, don't try to write any more /* If we're not writing EUI64 leases to the file, then
* leases until we've written a good lease file. * we can skip writing this IA provided all of its leases
* are EUI64. (Not sure you can ever have a case where
* they aren't but doesn't hurt to check) */
if (ia->ia_type == D6O_IA_NA && !persist_eui64) {
int i;
for (i=0; i < ia->num_iasubopt; i++) {
if (!ia->iasubopt[i]->ipv6_pool->ipv6_pond->use_eui_64)
{
break;
}
}
if (i == ia->num_iasubopt) {
/* Their all EUI64 so we can skip it */
return(1);
}
}
#endif
/*
* If the lease file is corrupt, don't try to write any more
* leases until we've written a good lease file.
*/ */
if (lease_file_is_corrupt) { if (lease_file_is_corrupt) {
if (!new_lease_file(0)) { if (!new_lease_file(0)) {
@ -587,11 +608,11 @@ write_ia(const struct ia_xx *ia) {
goto error_exit; goto error_exit;
} }
if ((iasubopt->state <= 0) || (iasubopt->state > FTS_LAST)) { if ((iasubopt->state <= 0) || (iasubopt->state > FTS_LAST)) {
log_fatal("Unknown iasubopt state %d at %s:%d", log_fatal("Unknown iasubopt state %d at %s:%d",
iasubopt->state, MDL); iasubopt->state, MDL);
} }
binding_state = binding_state_names[iasubopt->state-1]; binding_state = binding_state_names[iasubopt->state-1];
if (fprintf(db_file, " binding state %s;\n", if (fprintf(db_file, " binding state %s;\n",
binding_state) < 0) { binding_state) < 0) {
goto error_exit; goto error_exit;
} }
@ -639,7 +660,7 @@ write_ia(const struct ia_xx *ia) {
if (write_binding_scope(db_file, bnd, if (write_binding_scope(db_file, bnd,
"\n ") != ISC_R_SUCCESS) "\n ") != ISC_R_SUCCESS)
goto error_exit; goto error_exit;
} }
if (iasubopt->on_star.on_expiry) { if (iasubopt->on_star.on_expiry) {
@ -650,7 +671,7 @@ write_ia(const struct ia_xx *ia) {
goto error_exit; goto error_exit;
write_statements(db_file, write_statements(db_file,
iasubopt->on_star.on_expiry, 6); iasubopt->on_star.on_expiry, 6);
if (fprintf(db_file, "\n }") < 0) if (fprintf(db_file, "\n }") < 0)
goto error_exit; goto error_exit;
} }
@ -697,9 +718,9 @@ write_server_duid(void) {
return 1; return 1;
} }
/* /*
* If the lease file is corrupt, don't try to write any more * If the lease file is corrupt, don't try to write any more
* leases until we've written a good lease file. * leases until we've written a good lease file.
*/ */
if (lease_file_is_corrupt) { if (lease_file_is_corrupt) {
if (!new_lease_file(0)) { if (!new_lease_file(0)) {
@ -882,7 +903,7 @@ write_named_billing_class(const void *key, unsigned len, void *object)
if (fprintf(db_file, " dynamic;\n") <= 0) if (fprintf(db_file, " dynamic;\n") <= 0)
return ISC_R_IOERROR; return ISC_R_IOERROR;
} }
if (class->lease_limit > 0) { if (class->lease_limit > 0) {
if (fprintf(db_file, " lease limit %d;\n", if (fprintf(db_file, " lease limit %d;\n",
class->lease_limit) <= 0) class->lease_limit) <= 0)
@ -893,7 +914,7 @@ write_named_billing_class(const void *key, unsigned len, void *object)
if (fprintf(db_file, " match if ") <= 0) if (fprintf(db_file, " match if ") <= 0)
return ISC_R_IOERROR; return ISC_R_IOERROR;
errno = 0; errno = 0;
write_expression(db_file, class->expr, 5, 5, 0); write_expression(db_file, class->expr, 5, 5, 0);
if (errno) if (errno)
return ISC_R_IOERROR; return ISC_R_IOERROR;
@ -919,7 +940,7 @@ write_named_billing_class(const void *key, unsigned len, void *object)
if (fprintf(db_file, ";\n") <= 0) if (fprintf(db_file, ";\n") <= 0)
return ISC_R_IOERROR; return ISC_R_IOERROR;
} }
if (class->statements != 0) { if (class->statements != 0) {
errno = 0; errno = 0;
write_statements(db_file, class->statements, 8); write_statements(db_file, class->statements, 8);
@ -1238,7 +1259,7 @@ int new_lease_file (int test_mode)
#if defined (TRACING) #if defined (TRACING)
} }
#endif #endif
/* Move in the new file... */ /* Move in the new file... */
if (rename (newfname, path_dhcpd_db) < 0) { if (rename (newfname, path_dhcpd_db) < 0) {
log_error ("Can't install new lease database %s to %s: %m", log_error ("Can't install new lease database %s to %s: %m",

View File

@ -82,6 +82,10 @@ int dont_use_fsync = 0; /* 0 = default, use fsync, 1 = don't use fsync */
int server_id_check = 0; /* 0 = default, don't check server id, 1 = do check */ int server_id_check = 0; /* 0 = default, don't check server id, 1 = do check */
int prefix_length_mode = PLM_PREFER; int prefix_length_mode = PLM_PREFER;
#ifdef EUI_64
int persist_eui64 = 1; /* 1 = write EUI64 leases to disk, 0 = don't */
#endif
int authoring_byte_order = 0; /* 0 = not set */ int authoring_byte_order = 0; /* 0 = not set */
int lease_id_format = TOKEN_OCTAL; /* octal by default */ int lease_id_format = TOKEN_OCTAL; /* octal by default */
u_int32_t abandon_lease_time = DEFAULT_ABANDON_LEASE_TIME; u_int32_t abandon_lease_time = DEFAULT_ABANDON_LEASE_TIME;
@ -847,8 +851,9 @@ main(int argc, char **argv) {
#endif #endif
/* test option should cause an early exit */ /* test option should cause an early exit */
if (cftest && !lftest) if (cftest && !lftest) {
exit(0); exit(0);
}
/* /*
* First part of dealing with pid files. Check to see if * First part of dealing with pid files. Check to see if
@ -1396,6 +1401,21 @@ void postconf_initialization (int quiet)
} }
#endif #endif
#ifdef EUI_64
oc = lookup_option(&server_universe, options, SV_PERSIST_EUI_64_LEASES);
if (oc != NULL) {
persist_eui64 = evaluate_boolean_option_cache(NULL, NULL, NULL,
NULL, options,
NULL,
&global_scope,
oc, MDL);
}
if (!persist_eui64) {
log_info("EUI64 leases will not be written to lease file");
}
#endif
#if defined (BINARY_LEASES) #if defined (BINARY_LEASES)
if (local_family == AF_INET) { if (local_family == AF_INET) {
log_info("Source compiled to use binary-leases"); log_info("Source compiled to use binary-leases");

View File

@ -2920,6 +2920,21 @@ or provable, so we urge caution in the use of this statement.
.RE .RE
.PP .PP
The The
.I persist-eui-64-leases
statement
.RS 0.25i
.PP
.B persist-eui-64-leases \fIflag\fR\fB;\fR
.PP
When this flag is enabled, the server will write EUI-64 based leases to the
leases file. Since such leases can only, ever be valid for a single DUID value
it can be argued that writing them to the leases file isn't essential and not
doing so may have perfomance advantages. See \fIuse-eui-64\fR statement for
more details on EUI-64 based address allocation. The flag is enabled by
default and may only be set at the global scope.
.RE
.PP
The
.I pid-file-name .I pid-file-name
statement statement
.RS 0.25i .RS 0.25i
@ -3349,8 +3364,6 @@ in use. Also, the server must attempt the update each time the
client renews its lease, which could have a significant performance client renews its lease, which could have a significant performance
impact in environments that place heavy demands on the DHCP server. impact in environments that place heavy demands on the DHCP server.
.RE .RE
.PP .PP
The The
.I use-eui-64 .I use-eui-64
@ -3413,6 +3426,9 @@ message:
Request - Server will send "an address not on link status", and no ia Request - Server will send "an address not on link status", and no ia
suboption Renew/Rebind - Server will send the requested address ia suboption Renew/Rebind - Server will send the requested address ia
suboption with lifetimes of 0, plus an EUI-64 ia suboption with lifetimes of 0, plus an EUI-64 ia
Whether or not EUI-64 based leases are written out to the lease database
may be controlled by \fIpersist-eui-64-leases\fR statement.
.RE .RE
.PP .PP
The The

View File

@ -279,6 +279,7 @@ static struct option server_options[] = {
{ "abandon-lease-time", "T", &server_universe, SV_ABANDON_LEASE_TIME, 1 }, { "abandon-lease-time", "T", &server_universe, SV_ABANDON_LEASE_TIME, 1 },
#ifdef EUI_64 #ifdef EUI_64
{ "use-eui-64", "f", &server_universe, SV_USE_EUI_64, 1 }, { "use-eui-64", "f", &server_universe, SV_USE_EUI_64, 1 },
{ "persist-eui-64-leases", "f", &server_universe, SV_PERSIST_EUI_64_LEASES, 1 },
#endif #endif
#if defined (FAILOVER_PROTOCOL) #if defined (FAILOVER_PROTOCOL)
{ "check-secs-byte-order", "f", &server_universe, SV_CHECK_SECS_BYTE_ORDER, 1 }, { "check-secs-byte-order", "f", &server_universe, SV_CHECK_SECS_BYTE_ORDER, 1 },