summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Lemon <source@isc.org>2001-08-10 10:50:50 +0000
committerTed Lemon <source@isc.org>2001-08-10 10:50:50 +0000
commita609e69bba4c227b52532a28d49f32f97395a56e (patch)
tree2b8e35b79518e25c5f9d19f9321dfdb0749c3589
parenteaf0b3020b3e558da321d7ad099bc1fc5a813750 (diff)
downloadisc-dhcp-a609e69bba4c227b52532a28d49f32f97395a56e.tar.gz
sync with branch
-rw-r--r--client/dhclient.c13
-rwxr-xr-xclient/scripts/linux8
-rw-r--r--common/dhcp-eval.527
-rw-r--r--common/execute.c14
-rw-r--r--common/options.c31
-rw-r--r--common/print.c7
-rw-r--r--includes/dhcpd.h4
-rw-r--r--includes/failover.h2
-rw-r--r--includes/version.h2
-rw-r--r--omapip/hash.c4
-rw-r--r--omapip/protocol.c18
-rw-r--r--server/confpars.c7
-rw-r--r--server/dhcp.c19
-rw-r--r--server/dhcpd.conf.52
-rw-r--r--server/failover.c22
-rw-r--r--server/omapi.c4
16 files changed, 107 insertions, 77 deletions
diff --git a/client/dhclient.c b/client/dhclient.c
index e3667c74..26d84601 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -41,7 +41,7 @@
#ifndef lint
static char ocopyright[] =
-"$Id: dhclient.c,v 1.130 2001/06/27 00:29:29 mellon Exp $ Copyright (c) 1995-2001 Internet Software Consortium. All rights reserved.\n";
+"$Id: dhclient.c,v 1.131 2001/08/10 10:47:33 mellon Exp $ Copyright (c) 1995-2001 Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -2654,6 +2654,7 @@ void go_daemon ()
{
static int state = 0;
int pid;
+ int i;
/* Don't become a daemon if the user requested otherwise. */
if (no_daemon) {
@@ -2682,6 +2683,16 @@ void go_daemon ()
close(1);
close(2);
+ /* Reopen them on /dev/null. */
+ i = open ("/dev/null", O_RDWR);
+ if (i == 0)
+ i = open ("/dev/null", O_RDWR);
+ if (i == 1) {
+ i = open ("/dev/null", O_RDWR);
+ log_perror = 0; /* No sense logging to /dev/null. */
+ } else if (i != -1)
+ close (i);
+
write_client_pid_file ();
}
diff --git a/client/scripts/linux b/client/scripts/linux
index 71d00ab3..6598b90e 100755
--- a/client/scripts/linux
+++ b/client/scripts/linux
@@ -90,7 +90,7 @@ if [ x$reason = xPREINIT ]; then
# Add route to make broadcast work. Do not omit netmask.
route add default dev $interface netmask 0.0.0.0
else
- ifconfig $interface up
+ ifconfig $interface 0 up
fi
# We need to give the kernel some time to get the interface up.
@@ -122,7 +122,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
# IP address changed. Bringing down the interface will delete all routes,
# and clear the ARP cache.
- ifconfig $interface inet down
+ ifconfig $interface inet 0 down
fi
if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
@@ -157,7 +157,7 @@ if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
fi
if [ x$old_ip_address != x ]; then
# Shut down interface, which will delete routes and clear arp cache.
- ifconfig $interface inet down
+ ifconfig $interface inet 0 down
fi
if [ x$alias_ip_address != x ]; then
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
@@ -190,7 +190,7 @@ if [ x$reason = xTIMEOUT ]; then
make_resolv_conf
exit_with_hooks 0
fi
- ifconfig $interface inet down
+ ifconfig $interface inet 0 down
exit_with_hooks 1
fi
diff --git a/common/dhcp-eval.5 b/common/dhcp-eval.5
index 1721c608..3b80ad87 100644
--- a/common/dhcp-eval.5
+++ b/common/dhcp-eval.5
@@ -409,33 +409,6 @@ Rebind - DHCP client is in the REBINDING state - it has an IP address,
and is trying to contact any server to renew it. The next message to
be sent will be a DHCPREQUEST, which will be broadcast.
.RE
-.SH
-FUNCTIONS
-Functions may be defined with the \fBdefine\fR statement. A function
-definition may occur anywhere that regular statement may appear.
-Functions occupy the same namespace as variables, and obey the same
-scoping rules.
-.PP
-.nf
-define set-hostname(prefix) {
- option host-name
- concat (prefix, binary-to-ascii (16, 32, "", leased-address));
-}
-.fi
-.PP
-A function may return a value when used in an expression with the
-\fBreturn\fR statement. A function with no return statement has a
-value of null.
-.PP
-.nf
-define make-hostname(prefix) {
- return concat (prefix, binary-to-ascii (16, 32, "", leased-address));
-}
-
-option host-name make-hostname("dyn-");
-.fi
-.PP
-.RE
.SH REFERENCE: LOGGING
Logging statements may be used to send information to the standard logging
channels. A logging statement includes an optional priority (\fBfatal\fR,
diff --git a/common/execute.c b/common/execute.c
index aeaac1b9..1287e9e5 100644
--- a/common/execute.c
+++ b/common/execute.c
@@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
-"$Id: execute.c,v 1.45 2001/06/27 00:29:48 mellon Exp $ Copyright (c) 1998-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: execute.c,v 1.46 2001/08/10 10:48:58 mellon Exp $ Copyright (c) 1998-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -999,10 +999,10 @@ int executable_statement_foreach (struct executable_statement *stmt,
case null_statement:
break;
case if_statement:
- if (executable_statement_foreach (stmt -> data.ie.tc,
+ if (executable_statement_foreach (foo -> data.ie.tc,
callback, vp, 1))
ok = 1;
- if (executable_statement_foreach (stmt -> data.ie.fc,
+ if (executable_statement_foreach (foo -> data.ie.fc,
callback, vp, 1))
ok = 1;
break;
@@ -1024,17 +1024,17 @@ int executable_statement_foreach (struct executable_statement *stmt,
break;
case statements_statement:
if ((executable_statement_foreach
- (stmt -> data.statements, callback, vp, condp)))
+ (foo -> data.statements, callback, vp, condp)))
ok = 1;
break;
case on_statement:
if ((executable_statement_foreach
- (stmt -> data.on.statements, callback, vp, 1)))
+ (foo -> data.on.statements, callback, vp, 1)))
ok = 1;
break;
case switch_statement:
if ((executable_statement_foreach
- (stmt -> data.s_switch.statements, callback, vp, 1)))
+ (foo -> data.s_switch.statements, callback, vp, 1)))
ok = 1;
break;
case case_statement:
@@ -1047,7 +1047,7 @@ int executable_statement_foreach (struct executable_statement *stmt,
break;
case let_statement:
if ((executable_statement_foreach
- (stmt -> data.let.statements, callback, vp, 0)))
+ (foo -> data.let.statements, callback, vp, 0)))
ok = 1;
break;
case define_statement:
diff --git a/common/options.c b/common/options.c
index 25c62422..0e7a0886 100644
--- a/common/options.c
+++ b/common/options.c
@@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
-"$Id: options.c,v 1.86 2001/06/27 00:29:54 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
+"$Id: options.c,v 1.87 2001/08/10 10:49:00 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#define DHCP_OPTION_DATA
@@ -82,13 +82,34 @@ int parse_options (packet)
&packet -> raw -> options [4],
(packet -> packet_length -
DHCP_FIXED_NON_UDP - 4),
- &dhcp_universe))
- return 0;
+ &dhcp_universe)) {
+
+ /* STSN servers have a bug where they send a mangled
+ domain-name option, and whatever is beyond that in
+ the packet is junk. Microsoft clients accept this,
+ which is probably why whoever implemented the STSN
+ server isn't aware of the problem yet. To work around
+ this, we will accept corrupt packets from the server if
+ they contain a valid DHCP_MESSAGE_TYPE option, but
+ will not accept any corrupt client packets (the ISC DHCP
+ server is sufficiently widely used that it is probably
+ beneficial for it to be picky) and will not accept
+ packets whose type can't be determined. */
+
+ if ((op = lookup_option (&dhcp_universe, packet -> options,
+ DHO_DHCP_MESSAGE_TYPE))) {
+ if (!op -> data.data ||
+ (op -> data.data [0] != DHCPOFFER &&
+ op -> data.data [0] != DHCPACK &&
+ op -> data.data [0] != DHCPNAK))
+ return 0;
+ } else
+ return 0;
+ }
/* If we parsed a DHCP Option Overload option, parse more
options out of the buffer(s) containing them. */
- if (packet -> options_valid &&
- (op = lookup_option (&dhcp_universe, packet -> options,
+ if ((op = lookup_option (&dhcp_universe, packet -> options,
DHO_DHCP_OPTION_OVERLOAD))) {
if (op -> data.data [0] & 1) {
if (!parse_option_buffer
diff --git a/common/print.c b/common/print.c
index 807a53c7..5f0c9f9d 100644
--- a/common/print.c
+++ b/common/print.c
@@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
-"$Id: print.c,v 1.54 2001/06/27 00:29:57 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
+"$Id: print.c,v 1.55 2001/08/10 10:49:01 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -1292,7 +1292,10 @@ void print_dns_status (int status, ns_updque *uq)
strcpy (s, "empty update");
s += strlen (s);
}
- errorp = 1;
+ if (status == NOERROR)
+ errorp = 0;
+ else
+ errorp = 1;
en = isc_result_totext (status);
#if 0
switch (status) {
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
index acbe68aa..b4b8ac69 100644
--- a/includes/dhcpd.h
+++ b/includes/dhcpd.h
@@ -592,9 +592,9 @@ struct collection {
/* XXX classes must be reference-counted. */
struct class {
OMAPI_OBJECT_PREAMBLE;
- struct class *nic; /* Next in collection. */
+ struct class *nic; /* Next in collection. */
struct class *superclass; /* Set for spawned classes only. */
- char *name; /* Not set for spawned classes. */
+ char *name; /* Not set for spawned classes. */
/* A class may be configured to permit a limited number of leases. */
int lease_limit;
diff --git a/includes/failover.h b/includes/failover.h
index 26854476..e27a9115 100644
--- a/includes/failover.h
+++ b/includes/failover.h
@@ -314,6 +314,8 @@ typedef struct _dhcp_failover_state {
failover_message_t *toack_queue_tail;
int pending_acks; /* Number of messages in the toack
queue. */
+ int pool_count; /* Number of pools referencing this
+ failover state object. */
} dhcp_failover_state_t;
#define DHCP_FAILOVER_VERSION 1
diff --git a/includes/version.h b/includes/version.h
index 193122bc..6bfb5830 100644
--- a/includes/version.h
+++ b/includes/version.h
@@ -1,3 +1,3 @@
/* Current version of ISC DHCP Distribution. */
-#define DHCP_VERSION "V3.0rc8pl2"
+#define DHCP_VERSION "V3.1-pre"
diff --git a/omapip/hash.c b/omapip/hash.c
index 58aea60e..da7b25e8 100644
--- a/omapip/hash.c
+++ b/omapip/hash.c
@@ -3,7 +3,7 @@
Routines for manipulating hash tables... */
/*
- * Copyright (c) 1995-2001 Internet Software Consortium.
+ * Copyright (c) 1995-2000 Internet Software Consortium.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
-"$Id: hash.c,v 1.3 2001/06/27 00:30:48 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
+"$Id: hash.c,v 1.4 2001/08/10 10:50:22 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include <omapip/omapip_p.h>
diff --git a/omapip/protocol.c b/omapip/protocol.c
index 8a5890a7..6237f2a7 100644
--- a/omapip/protocol.c
+++ b/omapip/protocol.c
@@ -401,23 +401,27 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h,
}
/* If we get a disconnect, dump memory usage. */
- if (!strcmp (name, "disconnect")
-#if defined (DEBUG_MEMORY_LEAKAGE)
- && connect_outstanding != 0xBEADCAFE
-#endif
- ) {
+ if (!strcmp (name, "disconnect")) {
#if defined (DEBUG_MEMORY_LEAKAGE)
+ if (connect_outstanding != 0xBEADCAFE) {
log_info ("generation %ld: %ld new, %ld outstanding, %ld%s",
dmalloc_generation,
dmalloc_outstanding - previous_outstanding,
dmalloc_outstanding, dmalloc_longterm, " long-term");
+ }
#endif
#if defined (DEBUG_MEMORY_LEAKAGE)
- dmalloc_dump_outstanding ();
+ dmalloc_dump_outstanding ();
#endif
#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
- dump_rc_history (0);
+ dump_rc_history ();
#endif
+ for (m = omapi_registered_messages; m; m = m -> next) {
+ if (m -> protocol_object == p) {
+ if (m -> object)
+ omapi_signal (m -> object, "disconnect");
+ }
+ }
}
/* Not a signal we recognize? */
diff --git a/server/confpars.c b/server/confpars.c
index 7c3d4512..75219607 100644
--- a/server/confpars.c
+++ b/server/confpars.c
@@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
-"$Id: confpars.c,v 1.146 2001/07/10 20:36:02 brister Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
+"$Id: confpars.c,v 1.147 2001/08/10 10:50:44 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -1286,6 +1286,8 @@ void parse_pool_statement (cfile, group, type)
parse_warn (cfile,
"failover peer %s: %s", val,
isc_result_totext (status));
+ else
+ pool -> failover_peer -> pool_count++;
parse_semi (cfile);
break;
#endif
@@ -1851,7 +1853,7 @@ int parse_class_declaration (cp, cfile, group, type)
}
/* Save the name, if there is one. */
- class -> name = (char *)name;
+ class -> name = name;
}
if (type == 0 || type == 1 || type == 3)
@@ -2764,6 +2766,7 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
break;
case OPTION:
+ case SUPERSEDE:
noequal = 0;
seenbit = 0;
oc = (struct option_cache *)0;
diff --git a/server/dhcp.c b/server/dhcp.c
index 095d78a7..9a3f0baf 100644
--- a/server/dhcp.c
+++ b/server/dhcp.c
@@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
-"$Id: dhcp.c,v 1.194 2001/06/27 00:31:07 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhcp.c,v 1.195 2001/08/10 10:50:45 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -2919,6 +2919,7 @@ int find_lease (struct lease **lp,
be two "free" leases for the same uid, but only one of
them that's available for this failover peer to allocate. */
if (uid_lease -> binding_state != FTS_ACTIVE &&
+ uid_lease -> binding_state != FTS_BOOTP &&
!lease_mine_to_reallocate (uid_lease)) {
#if defined (DEBUG_FIND_LEASE)
log_info ("not mine to allocate: %s",
@@ -2982,6 +2983,7 @@ int find_lease (struct lease **lp,
be two "free" leases for the same uid, but only one of
them that's available for this failover peer to allocate. */
if (hw_lease -> binding_state != FTS_ACTIVE &&
+ hw_lease -> binding_state != FTS_BOOTP &&
!lease_mine_to_reallocate (hw_lease)) {
#if defined (DEBUG_FIND_LEASE)
log_info ("not mine to allocate: %s",
@@ -3114,6 +3116,7 @@ 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 &&
+ ip_lease -> binding_state != FTS_BOOTP &&
!lease_mine_to_reallocate (ip_lease) &&
packet -> packet_type == DHCPDISCOVER) {
#if defined (DEBUG_FIND_LEASE)
@@ -3126,14 +3129,16 @@ int find_lease (struct lease **lp,
on the subnet that matches its uid, pick the one that
it asked for and (if we can) free the other. */
if (ip_lease &&
- ip_lease -> binding_state == FTS_ACTIVE &&
+ (ip_lease -> binding_state == FTS_ACTIVE ||
+ ip_lease -> binding_state == FTS_BOOTP) &&
ip_lease -> uid && ip_lease != uid_lease) {
if (have_client_identifier &&
(ip_lease -> uid_len == client_identifier.len) &&
!memcmp (client_identifier.data,
ip_lease -> uid, ip_lease -> uid_len)) {
if (uid_lease) {
- if (uid_lease -> binding_state == FTS_ACTIVE) {
+ if (uid_lease -> binding_state == FTS_ACTIVE ||
+ uid_lease -> binding_state == FTS_BOOTP) {
log_error ("client %s has duplicate%s on %s",
(print_hw_addr
(packet -> raw -> htype,
@@ -3147,7 +3152,10 @@ int find_lease (struct lease **lp,
it shouldn't still be using the old
one, so we can free it for allocation. */
if (uid_lease &&
- uid_lease -> binding_state == FTS_ACTIVE &&
+ (uid_lease -> binding_state == FTS_ACTIVE
+ ||
+ uid_lease -> binding_state == FTS_BOOTP)
+ &&
!packet -> raw -> ciaddr.s_addr &&
(share ==
uid_lease -> subnet -> shared_network) &&
@@ -3302,7 +3310,8 @@ int find_lease (struct lease **lp,
if (lease) {
if (!packet -> raw -> ciaddr.s_addr &&
packet -> packet_type == DHCPREQUEST &&
- uid_lease -> binding_state == FTS_ACTIVE)
+ (uid_lease -> binding_state == FTS_ACTIVE ||
+ uid_lease -> binding_state == FTS_BOOTP))
dissociate_lease (uid_lease);
#if defined (DEBUG_FIND_LEASE)
log_info ("not choosing uid lease.");
diff --git a/server/dhcpd.conf.5 b/server/dhcpd.conf.5
index ebb57cfe..f9b3463d 100644
--- a/server/dhcpd.conf.5
+++ b/server/dhcpd.conf.5
@@ -956,7 +956,7 @@ client sends a DHCPDISCOVER message, then the server sends a
DHCPOFFER, then the client sends a DHCPREQUEST, then the server sends
a DHCPACK. In the current version of the server, the server will do
a DNS update after it has received the DHCPREQUEST, and before it has
-sent the DHCPOFFER. It only sends the DNS update if it has not sent
+sent the DHCPACK. It only sends the DNS update if it has not sent
one for the client's address before, in order to minimize the impact
on the DHCP server.
.PP
diff --git a/server/failover.c b/server/failover.c
index 136176a5..6a094efe 100644
--- a/server/failover.c
+++ b/server/failover.c
@@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
-"$Id: failover.c,v 1.56 2001/06/29 18:34:57 mellon Exp $ Copyright (c) 1999-2001 The Internet Software Consortium. All rights reserved.\n";
+"$Id: failover.c,v 1.57 2001/08/10 10:50:49 mellon Exp $ Copyright (c) 1999-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -72,6 +72,15 @@ void dhcp_failover_startup ()
for (state = failover_states; state; state = state -> next) {
dhcp_failover_state_transition (state, "startup");
+ if (state -> pool_count == 0) {
+ log_error ("failover peer declaration with no %s",
+ "referring pools.");
+ log_error ("In order to use failover, you MUST %s",
+ "refer to your main failover declaration");
+ log_error ("in each pool declaration. You MUST %s",
+ "NOT use range declarations outside");
+ log_fatal ("of pool declarations.");
+ }
/* In case the peer is already running, immediately try
to establish a connection with it. */
status = dhcp_failover_link_initiate ((omapi_object_t *)state);
@@ -243,7 +252,7 @@ isc_result_t dhcp_failover_link_initiate (omapi_object_t *h)
local_addr.addrtype = AF_INET;
local_addr.addrlen = sizeof (struct in_addr);
if (!state -> server_identifier.len) {
- log_fatal ("failover peer %s: no identifier.",
+ log_fatal ("failover peer %s: no local address.",
state -> name);
}
} else {
@@ -4981,14 +4990,9 @@ normal_binding_state_transition_check (struct lease *lease,
switch (binding_state) {
case FTS_FREE:
case FTS_BACKUP:
- /* Can't set a lease to free or backup until the
- peer agrees that it's expired. */
- if (tsfp > cur_time) {
- new_state = lease -> binding_state;
- goto out;
- }
- return binding_state;
+ /* These are invalid state transitions - should we
+ prevent them? */
case FTS_RESERVED:
case FTS_BOOTP:
case FTS_EXPIRED:
diff --git a/server/omapi.c b/server/omapi.c
index 819d7f1d..b65eef17 100644
--- a/server/omapi.c
+++ b/server/omapi.c
@@ -50,7 +50,7 @@
#ifndef lint
static char copyright[] =
-"$Id: omapi.c,v 1.50 2001/07/10 20:36:06 brister Exp $ Copyright (c) 1999-2001 The Internet Software Consortium. All rights reserved.\n";
+"$Id: omapi.c,v 1.51 2001/08/10 10:50:50 mellon Exp $ Copyright (c) 1999-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -1868,7 +1868,7 @@ isc_result_t dhcp_class_destroy (omapi_object_t *h, const char *file, int line)
isc_result_t status;
int i;
- if (h -> type != dhcp_type_class || h -> type != dhcp_type_subclass)
+ if (h -> type != dhcp_type_class && h -> type != dhcp_type_subclass)
return ISC_R_INVALIDARG;
class = (struct class *)h;