Commit 66cebfcb authored by David Hankins's avatar David Hankins
Browse files

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

  as failover, server tracing, debugging, and the execute() command.
  [ISC-Bugs #17678]
parent 3004d0a3
......@@ -54,6 +54,9 @@ work on other platforms. Please report any problems and suggested fixes to
via two ./configure parameters, --enable-paranoia and
--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)
- Added DHCPv6 rapid commit support.
......
......@@ -729,8 +729,10 @@ void write_statements (file, statements, indent)
struct executable_statement *statements;
int indent;
{
struct executable_statement *r, *x;
#if defined ENABLE_EXECUTE
struct expression *expr;
#endif
struct executable_statement *r, *x;
const char *s, *t, *dot;
int col;
......
......@@ -2017,13 +2017,15 @@ int parse_executable_statement (result, cfile, lose, case_context)
int *lose;
enum expression_context case_context;
{
#if defined(ENABLE_EXECUTE)
unsigned len;
struct expression **ep;
#endif
enum dhcp_token token;
const char *val;
unsigned len;
struct class *cta;
struct option *option=NULL;
struct option_cache *cache;
struct expression **ep;
int known;
int flag;
int i;
......
......@@ -30,10 +30,72 @@ AC_DEFINE_UNQUOTED([DHCP_BYTE_ORDER], [$byte_order],
[Define to BIG_ENDIAN for MSB (Motorola or SPARC 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_HELP_STRING([--enable-dhcpv6],
[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
AC_DEFINE([DHCPv6], [1],
[Define to 1 to include DHCPv6 support.])
......
......@@ -94,7 +94,7 @@
/* Define this if you want DHCP failover protocol support in the DHCP
server. */
#define FAILOVER_PROTOCOL
/* #define FAILOVER_PROTOCOL */
/* 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
during conditional evaluation. */
#define ENABLE_EXECUTE
/* #define ENABLE_EXECUTE */
/* Define this if you aren't debugging and you want to save memory
(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
traces. */
#define TRACING
/* #define TRACING */
......@@ -76,7 +76,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
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 */
#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. */
#define RESOLVSORT
#define RFC1535
#define DEBUG
static void res_setoptions (res_state, const char *, const char *);
......@@ -389,14 +388,12 @@ minires_vinit(res_state statp, int preinit) {
dots--;
}
*pp = NULL;
#ifdef DEBUG
if (statp->options & RES_DEBUG) {
printf(";; res_init()... default dnsrch list:\n");
for (pp = statp->dnsrch; *pp; pp++)
printf(";;\t%s\n", *pp);
printf(";;\t..END..\n");
}
#endif
#endif /* !RFC1535 */
}
......@@ -411,11 +408,9 @@ res_setoptions(res_state statp, const char *options, const char *source) {
const char *cp = options;
int i;
#ifdef DEBUG
if (statp->options & RES_DEBUG)
printf(";; res_setoptions(\"%s\", \"%s\")...\n",
options, source);
#endif
while (*cp) {
/* skip leading and inner runs of spaces */
while (*cp == ' ' || *cp == '\t')
......@@ -427,10 +422,8 @@ res_setoptions(res_state statp, const char *options, const char *source) {
statp->ndots = i;
else
statp->ndots = RES_MAXNDOTS;
#ifdef DEBUG
if (statp->options & RES_DEBUG)
printf(";;\tndots=%d\n", statp->ndots);
#endif
} else if (!strncmp(cp, "timeout:", sizeof("timeout:") - 1)) {
i = atoi(cp + sizeof("timeout:") - 1);
if (i <= RES_MAXRETRANS)
......@@ -444,14 +437,12 @@ res_setoptions(res_state statp, const char *options, const char *source) {
else
statp->retry = RES_MAXRETRY;
} else if (!strncmp(cp, "debug", sizeof("debug") - 1)) {
#ifdef DEBUG
if (!(statp->options & RES_DEBUG)) {
printf(";; res_setoptions(\"%s\", \"%s\")..\n",
options, source);
statp->options |= RES_DEBUG;
}
printf(";;\tdebug\n");
#endif
} else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) {
statp->options |= RES_USE_INET6;
} else if (!strncmp(cp, "rotate", sizeof("rotate") - 1)) {
......
......@@ -27,7 +27,7 @@
*/
#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 */
#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"
/* Options. Leave them on. */
#define DEBUG
#define MAXPORT 1024
static int getnum_str(const u_char **, const u_char *);
......
......@@ -76,7 +76,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
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 */
#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"
/* Options. Leave them on. */
#define DEBUG
#if PACKETSZ > 1024
#define MAXPACKET PACKETSZ
#else
......@@ -128,37 +126,29 @@ res_nquery(res_state statp,
hp->rcode = NOERROR; /* default */
#ifdef DEBUG
if (statp->options & RES_DEBUG)
printf(";; res_query(%s, %d, %d)\n", name, class, type);
#endif
rcode = res_nmkquery(statp, QUERY, name, class, type, NULL, 0, NULL,
buf, sizeof(buf), &n);
if (rcode != ISC_R_SUCCESS) {
#ifdef DEBUG
if (statp->options & RES_DEBUG)
printf(";; res_query: mkquery failed\n");
#endif
RES_SET_H_ERRNO(statp, NO_RECOVERY);
return rcode;
}
rcode = res_nsend(statp, buf, n, answer, anslen, &n);
if (rcode != ISC_R_SUCCESS) {
#ifdef DEBUG
if (statp->options & RES_DEBUG)
printf(";; res_query: send error\n");
#endif
RES_SET_H_ERRNO(statp, TRY_AGAIN);
return rcode;
}
if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
#ifdef DEBUG
if (statp->options & RES_DEBUG)
printf(";; rcode = %d, ancount=%d\n", hp->rcode,
ntohs(hp->ancount));
#endif
switch (hp->rcode) {
case NXDOMAIN:
RES_SET_H_ERRNO(statp, HOST_NOT_FOUND);
......@@ -347,11 +337,9 @@ res_nquerydomain(res_state statp,
const char *longname = nbuf;
int n, d;
#ifdef DEBUG
if (statp->options & RES_DEBUG)
printf(";; res_nquerydomain(%s, %s, %d, %d)\n",
name, domain?domain:"<Nil>", class, type);
#endif
if (domain == NULL) {
/*
* Check for trailing '.';
......
......@@ -442,7 +442,6 @@ isc_result_t omapi_connection_writer (omapi_object_t *h)
unsigned first_byte;
omapi_buffer_t *buffer;
omapi_connection_object_t *c;
isc_result_t status;
if (!h || h -> type != omapi_type_connection)
return ISC_R_INVALIDARG;
......@@ -504,6 +503,7 @@ isc_result_t omapi_connection_writer (omapi_object_t *h)
#if defined (TRACING)
if (trace_record ()) {
isc_result_t status;
trace_iov_t iov [2];
int32_t connect_index;
......
......@@ -437,7 +437,6 @@ isc_result_t omapi_disconnect (omapi_object_t *h,
int force)
{
omapi_connection_object_t *c;
isc_result_t status;
#ifdef DEBUG_PROTOCOL
log_debug ("omapi_disconnect(%s)", force ? "force" : "");
......@@ -449,6 +448,7 @@ isc_result_t omapi_disconnect (omapi_object_t *h,
#if defined (TRACING)
if (trace_record ()) {
isc_result_t status;
int32_t index;
index = htonl (c -> index);
......
......@@ -38,6 +38,7 @@
#include <errno.h>
#if defined(TRACING)
static void trace_mr_output_input (trace_type_t *, unsigned, char *);
static void trace_mr_output_stop (trace_type_t *);
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_randomid_input (trace_type_t *, unsigned, char *);
static void trace_mr_randomid_stop (trace_type_t *);
#endif /* TRACING */
trace_type_t *trace_mr_output;
trace_type_t *trace_mr_input;
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)
{
u_int32_t id;
int rid = oldid;
#if defined (TRACING)
u_int32_t id;
unsigned buflen = 0;
char *buf = (char *)0;
isc_result_t status;
......
......@@ -796,7 +796,9 @@ void dhcprelease (packet, ms_nulltp)
release_lease (lease, packet);
}
log_info ("%s", msgbuf);
#if defined(FAILOVER_PROTOCOL)
out:
#endif
if (lease)
lease_dereference (&lease, MDL);
}
......@@ -918,8 +920,10 @@ void dhcpdecline (packet, ms_nulltp)
if (!ignorep)
log_info ("%s: %s", msgbuf, status);
#if defined(FAILOVER_PROTOCOL)
out:
#endif
if (options)
option_state_dereference (&options, MDL);
if (lease)
......@@ -3153,6 +3157,7 @@ int find_lease (struct lease **lp,
struct data_string client_identifier;
struct hardware h;
#if defined(FAILOVER_PROTOCOL)
/* Quick check to see if the peer has leases. */
if (peer_has_leases) {
struct pool *pool;
......@@ -3168,6 +3173,7 @@ int find_lease (struct lease **lp,
}
}
}
#endif /* FAILOVER_PROTOCOL */
if (packet -> raw -> ciaddr.s_addr) {
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. */
if (ip_lease && (uid_lease || hw_lease) &&
ip_lease -> binding_state != FTS_ACTIVE &&
#if defined(FAILOVER_PROTOCOL)
!lease_mine_to_reallocate (ip_lease) &&
#endif
packet -> packet_type == DHCPDISCOVER) {
#if defined (DEBUG_FIND_LEASE)
log_info ("ip lease not ours to offer.");
......
......@@ -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)
{
dhcp_failover_state_t *state;
#if defined (FAILOVER_PROTOCOL)
dhcp_failover_state_t *state;
int failover_connection_count = 0;
#endif
struct timeval tv;
......
......@@ -1515,6 +1515,7 @@ void make_binding_state_transition (struct lease *lease)
case FTS_ABANDONED:
case FTS_RESET:
lease -> next_binding_state = FTS_FREE;
#if defined(FAILOVER_PROTOCOL)
/* If we are not in partner_down, leases don't go from
EXPIRED to FREE on a timeout - only on an update.
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 -> pool -> failover_peer -> me.stos +
lease -> pool -> failover_peer -> mclt);
#endif /* FAILOVER_PROTOCOL */
break;
case FTS_FREE:
......
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