- ./configure was extended to cover many optional build features, such
as failover, server tracing, debugging, and the execute() command.
+- There is now a default 1/4 of a second scheduled delay between delayed
+ fsync()'s, it can be configured by the max-ack-delay configuration
+ parameter.
+
Changes since 4.0.0 (new features)
- Added DHCPv6 rapid commit support.
#define SV_LIMIT_ADDRS_PER_IA 56
#define SV_LIMIT_PREFS_PER_IA 57
#define SV_DELAYED_ACK 58
+#define SV_MAX_ACK_DELAY 59
#if !defined (DEFAULT_PING_TIMEOUT)
# define DEFAULT_PING_TIMEOUT 1
# define DEFAULT_DELAYED_ACK 28 /* default SO_SNDBUF size / 576 bytes */
#endif
+#if !defined (DEFAULT_ACK_DELAY_SECS)
+# define DEFAULT_ACK_DELAY_SECS 0
+#endif
+
+#if !defined (DEFAULT_ACK_DELAY_USECS)
+# define DEFAULT_ACK_DELAY_USECS 250000 /* 1/4 of a second */
+#endif
+
#if !defined (DEFAULT_DEFAULT_LEASE_TIME)
# define DEFAULT_DEFAULT_LEASE_TIME 43200
#endif
/* dhcp.c */
extern int outstanding_pings;
extern int max_outstanding_acks;
+extern int max_ack_delay_secs;
+extern int max_ack_delay_usecs;
void dhcp PROTO ((struct packet *));
void dhcpdiscover PROTO ((struct packet *, int));
log_info ("commit_leases: unable to commit: %m");
return 0;
}
-
- /* send out all deferred ACKs now*/
+
+ /* send out all deferred ACKs now */
flush_ackqueue(NULL);
/* If we haven't rewritten the lease database in over an
#include "dhcpd.h"
#include <errno.h>
#include <limits.h>
+#include <sys/time.h>
+
+static void commit_leases_ackout(void *foo);
int outstanding_pings;
struct leasequeue *ackqueue_head, *ackqueue_tail;
static struct leasequeue *free_ackqueue;
-TIME next_fsync;
+static struct timeval next_fsync;
int outstanding_acks;
int max_outstanding_acks = DEFAULT_DELAYED_ACK;
+int max_ack_delay_secs = DEFAULT_ACK_DELAY_SECS;
+int max_ack_delay_usecs = DEFAULT_ACK_DELAY_USECS;
static char dhcp_message [256];
static int site_code_min;
delayed_ack_enqueue(struct lease *lease)
{
struct leasequeue *q;
+
if (!write_lease(lease))
return;
if (free_ackqueue) {
if (outstanding_acks > max_outstanding_acks)
commit_leases();
- /* If neccessary, schedule a fsync in 1 second */
- /*
- if (next_fsync < cur_time + 1) {
- next_fsync = cur_time + 1;
- add_timeout(next_fsync, commit_leases_readerdry, NULL,
+ /* If next_fsync is not set, schedule an fsync. */
+ if (next_fsync.tv_sec == 0 && next_fsync.tv_usec == 0) {
+ next_fsync.tv_sec = cur_tv.tv_sec + max_ack_delay_secs;
+ next_fsync.tv_usec = cur_tv.tv_usec + max_ack_delay_usecs;
+
+ if (next_fsync.tv_usec >= 1000000) {
+ next_fsync.tv_sec++;
+ next_fsync.tv_usec -= 1000000;
+ }
+
+ add_timeout(&next_fsync, commit_leases_ackout, NULL,
(tvref_t) NULL, (tvunref_t) NULL);
}
- */
}
void
commit_leases_readerdry(void *foo)
{
- if (outstanding_acks)
+ if (outstanding_acks) {
+ commit_leases();
+
+ /* Reset next_fsync and cancel any pending timeout. */
+ memset(&next_fsync, 0, sizeof(next_fsync));
+ cancel_timeout(commit_leases_ackout, NULL);
+ }
+}
+
+static void
+commit_leases_ackout(void *foo)
+{
+ if (outstanding_acks) {
commit_leases();
+
+ memset(&next_fsync, 0, sizeof(next_fsync));
+ }
}
/* CC: process the delayed ACK responses:
data_string_forget(&db, MDL);
}
+ oc = lookup_option(&server_universe, options, SV_MAX_ACK_DELAY);
+ if (oc &&
+ evaluate_option_cache(&db, NULL, NULL, NULL, options, NULL,
+ &global_scope, oc, MDL)) {
+ u_int32_t timeval;
+
+ if (db.len != 4)
+ log_fatal("invalid max ack delay configuration");
+
+ timeval = getULong(db.data);
+ max_ack_delay_secs = timeval / 1000000;
+ max_ack_delay_usecs = timeval % 1000000;
+
+ data_string_forget(&db, MDL);
+ }
+
/* Don't need the options anymore. */
option_state_dereference (&options, MDL);
.\" see ``http://www.vix.com''. To learn more about Nominum, Inc., see
.\" ``http://www.nominum.com''.
.\"
-.\" $Id: dhcpd.conf.5,v 1.94 2008/02/20 12:45:53 fdupont Exp $
+.\" $Id: dhcpd.conf.5,v 1.95 2008/02/28 23:40:45 dhankins Exp $
.\"
.TH dhcpd.conf 5
.SH NAME
.PP
The
.I delayed-ack
-statement
+and
+.I max-ack-delay
+statements
.RS 0.25i
.PP
-.B delayed-ack \fInumber\fR\fB;\fR
+.B delayed-ack \fIcount\fR\fB;\fR
+.B max-ack-delay \fImicroseconds\fR\fB;\fR
.PP
-.I Number
+.I Count
should be an integer value from zero to 2^16-1, and defaults to 28. The
-number represents how many DHCPv4 replies maximum will be queued pending
+count represents how many DHCPv4 replies maximum will be queued pending
transmission until after a database commit event. If this number is
reached, a database commit event (commonly resulting in fsync() and
representing a performance penalty) will be made, and the reply packets
direction that "stable storage" be updated prior to replying to clients.
Should the DHCPv4 sockets "go dry" (select() returns immediately with no
read sockets), the commit is made and any queued packets are transmitted.
+.PP
+Similarly, \fImicroseconds\fR indicates how many microseconds are permitted
+to pass inbetween queuing a packet pending an fsync, and performing the
+fsync. Valid values range from 0 to 2^32-1, and defaults to 250,000 (1/4 of
+a second).
.RE
.PP
The
{ "limit-addrs-per-ia", "L", &server_universe, 56, 1 },
{ "limit-prefs-per-ia", "L", &server_universe, 57, 1 },
{ "delayed-ack", "S", &server_universe, 58, 1 },
+ { "max-ack-delay", "L", &server_universe, 59, 1 },
{ NULL, NULL, NULL, 0, 0 }
};