2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-22 09:57:20 +00:00

- ./configure was extended to cover many optional build features, such

as failover, server tracing, debugging, and the execute() command.
  [ISC-Bugs #17678]
This commit is contained in:
David Hankins 2008-02-28 21:21:56 +00:00
parent 3004d0a318
commit 66cebfcb89
14 changed files with 96 additions and 37 deletions

View File

@ -54,6 +54,9 @@ work on other platforms. Please report any problems and suggested fixes to
via two ./configure parameters, --enable-paranoia and via two ./configure parameters, --enable-paranoia and
--enable-early-chroot. --enable-early-chroot.
- ./configure was extended to cover many optional build features, such
as failover, server tracing, debugging, and the execute() command.
Changes since 4.0.0 (new features) Changes since 4.0.0 (new features)
- Added DHCPv6 rapid commit support. - Added DHCPv6 rapid commit support.

View File

@ -729,8 +729,10 @@ void write_statements (file, statements, indent)
struct executable_statement *statements; struct executable_statement *statements;
int indent; int indent;
{ {
struct executable_statement *r, *x; #if defined ENABLE_EXECUTE
struct expression *expr; struct expression *expr;
#endif
struct executable_statement *r, *x;
const char *s, *t, *dot; const char *s, *t, *dot;
int col; int col;

View File

@ -2017,13 +2017,15 @@ int parse_executable_statement (result, cfile, lose, case_context)
int *lose; int *lose;
enum expression_context case_context; enum expression_context case_context;
{ {
#if defined(ENABLE_EXECUTE)
unsigned len;
struct expression **ep;
#endif
enum dhcp_token token; enum dhcp_token token;
const char *val; const char *val;
unsigned len;
struct class *cta; struct class *cta;
struct option *option=NULL; struct option *option=NULL;
struct option_cache *cache; struct option_cache *cache;
struct expression **ep;
int known; int known;
int flag; int flag;
int i; int i;

View File

@ -30,10 +30,72 @@ AC_DEFINE_UNQUOTED([DHCP_BYTE_ORDER], [$byte_order],
[Define to BIG_ENDIAN for MSB (Motorola or SPARC CPUs) [Define to BIG_ENDIAN for MSB (Motorola or SPARC CPUs)
or LITTLE_ENDIAN for LSB (Intel CPUs).]) or LITTLE_ENDIAN for LSB (Intel CPUs).])
# DHCPv6 is off by default # Optional compile-time DEBUGging.
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug],
[create a debug-only version of the software (default is no).]))
# This is very much off by default.
if test "$enable_debug" = "yes" ; then
AC_DEFINE([DEBUG], [1],
[Define to compile debug-only DHCP software.])
# Just override CFLAGS to totally to remove optimization.
CFLAGS="-g"
fi
# XXX: there are actually quite a lot more DEBUG_ features we could enable,
# but I don't want to pollute the --help space.
#
#/* #define DEBUG_TOKENS */
#/* #define DEBUG_PACKET */
#/* #define DEBUG_EXPRESSIONS */
#/* #define DEBUG_FIND_LEASE */
#/* #define DEBUG_EXPRESSION_PARSE */
#/* #define DEBUG_CLASS_MATCHING */
#/* #define DEBUG_MEMORY_LEAKAGE */
#/* #define DEBUG_MALLOC_POOL */
#/* #define DEBUG_LEASE_STATE_TRANSITIONS */
#/* #define DEBUG_RC_HISTORY */
#/* #define DEBUG_RC_HISTORY_EXHAUSTIVELY */
#/* #define RC_HISTORY_MAX 10240 */
#/* #define POINTER_DEBUG */
#/* #define DEBUG_FAILOVER_MESSAGES */
#/* #define DEBUG_FAILOVER_TIMING */
#/* #define DEBUG_DUMP_ALL_LEASES */
# Failover optional compile-time feature.
AC_ARG_ENABLE(failover,
AC_HELP_STRING([--enable-failover],
[enable support for failover (default is yes)]))
# Failover is on by default, so define if it is not explicitly disabled.
if test "$enable_failover" != "no"; then
AC_DEFINE([FAILOVER_PROTOCOL], [1],
[Define to include Failover Protocol support.])
fi
# execute() support.
AC_ARG_ENABLE(execute,
AC_HELP_STRING([--enable-execute],
[enable support for execute() in config (default is yes)]))
# execute() is on by default, so define if it is not explicitly disabled.
if test "$enable_execute" != "no" ; then
AC_DEFINE([ENABLE_EXECUTE], [1],
[Define to include execute() config language support.])
fi
# Server tracing support.
AC_ARG_ENABLE(tracing,
AC_HELP_STRING([--enable-tracing],
[enable support for server activity tracing (default is yes)]))
# tracing is on by default, so define if it is not explicitly disabled.
if test "$enable_tracing" != "no" ; then
AC_DEFINE([TRACING], [1],
[Define to include server activity tracing support.])
fi
# DHCPv6 optional compile-time feature.
AC_ARG_ENABLE(dhcpv6, AC_ARG_ENABLE(dhcpv6,
AC_HELP_STRING([--enable-dhcpv6], AC_HELP_STRING([--enable-dhcpv6],
[enable support for DHCPv6 (default is yes)])) [enable support for DHCPv6 (default is yes)]))
# DHCPv6 is on by default, so define if it is not explicitly disabled.
if test "$enable_dhcpv6" != "no"; then if test "$enable_dhcpv6" != "no"; then
AC_DEFINE([DHCPv6], [1], AC_DEFINE([DHCPv6], [1],
[Define to 1 to include DHCPv6 support.]) [Define to 1 to include DHCPv6 support.])

View File

@ -94,7 +94,7 @@
/* Define this if you want DHCP failover protocol support in the DHCP /* Define this if you want DHCP failover protocol support in the DHCP
server. */ server. */
#define FAILOVER_PROTOCOL /* #define FAILOVER_PROTOCOL */
/* Define this if you want DNS update functionality to be available. */ /* Define this if you want DNS update functionality to be available. */
@ -171,7 +171,7 @@
/* Define this if you want to be able to execute external commands /* Define this if you want to be able to execute external commands
during conditional evaluation. */ during conditional evaluation. */
#define ENABLE_EXECUTE /* #define ENABLE_EXECUTE */
/* Define this if you aren't debugging and you want to save memory /* Define this if you aren't debugging and you want to save memory
(potentially a _lot_ of memory) by allocating leases in chunks rather (potentially a _lot_ of memory) by allocating leases in chunks rather
@ -182,4 +182,4 @@
/* Define this if you want to be able to save and playback server operational /* Define this if you want to be able to save and playback server operational
traces. */ traces. */
#define TRACING /* #define TRACING */

View File

@ -76,7 +76,7 @@
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
static const char rcsid[] = "$Id: res_init.c,v 1.10 2007/10/01 14:47:35 explorer Exp $"; static const char rcsid[] = "$Id: res_init.c,v 1.11 2008/02/28 21:21:56 dhankins Exp $";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <sys/types.h> #include <sys/types.h>
@ -99,7 +99,6 @@ static const char rcsid[] = "$Id: res_init.c,v 1.10 2007/10/01 14:47:35 explorer
/* Options. Should all be left alone. */ /* Options. Should all be left alone. */
#define RESOLVSORT #define RESOLVSORT
#define RFC1535 #define RFC1535
#define DEBUG
static void res_setoptions (res_state, const char *, const char *); static void res_setoptions (res_state, const char *, const char *);
@ -389,14 +388,12 @@ minires_vinit(res_state statp, int preinit) {
dots--; dots--;
} }
*pp = NULL; *pp = NULL;
#ifdef DEBUG
if (statp->options & RES_DEBUG) { if (statp->options & RES_DEBUG) {
printf(";; res_init()... default dnsrch list:\n"); printf(";; res_init()... default dnsrch list:\n");
for (pp = statp->dnsrch; *pp; pp++) for (pp = statp->dnsrch; *pp; pp++)
printf(";;\t%s\n", *pp); printf(";;\t%s\n", *pp);
printf(";;\t..END..\n"); printf(";;\t..END..\n");
} }
#endif
#endif /* !RFC1535 */ #endif /* !RFC1535 */
} }
@ -411,11 +408,9 @@ res_setoptions(res_state statp, const char *options, const char *source) {
const char *cp = options; const char *cp = options;
int i; int i;
#ifdef DEBUG
if (statp->options & RES_DEBUG) if (statp->options & RES_DEBUG)
printf(";; res_setoptions(\"%s\", \"%s\")...\n", printf(";; res_setoptions(\"%s\", \"%s\")...\n",
options, source); options, source);
#endif
while (*cp) { while (*cp) {
/* skip leading and inner runs of spaces */ /* skip leading and inner runs of spaces */
while (*cp == ' ' || *cp == '\t') while (*cp == ' ' || *cp == '\t')
@ -427,10 +422,8 @@ res_setoptions(res_state statp, const char *options, const char *source) {
statp->ndots = i; statp->ndots = i;
else else
statp->ndots = RES_MAXNDOTS; statp->ndots = RES_MAXNDOTS;
#ifdef DEBUG
if (statp->options & RES_DEBUG) if (statp->options & RES_DEBUG)
printf(";;\tndots=%d\n", statp->ndots); printf(";;\tndots=%d\n", statp->ndots);
#endif
} else if (!strncmp(cp, "timeout:", sizeof("timeout:") - 1)) { } else if (!strncmp(cp, "timeout:", sizeof("timeout:") - 1)) {
i = atoi(cp + sizeof("timeout:") - 1); i = atoi(cp + sizeof("timeout:") - 1);
if (i <= RES_MAXRETRANS) if (i <= RES_MAXRETRANS)
@ -444,14 +437,12 @@ res_setoptions(res_state statp, const char *options, const char *source) {
else else
statp->retry = RES_MAXRETRY; statp->retry = RES_MAXRETRY;
} else if (!strncmp(cp, "debug", sizeof("debug") - 1)) { } else if (!strncmp(cp, "debug", sizeof("debug") - 1)) {
#ifdef DEBUG
if (!(statp->options & RES_DEBUG)) { if (!(statp->options & RES_DEBUG)) {
printf(";; res_setoptions(\"%s\", \"%s\")..\n", printf(";; res_setoptions(\"%s\", \"%s\")..\n",
options, source); options, source);
statp->options |= RES_DEBUG; statp->options |= RES_DEBUG;
} }
printf(";;\tdebug\n"); printf(";;\tdebug\n");
#endif
} else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) { } else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) {
statp->options |= RES_USE_INET6; statp->options |= RES_USE_INET6;
} else if (!strncmp(cp, "rotate", sizeof("rotate") - 1)) { } else if (!strncmp(cp, "rotate", sizeof("rotate") - 1)) {

View File

@ -27,7 +27,7 @@
*/ */
#if !defined(lint) && !defined(SABER) #if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: res_mkupdate.c,v 1.11 2007/07/13 06:43:42 shane Exp $"; static const char rcsid[] = "$Id: res_mkupdate.c,v 1.12 2008/02/28 21:21:56 dhankins Exp $";
#endif /* not lint */ #endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
@ -50,7 +50,6 @@ static const char rcsid[] = "$Id: res_mkupdate.c,v 1.11 2007/07/13 06:43:42 shan
#include "arpa/nameser.h" #include "arpa/nameser.h"
/* Options. Leave them on. */ /* Options. Leave them on. */
#define DEBUG
#define MAXPORT 1024 #define MAXPORT 1024
static int getnum_str(const u_char **, const u_char *); static int getnum_str(const u_char **, const u_char *);

View File

@ -76,7 +76,7 @@
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: res_query.c,v 1.8 2007/09/05 17:32:10 dhankins Exp $"; static const char rcsid[] = "$Id: res_query.c,v 1.9 2008/02/28 21:21:56 dhankins Exp $";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <sys/types.h> #include <sys/types.h>
@ -95,8 +95,6 @@ static const char rcsid[] = "$Id: res_query.c,v 1.8 2007/09/05 17:32:10 dhankins
#include "arpa/nameser.h" #include "arpa/nameser.h"
/* Options. Leave them on. */ /* Options. Leave them on. */
#define DEBUG
#if PACKETSZ > 1024 #if PACKETSZ > 1024
#define MAXPACKET PACKETSZ #define MAXPACKET PACKETSZ
#else #else
@ -128,37 +126,29 @@ res_nquery(res_state statp,
hp->rcode = NOERROR; /* default */ hp->rcode = NOERROR; /* default */
#ifdef DEBUG
if (statp->options & RES_DEBUG) if (statp->options & RES_DEBUG)
printf(";; res_query(%s, %d, %d)\n", name, class, type); printf(";; res_query(%s, %d, %d)\n", name, class, type);
#endif
rcode = res_nmkquery(statp, QUERY, name, class, type, NULL, 0, NULL, rcode = res_nmkquery(statp, QUERY, name, class, type, NULL, 0, NULL,
buf, sizeof(buf), &n); buf, sizeof(buf), &n);
if (rcode != ISC_R_SUCCESS) { if (rcode != ISC_R_SUCCESS) {
#ifdef DEBUG
if (statp->options & RES_DEBUG) if (statp->options & RES_DEBUG)
printf(";; res_query: mkquery failed\n"); printf(";; res_query: mkquery failed\n");
#endif
RES_SET_H_ERRNO(statp, NO_RECOVERY); RES_SET_H_ERRNO(statp, NO_RECOVERY);
return rcode; return rcode;
} }
rcode = res_nsend(statp, buf, n, answer, anslen, &n); rcode = res_nsend(statp, buf, n, answer, anslen, &n);
if (rcode != ISC_R_SUCCESS) { if (rcode != ISC_R_SUCCESS) {
#ifdef DEBUG
if (statp->options & RES_DEBUG) if (statp->options & RES_DEBUG)
printf(";; res_query: send error\n"); printf(";; res_query: send error\n");
#endif
RES_SET_H_ERRNO(statp, TRY_AGAIN); RES_SET_H_ERRNO(statp, TRY_AGAIN);
return rcode; return rcode;
} }
if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) { if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
#ifdef DEBUG
if (statp->options & RES_DEBUG) if (statp->options & RES_DEBUG)
printf(";; rcode = %d, ancount=%d\n", hp->rcode, printf(";; rcode = %d, ancount=%d\n", hp->rcode,
ntohs(hp->ancount)); ntohs(hp->ancount));
#endif
switch (hp->rcode) { switch (hp->rcode) {
case NXDOMAIN: case NXDOMAIN:
RES_SET_H_ERRNO(statp, HOST_NOT_FOUND); RES_SET_H_ERRNO(statp, HOST_NOT_FOUND);
@ -347,11 +337,9 @@ res_nquerydomain(res_state statp,
const char *longname = nbuf; const char *longname = nbuf;
int n, d; int n, d;
#ifdef DEBUG
if (statp->options & RES_DEBUG) if (statp->options & RES_DEBUG)
printf(";; res_nquerydomain(%s, %s, %d, %d)\n", printf(";; res_nquerydomain(%s, %s, %d, %d)\n",
name, domain?domain:"<Nil>", class, type); name, domain?domain:"<Nil>", class, type);
#endif
if (domain == NULL) { if (domain == NULL) {
/* /*
* Check for trailing '.'; * Check for trailing '.';

View File

@ -442,7 +442,6 @@ isc_result_t omapi_connection_writer (omapi_object_t *h)
unsigned first_byte; unsigned first_byte;
omapi_buffer_t *buffer; omapi_buffer_t *buffer;
omapi_connection_object_t *c; omapi_connection_object_t *c;
isc_result_t status;
if (!h || h -> type != omapi_type_connection) if (!h || h -> type != omapi_type_connection)
return ISC_R_INVALIDARG; return ISC_R_INVALIDARG;
@ -504,6 +503,7 @@ isc_result_t omapi_connection_writer (omapi_object_t *h)
#if defined (TRACING) #if defined (TRACING)
if (trace_record ()) { if (trace_record ()) {
isc_result_t status;
trace_iov_t iov [2]; trace_iov_t iov [2];
int32_t connect_index; int32_t connect_index;

View File

@ -437,7 +437,6 @@ isc_result_t omapi_disconnect (omapi_object_t *h,
int force) int force)
{ {
omapi_connection_object_t *c; omapi_connection_object_t *c;
isc_result_t status;
#ifdef DEBUG_PROTOCOL #ifdef DEBUG_PROTOCOL
log_debug ("omapi_disconnect(%s)", force ? "force" : ""); log_debug ("omapi_disconnect(%s)", force ? "force" : "");
@ -449,6 +448,7 @@ isc_result_t omapi_disconnect (omapi_object_t *h,
#if defined (TRACING) #if defined (TRACING)
if (trace_record ()) { if (trace_record ()) {
isc_result_t status;
int32_t index; int32_t index;
index = htonl (c -> index); index = htonl (c -> index);

View File

@ -38,6 +38,7 @@
#include <errno.h> #include <errno.h>
#if defined(TRACING)
static void trace_mr_output_input (trace_type_t *, unsigned, char *); static void trace_mr_output_input (trace_type_t *, unsigned, char *);
static void trace_mr_output_stop (trace_type_t *); static void trace_mr_output_stop (trace_type_t *);
static void trace_mr_input_input (trace_type_t *, unsigned, char *); static void trace_mr_input_input (trace_type_t *, unsigned, char *);
@ -46,6 +47,7 @@ static void trace_mr_statp_input (trace_type_t *, unsigned, char *);
static void trace_mr_statp_stop (trace_type_t *); static void trace_mr_statp_stop (trace_type_t *);
static void trace_mr_randomid_input (trace_type_t *, unsigned, char *); static void trace_mr_randomid_input (trace_type_t *, unsigned, char *);
static void trace_mr_randomid_stop (trace_type_t *); static void trace_mr_randomid_stop (trace_type_t *);
#endif /* TRACING */
trace_type_t *trace_mr_output; trace_type_t *trace_mr_output;
trace_type_t *trace_mr_input; trace_type_t *trace_mr_input;
trace_type_t *trace_mr_statp; trace_type_t *trace_mr_statp;
@ -404,9 +406,9 @@ int trace_mr_select (int s, fd_set *r, fd_set *w, fd_set *x, struct timeval *t)
unsigned int trace_mr_res_randomid (unsigned int oldid) unsigned int trace_mr_res_randomid (unsigned int oldid)
{ {
u_int32_t id;
int rid = oldid; int rid = oldid;
#if defined (TRACING) #if defined (TRACING)
u_int32_t id;
unsigned buflen = 0; unsigned buflen = 0;
char *buf = (char *)0; char *buf = (char *)0;
isc_result_t status; isc_result_t status;

View File

@ -796,7 +796,9 @@ void dhcprelease (packet, ms_nulltp)
release_lease (lease, packet); release_lease (lease, packet);
} }
log_info ("%s", msgbuf); log_info ("%s", msgbuf);
#if defined(FAILOVER_PROTOCOL)
out: out:
#endif
if (lease) if (lease)
lease_dereference (&lease, MDL); lease_dereference (&lease, MDL);
} }
@ -918,8 +920,10 @@ void dhcpdecline (packet, ms_nulltp)
if (!ignorep) if (!ignorep)
log_info ("%s: %s", msgbuf, status); log_info ("%s: %s", msgbuf, status);
#if defined(FAILOVER_PROTOCOL)
out: out:
#endif
if (options) if (options)
option_state_dereference (&options, MDL); option_state_dereference (&options, MDL);
if (lease) if (lease)
@ -3153,6 +3157,7 @@ int find_lease (struct lease **lp,
struct data_string client_identifier; struct data_string client_identifier;
struct hardware h; struct hardware h;
#if defined(FAILOVER_PROTOCOL)
/* Quick check to see if the peer has leases. */ /* Quick check to see if the peer has leases. */
if (peer_has_leases) { if (peer_has_leases) {
struct pool *pool; struct pool *pool;
@ -3168,6 +3173,7 @@ int find_lease (struct lease **lp,
} }
} }
} }
#endif /* FAILOVER_PROTOCOL */
if (packet -> raw -> ciaddr.s_addr) { if (packet -> raw -> ciaddr.s_addr) {
cip.len = 4; cip.len = 4;
@ -3487,7 +3493,9 @@ int find_lease (struct lease **lp,
is not active, and is not ours to reallocate, forget about it. */ is not active, and is not ours to reallocate, forget about it. */
if (ip_lease && (uid_lease || hw_lease) && if (ip_lease && (uid_lease || hw_lease) &&
ip_lease -> binding_state != FTS_ACTIVE && ip_lease -> binding_state != FTS_ACTIVE &&
#if defined(FAILOVER_PROTOCOL)
!lease_mine_to_reallocate (ip_lease) && !lease_mine_to_reallocate (ip_lease) &&
#endif
packet -> packet_type == DHCPDISCOVER) { packet -> packet_type == DHCPDISCOVER) {
#if defined (DEBUG_FIND_LEASE) #if defined (DEBUG_FIND_LEASE)
log_info ("ip lease not ours to offer."); log_info ("ip lease not ours to offer.");

View File

@ -1342,8 +1342,8 @@ isc_result_t dhcp_io_shutdown (omapi_object_t *obj, void *foo)
static isc_result_t dhcp_io_shutdown_countdown (void *vlp) static isc_result_t dhcp_io_shutdown_countdown (void *vlp)
{ {
dhcp_failover_state_t *state;
#if defined (FAILOVER_PROTOCOL) #if defined (FAILOVER_PROTOCOL)
dhcp_failover_state_t *state;
int failover_connection_count = 0; int failover_connection_count = 0;
#endif #endif
struct timeval tv; struct timeval tv;

View File

@ -1515,6 +1515,7 @@ void make_binding_state_transition (struct lease *lease)
case FTS_ABANDONED: case FTS_ABANDONED:
case FTS_RESET: case FTS_RESET:
lease -> next_binding_state = FTS_FREE; lease -> next_binding_state = FTS_FREE;
#if defined(FAILOVER_PROTOCOL)
/* If we are not in partner_down, leases don't go from /* If we are not in partner_down, leases don't go from
EXPIRED to FREE on a timeout - only on an update. EXPIRED to FREE on a timeout - only on an update.
If we're in partner_down, they expire at mclt past If we're in partner_down, they expire at mclt past
@ -1524,6 +1525,7 @@ void make_binding_state_transition (struct lease *lease)
lease -> tsfp = lease -> tsfp =
(lease -> pool -> failover_peer -> me.stos + (lease -> pool -> failover_peer -> me.stos +
lease -> pool -> failover_peer -> mclt); lease -> pool -> failover_peer -> mclt);
#endif /* FAILOVER_PROTOCOL */
break; break;
case FTS_FREE: case FTS_FREE: