Commit e6eccd10 authored by Thomas Markwalder's avatar Thomas Markwalder

[#10,!6] Added ping-timeout-ms parameter

You can now use ping-timeout-ms to specify the ping
timeout value in milliseconds.

includes/dhcpd.h
    new defines: SV_PING_TIMEOUT_MS and DEFAULT_PING_TIMEOUT_MS

server/dhcp.c
    do_ping_check() - modified to calculate ping time from
    ping-timeout-ms when its > 0, otherwise use ping-timeout
    Added timeout value to debug log message

server/dhcpd.conf.5
    Added discussion of ping-timeout-ms

server/stables.c
    Added entry for ping-timeout-ms
parent 787b8c03
...@@ -816,16 +816,20 @@ struct lease_state { ...@@ -816,16 +816,20 @@ struct lease_state {
#define SV_LOCAL_ADDRESS6 97 #define SV_LOCAL_ADDRESS6 97
#define SV_BIND_LOCAL_ADDRESS6 98 #define SV_BIND_LOCAL_ADDRESS6 98
#define SV_PING_CLTT_SECS 99 #define SV_PING_CLTT_SECS 99
#define SV_PING_TIMEOUT_MS 100
#if !defined (DEFAULT_PING_TIMEOUT) #if !defined (DEFAULT_PING_TIMEOUT)
# define DEFAULT_PING_TIMEOUT 1 # define DEFAULT_PING_TIMEOUT 1
#endif #endif
#if !defined (DEFAULT_PING_TIMEOUT_MS)
# define DEFAULT_PING_TIMEOUT_MS 0
#endif
#if !defined (DEFAULT_PING_CLTT_SECS) #if !defined (DEFAULT_PING_CLTT_SECS)
# define DEFAULT_PING_CLTT_SECS 60 /* in seconds */ # define DEFAULT_PING_CLTT_SECS 60 /* in seconds */
#endif #endif
#if !defined (DEFAULT_DELAYED_ACK) #if !defined (DEFAULT_DELAYED_ACK)
# define DEFAULT_DELAYED_ACK 0 /* default 0 disables delayed acking */ # define DEFAULT_DELAYED_ACK 0 /* default 0 disables delayed acking */
#endif #endif
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
DHCP Protocol engine. */ DHCP Protocol engine. */
/* /*
* Copyright (c) 2004-2018 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 2004-2019 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium * Copyright (c) 1995-2003 by Internet Software Consortium
* *
* This Source Code Form is subject to the terms of the Mozilla Public * This Source Code Form is subject to the terms of the Mozilla Public
...@@ -3609,10 +3609,13 @@ int do_ping_check(struct packet* packet, struct lease_state* state, ...@@ -3609,10 +3609,13 @@ int do_ping_check(struct packet* packet, struct lease_state* state,
struct lease* lease, TIME original_cltt, struct lease* lease, TIME original_cltt,
int same_client) { int same_client) {
TIME ping_timeout = DEFAULT_PING_TIMEOUT; TIME ping_timeout = DEFAULT_PING_TIMEOUT;
TIME ping_timeout_ms = DEFAULT_PING_TIMEOUT_MS;
struct option_cache *oc = NULL; struct option_cache *oc = NULL;
struct data_string ds; struct data_string ds;
struct timeval tv; struct timeval tv;
int ignorep; int ignorep;
int timeout_secs;
int timeout_ms;
// Don't go any further if lease is active or static. // Don't go any further if lease is active or static.
if (lease->binding_state == FTS_ACTIVE || lease->flags & STATIC_LEASE) { if (lease->binding_state == FTS_ACTIVE || lease->flags & STATIC_LEASE) {
...@@ -3658,6 +3661,7 @@ int do_ping_check(struct packet* packet, struct lease_state* state, ...@@ -3658,6 +3661,7 @@ int do_ping_check(struct packet* packet, struct lease_state* state,
/* Determine whether to use configured or default ping timeout. */ /* Determine whether to use configured or default ping timeout. */
memset(&ds, 0, sizeof(ds)); memset(&ds, 0, sizeof(ds));
oc = lookup_option (&server_universe, state->options, SV_PING_TIMEOUT); oc = lookup_option (&server_universe, state->options, SV_PING_TIMEOUT);
if (oc && if (oc &&
(evaluate_option_cache (&ds, packet, lease, 0, (evaluate_option_cache (&ds, packet, lease, 0,
...@@ -3670,26 +3674,50 @@ int do_ping_check(struct packet* packet, struct lease_state* state, ...@@ -3670,26 +3674,50 @@ int do_ping_check(struct packet* packet, struct lease_state* state,
data_string_forget (&ds, MDL); data_string_forget (&ds, MDL);
} }
oc = lookup_option (&server_universe, state->options, SV_PING_TIMEOUT_MS);
if (oc &&
(evaluate_option_cache (&ds, packet, lease, 0,
packet->options, state->options,
&lease->scope, oc, MDL))) {
if (ds.len == sizeof (u_int32_t)) {
ping_timeout_ms = getULong (ds.data);
}
data_string_forget (&ds, MDL);
}
/*
* Set the timeout for the ping to the current timeval plus
* the configured time out. Use ping-timeout-ms if it is > 0.
* This overrides ping-timeout allowing users to specify it in
* milliseconds.
*/
if (ping_timeout_ms > 0) {
timeout_secs = ping_timeout_ms / 1000;
timeout_ms = ping_timeout_ms % 1000;
} else {
timeout_secs = ping_timeout;
timeout_ms = 0;
}
tv.tv_sec = cur_tv.tv_sec + timeout_secs;
tv.tv_usec = cur_tv.tv_usec + (timeout_ms * 1000);
add_timeout (&tv, lease_ping_timeout, lease, (tvref_t)lease_reference,
(tvunref_t)lease_dereference);
#ifdef DEBUG #ifdef DEBUG
log_debug ("Pinging:%s, state: %d, same client? %s, " log_debug ("Pinging:%s, state: %d, same client? %s, "
" orig_cltt %s, elasped: %ld" , " orig_cltt %s, elasped: %ld, timeout in: %d.%d secs" ,
piaddr(lease->ip_addr), piaddr(lease->ip_addr),
lease->binding_state, lease->binding_state,
(same_client ? "y" : "n"), (same_client ? "y" : "n"),
(original_cltt ? print_time(original_cltt) : "0"), (original_cltt ? print_time(original_cltt) : "0"),
(original_cltt ? (long)(cur_time - original_cltt) : 0)); (original_cltt ? (long)(cur_time - original_cltt) : 0),
#endif timeout_secs, timeout_ms);
/* #endif
* Set a timeout for 'ping-timeout' seconds from NOW, including
* current microseconds. As ping-timeout defaults to 1, the
* exclusion of current microseconds causes a value somewhere
* /between/ zero and one.
*/
tv.tv_sec = cur_tv.tv_sec + ping_timeout;
tv.tv_usec = cur_tv.tv_usec;
add_timeout (&tv, lease_ping_timeout, lease, (tvref_t)lease_reference,
(tvunref_t)lease_dereference);
return (1); return (1);
} }
......
.\" dhcpd.conf.5 .\" dhcpd.conf.5
.\" .\"
.\" Copyright (c) 2004-2018 by Internet Systems Consortium, Inc. ("ISC") .\" Copyright (c) 2004-2019 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1996-2003 by Internet Software Consortium .\" Copyright (c) 1996-2003 by Internet Software Consortium
.\" .\"
.\" This Source Code Form is subject to the terms of the Mozilla Public .\" This Source Code Form is subject to the terms of the Mozilla Public
...@@ -3070,7 +3070,20 @@ you to configure how many seconds the DHCP server should wait for an ...@@ -3070,7 +3070,20 @@ you to configure how many seconds the DHCP server should wait for an
ICMP Echo response to be heard, if no ICMP Echo response has been received ICMP Echo response to be heard, if no ICMP Echo response has been received
before the timeout expires, it assigns the address. If a response \fIis\fR before the timeout expires, it assigns the address. If a response \fIis\fR
heard, the lease is abandoned, and the server does not respond to the client. heard, the lease is abandoned, and the server does not respond to the client.
If no value is set, ping-timeout defaults to 1 second. If no value is set, ping-timeout defaults to 1 second. (See also ping-timeout-ms
below)
.RE
The
.I ping-timeout-ms
statement
.RS 0.25i
.PP
.B ping-timeout-ms
.I milliseconds\fR\fB;\fR
.PP
Allows you to specify the ping timeout in milliseconds rather than
seconds. If this value is greater than zero, the server will use it
in place of ping-timeout. The default value is zero.
.RE .RE
.PP .PP
The The
......
...@@ -292,6 +292,7 @@ static struct option server_options[] = { ...@@ -292,6 +292,7 @@ static struct option server_options[] = {
{ "local-address6", "6", &server_universe, SV_LOCAL_ADDRESS6, 1 }, { "local-address6", "6", &server_universe, SV_LOCAL_ADDRESS6, 1 },
{ "bind-local-address6", "f", &server_universe, SV_BIND_LOCAL_ADDRESS6, 1 }, { "bind-local-address6", "f", &server_universe, SV_BIND_LOCAL_ADDRESS6, 1 },
{ "ping-cltt-secs", "T", &server_universe, SV_PING_CLTT_SECS, 1 }, { "ping-cltt-secs", "T", &server_universe, SV_PING_CLTT_SECS, 1 },
{ "ping-timeout-ms", "T", &server_universe, SV_PING_TIMEOUT_MS, 1 },
{ NULL, NULL, NULL, 0, 0 } { NULL, NULL, NULL, 0, 0 }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment