From: David Hankins Date: Thu, 7 Jul 2005 16:39:08 +0000 (+0000) Subject: Merge changes between 3.0.3b1 and 3.0.3rc1 to HEAD. X-Git-Tag: HEAD-MERGE-V3-0-3RC1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c75473d8001ba93461a611ba2d797cf144ab1a54;p=thirdparty%2Fdhcp.git Merge changes between 3.0.3b1 and 3.0.3rc1 to HEAD. --- diff --git a/Makefile.conf b/Makefile.conf index 4d57cb358..8d6cb7961 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -47,6 +47,7 @@ INCDIR=/usr/local/include LIBS = COPTS = $(BINDDEF) $(CC_OPTIONS) DEBUG = -g +#WARNERR = -Werror RANLIB = ranlib MKDEP = mkdep CLIENT_PATH = '"PATH=/usr/ucb:/usr/bin:/usr/sbin:/bin:/sbin"' @@ -128,7 +129,7 @@ MINORVERSION=MinorVersion #LIBS = -lresolv -lsocket -lnsl -lgen #CC=gcc #COPTS = $(BINDDEF) -Wall -Wno-unused -Wno-implicit -Wno-comment \ -# -Wno-uninitialized -Wno-char-subscripts -Wno-switch -Werror \ +# -Wno-uninitialized -Wno-char-subscripts -Wno-switch $(WARNERR) \ # -DSOLARIS_MAJOR=$(MAJORVERSION) -DSOLARIS_MINOR=$(MINORVERSION) \ # $(CC_OPTIONS) #CF = cf/sunos5-5.h @@ -204,7 +205,7 @@ MINORVERSION=MinorVersion ## FreeBSD ##--freebsd-- #CF = cf/freebsd.h -#COPTS = -O -Wall -Wno-unused -Werror $(CC_OPTIONS) +#COPTS = -O -Wall -Wno-unused $(WARNERR) $(CC_OPTIONS) #SCRIPT=freebsd ##--freebsd-- @@ -212,7 +213,7 @@ MINORVERSION=MinorVersion ##--rhapsody-- #CF = cf/rhapsody.h #COPTS = -Wall -Wno-unused -Wno-implicit -Wno-comment \ -# -Wno-uninitialized -Wno-switch -Werror -pipe $(BINDDEF) $(CC_OPTIONS) +# -Wno-uninitialized -Wno-switch $(WARNERR) -pipe $(BINDDEF) $(CC_OPTIONS) ##SCRIPT=rhapsody ##--rhapsody-- @@ -220,7 +221,7 @@ MINORVERSION=MinorVersion ##--darwin-- #CF = cf/rhapsody.h #COPTS = -Ddarwin -Wall -Wno-unused -Wno-implicit -Wno-comment \ -# -Wno-uninitialized -Wno-switch -Werror -pipe $(BINDDEF) $(CC_OPTIONS) +# -Wno-uninitialized -Wno-switch $(WARNERR) -pipe $(BINDDEF) $(CC_OPTIONS) #SCRIPT=freebsd ##--darwin-- @@ -228,7 +229,7 @@ MINORVERSION=MinorVersion ##--netbsd-- #CF = cf/netbsd.h #COPTS = -Wall -Wstrict-prototypes -Wno-unused -Wno-comment \ -# -Wno-uninitialized -Werror \ +# -Wno-uninitialized $(WARNERR) \ # -Wimplicit-function-declaration -Wpointer-arith -Wcast-qual \ # -Wwrite-strings -Wmissing-prototypes \ # -Wmissing-declarations -Wnested-externs \ diff --git a/RELNOTES b/RELNOTES index 4eb1fc04b..1c0d9a383 100644 --- a/RELNOTES +++ b/RELNOTES @@ -60,6 +60,31 @@ and for prodding me into improving it. - 'make install' now creates the initial zero-length dhcpd.leases file if one does not already exist on the system. + Changes since 3.0.3b3 + +- dhclient.conf documentation for interface {} was updated to reflect recent + discussion on the dhcp-hackers mailing list. + +- In response to reports that the software does not compile on GCC 4.0.0, + -Werror was removed from Makefile.conf for all platforms that used it. + We will address the true problem in a future release; this is a temporary + workaround. + + Changes since 3.0.3b2 + +- An error in code changes introduced in 3.0.3b2 was corrected, which caused + static BOOTP clients to receive random addresses. + + Changes since 3.0.3b1 + +- A bug was fixed in BOOTPREQUEST handling code wherein stale references to + host records would be left behind on leases that were not allocated to the + client currently booting (eg in the case where the host was denied booting). + +- The dhcpd.conf.5 manpage was updated to be more clear in regards to + multiple host declarations (thanks to Vincent McIntyre). 'Interim' style + dynamic updates were also retouched. + Changes since 3.0.2 - A bug was fixed where a server might load balance a DHCP REQUEST to its diff --git a/client/dhclient.conf.5 b/client/dhclient.conf.5 index ba9583c8d..49a46b50b 100644 --- a/client/dhclient.conf.5 +++ b/client/dhclient.conf.5 @@ -1,4 +1,4 @@ -.\" $Id: dhclient.conf.5,v 1.15 2005/03/17 20:14:56 dhankins Exp $ +.\" $Id: dhclient.conf.5,v 1.16 2005/07/07 16:39:07 dhankins Exp $ .\" .\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") .\" Copyright (c) 1996-2003 by Internet Software Consortium @@ -28,7 +28,7 @@ .\" see ``http://www.vix.com''. To learn more about Nominum, Inc., see .\" ``http://www.nominum.com''. .\" -.\" $Id: dhclient.conf.5,v 1.15 2005/03/17 20:14:56 dhankins Exp $ +.\" $Id: dhclient.conf.5,v 1.16 2005/07/07 16:39:07 dhankins Exp $ .\" .TH dhclient.conf 5 .SH NAME @@ -524,6 +524,15 @@ parameters will then be used only for the interface that matches the specified name. Interfaces for which there is no interface declaration will use the parameters declared outside of any interface declaration, or the default settings. +.PP +.B Note well: +ISC dhclient only maintains one list of interfaces, which is either +determined at startup from command line arguments, or otherwise is +autodetected. If you supplied the list of interfaces on the command +line, this configuration clause will add the named interface to the +list in such a way that will cause it to be configured by DHCP. Which +may not be the result you had intended. This is an undesirable side +effect that will be addressed in a future release. .PP \fBpseudo "\fIname\fR" "\fIreal-name\fB" { \fIdeclarations ... \fB } .PP diff --git a/includes/dhcpd.h b/includes/dhcpd.h index e12bc9c84..50899d5c0 100644 --- a/includes/dhcpd.h +++ b/includes/dhcpd.h @@ -1376,7 +1376,7 @@ void dhcpdecline PROTO ((struct packet *, int)); void dhcpinform PROTO ((struct packet *, int)); void nak_lease PROTO ((struct packet *, struct iaddr *cip)); void ack_lease PROTO ((struct packet *, struct lease *, - unsigned int, TIME, char *, int)); + unsigned int, TIME, char *, int, struct host_decl *)); void dhcp_reply PROTO ((struct lease *)); int find_lease PROTO ((struct lease **, struct packet *, struct shared_network *, int *, int *, struct lease *, diff --git a/server/bootp.c b/server/bootp.c index ed980b3d8..c5b2ae0b6 100644 --- a/server/bootp.c +++ b/server/bootp.c @@ -3,7 +3,7 @@ BOOTP Protocol support. */ /* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2004-2005 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1995-2003 by Internet Software Consortium * * Permission to use, copy, modify, and distribute this software for any @@ -34,7 +34,7 @@ #ifndef lint static char copyright[] = -"$Id: bootp.c,v 1.72 2005/03/17 20:15:26 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; +"$Id: bootp.c,v 1.73 2005/07/07 16:39:07 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -55,9 +55,7 @@ void bootp (packet) struct in_addr from; struct hardware hto; struct option_state *options = (struct option_state *)0; - struct subnet *subnet; - struct lease *lease; - struct iaddr ip_address; + struct lease *lease = (struct lease *)0; unsigned i; struct data_string d1; struct option_cache *oc; @@ -79,90 +77,70 @@ void bootp (packet) ? inet_ntoa (packet -> raw -> giaddr) : packet -> interface -> name); - - if (!locate_network (packet)) { log_info ("%s: network unknown", msgbuf); return; } - find_hosts_by_haddr (&hp, packet -> raw -> htype, - packet -> raw -> chaddr, - packet -> raw -> hlen, MDL); - - lease = (struct lease *)0; find_lease (&lease, packet, packet -> shared_network, 0, 0, (struct lease *)0, MDL); - /* Find an IP address in the host_decl that matches the - specified network. */ - subnet = (struct subnet *)0; - if (hp) - find_host_for_network (&subnet, &hp, &ip_address, - packet -> shared_network); + if (lease && lease->host) + host_reference(&hp, lease->host, MDL); - if (!subnet) { + if (!lease || ((lease->flags & STATIC_LEASE) == 0)) { struct host_decl *h; - /* We didn't find an applicable host declaration. - Just in case we may be able to dynamically assign - an address, see if there's a host declaration + /* We didn't find an applicable fixed-address host + declaration. Just in case we may be able to dynamically + assign an address, see if there's a host declaration that doesn't have an ip address associated with it. */ + + if (!hp) + find_hosts_by_haddr(&hp, packet->raw->htype, + packet->raw->chaddr, + packet->raw->hlen, MDL); + for (h = hp; h; h = h -> n_ipaddr) { if (!h -> fixed_addr) { - host_reference (&host, h, MDL); + host_reference(&host, h, MDL); break; } } - if (hp) { - host_dereference (&hp, MDL); - if (host) - host_reference (&hp, host, MDL); - } - - /* If a lease has already been assigned to this client, - use it. */ - if (lease) { - if (host && host != lease -> host) { - if (lease -> host) - host_dereference (&lease -> host, MDL); - host_reference (&lease -> host, host, MDL); - } - ack_lease (packet, lease, 0, 0, msgbuf, 0); - goto out; - } - /* Otherwise, try to allocate one. */ - allocate_lease (&lease, packet, - packet -> shared_network -> pools, - &peer_has_leases); - if (lease) { - if (host && host != lease -> host) { - if (lease -> host) - host_dereference (&lease -> host, MDL); - host_reference (&lease -> host, host, MDL); - } else if (lease -> host) - host_dereference (&lease -> host, MDL); - ack_lease (packet, lease, 0, 0, msgbuf, 0); - goto out; + if (hp) + host_dereference(&hp, MDL); + + if (host) { + host_reference(&hp, host, MDL); + host_dereference(&host, MDL); } - /* We couldn't find an address to give this bootp client. */ - log_info ("%s: BOOTP from unknown client and no dynamic leases", - msgbuf); + /* Allocate a lease if we have not yet found one. */ + if (!lease) + allocate_lease (&lease, packet, + packet -> shared_network -> pools, + &peer_has_leases); + + if (lease) + ack_lease (packet, lease, 0, 0, msgbuf, 0, hp); + else + log_info ("%s: BOOTP from dynamic client and no " + "dynamic leases", msgbuf); + goto out; } /* Run the executable statements to compute the client and server options. */ option_state_allocate (&options, MDL); - + /* Execute the subnet statements. */ execute_statements_in_scope ((struct binding_value **)0, packet, lease, (struct client_state *)0, packet -> options, options, &lease -> scope, lease -> subnet -> group, (struct group *)0); - + /* Execute statements from class scopes. */ for (i = packet -> class_count; i > 0; i--) { execute_statements_in_scope @@ -178,7 +156,7 @@ void bootp (packet) packet, lease, (struct client_state *)0, packet -> options, options, &lease -> scope, - hp -> group, subnet -> group); + hp -> group, lease -> subnet -> group); /* Drop the request if it's not allowed for this client. */ if ((oc = lookup_option (&server_universe, options, SV_ALLOW_BOOTP)) && @@ -266,7 +244,9 @@ void bootp (packet) raw.secs = packet -> raw -> secs; raw.flags = packet -> raw -> flags; raw.ciaddr = packet -> raw -> ciaddr; - memcpy (&raw.yiaddr, ip_address.iabuf, sizeof raw.yiaddr); + + /* yiaddr is an ipv4 address, it must be 4 octets. */ + memcpy (&raw.yiaddr, lease->ip_addr.iabuf, 4); /* If we're always supposed to broadcast to this client, set the broadcast bit in the bootp flags field. */ @@ -350,7 +330,7 @@ void bootp (packet) /* Report what we're doing... */ log_info ("%s", msgbuf); log_info ("BOOTREPLY for %s to %s (%s) via %s", - piaddr (ip_address), hp -> name, + piaddr (lease->ip_addr), hp -> name, print_hw_addr (packet -> raw -> htype, packet -> raw -> hlen, packet -> raw -> chaddr), @@ -406,6 +386,4 @@ void bootp (packet) host_dereference (&hp, MDL); if (host) host_dereference (&host, MDL); - if (subnet) - subnet_dereference (&subnet, MDL); } diff --git a/server/dhcp.c b/server/dhcp.c index 3d647458f..fee59a92a 100644 --- a/server/dhcp.c +++ b/server/dhcp.c @@ -34,7 +34,7 @@ #ifndef lint static char copyright[] = -"$Id: dhcp.c,v 1.197 2005/03/17 20:15:27 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; +"$Id: dhcp.c,v 1.198 2005/07/07 16:39:08 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -387,7 +387,8 @@ void dhcpdiscover (packet, ms_nulltp) if (when < lease -> ends) when = lease -> ends; - ack_lease (packet, lease, DHCPOFFER, when, msgbuf, ms_nulltp); + ack_lease (packet, lease, DHCPOFFER, when, msgbuf, ms_nulltp, + (struct host_decl *)0); out: if (lease) lease_dereference (&lease, MDL); @@ -664,7 +665,8 @@ void dhcprequest (packet, ms_nulltp, ip_lease) /* Otherwise, send the lease to the client if we found one. */ if (lease) { - ack_lease (packet, lease, DHCPACK, 0, msgbuf, ms_nulltp); + ack_lease (packet, lease, DHCPACK, 0, msgbuf, ms_nulltp, + (struct host_decl *)0); } else log_info ("%s: unknown lease %s.", msgbuf, piaddr (cip)); @@ -1476,13 +1478,14 @@ void nak_lease (packet, cip) from, &to, (struct hardware *)0); } -void ack_lease (packet, lease, offer, when, msg, ms_nulltp) +void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp) struct packet *packet; struct lease *lease; unsigned int offer; TIME when; char *msg; int ms_nulltp; + struct host_decl *hp; { struct lease *lt; struct lease_state *state; @@ -1511,7 +1514,9 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp) return; /* If the lease carries a host record, remember it. */ - if (lease -> host) + if (hp) + host_reference (&host, hp, MDL); + else if (lease -> host) host_reference (&host, lease -> host, MDL); /* Allocate a lease state structure... */ diff --git a/server/dhcpd.conf.5 b/server/dhcpd.conf.5 index 1c2df1f25..847b34582 100644 --- a/server/dhcpd.conf.5 +++ b/server/dhcpd.conf.5 @@ -28,7 +28,7 @@ .\" see ``http://www.vix.com''. To learn more about Nominum, Inc., see .\" ``http://www.nominum.com''. .\" -.\" $Id: dhcpd.conf.5,v 1.67 2005/03/17 20:15:27 dhankins Exp $ +.\" $Id: dhcpd.conf.5,v 1.68 2005/07/07 16:39:08 dhankins Exp $ .\" .TH dhcpd.conf 5 .SH NAME @@ -1040,8 +1040,8 @@ IP address, it can update its own A record, assuming that the .PP If the server is configured not to allow client updates, or if the client doesn't want to do its own update, the server will simply -choose a name for the client, possibly using the hostname supplied by -the client ("jschmoe" in the previous example). It will use its own +choose a name for the client from either the fqdn option (if present) +or the hostname option (if present). It will use its own domain name for the client, just as in the ad-hoc update scheme. It will then update both the A and PTR record, using the name that it chose for the client. If the client sends a fully-qualified domain @@ -1049,6 +1049,14 @@ name in the fqdn option, the server uses only the leftmost part of the domain name - in the example above, "jschmoe" instead of "jschmoe.radish.org". .PP +Also, if the +.I use-host-decl-names +configuration option is enabled, then the host declaration's +.I hostname +will be used in place of the +.I hostname +option, and the same rules will apply as described above. +.PP The other difference between the ad-hoc scheme and the interim scheme is that with the interim scheme, a method is used that allows more than one DHCP server to update the DNS database without @@ -1352,26 +1360,32 @@ a specific client, and also provides a way to assign a client a fixed address. The host declaration provides a way for the DHCP server to identify a DHCP or BOOTP client, and also a way to assign the client a static IP address. .PP -If it is desirable to be able to boot a DHCP or BOOTP -client on more than one subnet with fixed addresses, more than one -address may be specified in the +If it is desirable to be able to boot a DHCP or BOOTP client on more than one +subnet with fixed addresses, more than one address may be specified in the .I fixed-address declaration, or more than one .B host -statement may be specified. +statement may be specified matching the same client. .PP If client-specific boot parameters must change based on the network to which the client is attached, then multiple .B host -declaration should -be used. -.PP -If a client is to be booted using a fixed address if it's -possible, but should be allocated a dynamic address otherwise, then a +declarations should be used. The .B host -declaration must be specified without a -.B fixed-address -declaration. +declarations will only match a client if one of their +.I fixed-address +statements is viable on the subnet (or shared network) where the client is +attached. Conversely, for a +.B host +declaration to match a client being allocated a dynamic address, it must not +have any +.I fixed-address +statements. You may therefore need a mixture of +.B host +declarations for any given client...some having +.I fixed-address +statements, others without. +.PP .I hostname should be a name identifying the host. If a \fIhostname\fR option is not specified for the host, \fIhostname\fR is used.