Commit 166bd777 authored by Michael Gilbert's avatar Michael Gilbert

import upstream 4.4.1

parent f8a32411
This diff is collapsed.
......@@ -3,17 +3,22 @@
#
Makefile:
#
# for libtool
#
ACLOCAL_AMFLAGS = -I m4
#
# We have a lot of files that we want shipped with the distribution.
#
EXTRA_DIST = RELNOTES LICENSE \
EXTRA_DIST = RELNOTES LICENSE configure.ac+lt config+lt \
contrib/3.0b1-lease-convert contrib/dhclient-tz-exithook.sh \
contrib/dhcp.spec contrib/sethostname.sh contrib/solaris.init \
contrib/ms2isc/Registry.pm contrib/ms2isc/ms2isc.pl \
contrib/ms2isc/readme.txt contrib/ldap/dhcpd-conf-to-ldap \
contrib/ldap/dhcp.schema contrib/ldap/README.ldap \
contrib/dhcp-lease-list.pl \
doc/DHCPv4-over-DHCPv6 \
doc/BIND-libraries doc/DHCPv4-over-DHCPv6 \
doc/IANA-arp-parameters doc/Makefile doc/References.html \
doc/References.txt doc/References.xml doc/api+protocol \
doc/ja_JP.eucJP/dhclient-script.8 doc/ja_JP.eucJP/dhclient.8 \
......@@ -21,12 +26,19 @@ EXTRA_DIST = RELNOTES LICENSE \
doc/ja_JP.eucJP/dhcp-eval.5 doc/ja_JP.eucJP/dhcp-options.5 \
doc/examples/dhclient-dhcpv6.conf doc/examples/dhcpd-dhcpv6.conf \
doc/devel/arch.dox doc/devel/atf.dox doc/devel/contrib.dox \
doc/devel/debug.dox doc/devel/isc-logo.jpg doc/devel/mainpage.dox \
doc/devel/omapi.dox doc/devel/qa.dox util/bindvar.sh \
bind/Makefile.in bind/bind.tar.gz bind/version.tmp \
common/tests/Atffile server/tests/Atffile
doc/devel/debug.dox doc/devel/isc-logo.jpg doc/devel/libtool.dox \
doc/devel/mainpage.dox doc/devel/omapi.dox doc/devel/qa.dox \
client/tests/Atffile common/tests/Atffile server/tests/Atffile \
client/tests/Kyuafile common/tests/Kyuafile server/tests/Kyuafile \
m4/README
if HAVE_BINDDIR
EXTRA_DIST += bind/Makefile.in bind/bind.tar.gz bind/version.tmp
endif
SUBDIRS = @BINDSRCDIR@ includes tests common omapip client dhcpctl relay server
# Use an autoconf substitution vs an automake conditional here
# to fool automake when the bind directory does not exist.
SUBDIRS = @BINDSUBDIR@ includes tests common omapip client dhcpctl relay server
nobase_include_HEADERS = dhcpctl/dhcpctl.h
......@@ -35,9 +47,13 @@ nobase_include_HEADERS = dhcpctl/dhcpctl.h
#
DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_ATF_CONFIGURE_FLAG@
DISTCHECK_CONFIGURE_FLAGS += @DISTCHECK_LIBBIND_CONFIGURE_FLAG@
DISTCHECK_CONFIGURE_FLAGS += @DISTCHECK_LIBTOOL_CONFIGURE_FLAG@
distcheck-hook:
if HAVE_BINDDIR
chmod u+w $(distdir)/bind
endif
distclean-local:
rm -f config.report
Internet Systems Consortium DHCP Distribution
Version 4.3.5
5 October 2016
Version 4.4.1
28 February 2018
README FILE
......@@ -98,43 +98,6 @@ will not be correct for your operating system until after you iterate
'make install' (so if you're reading a manpage out of the source
directory, it may not have up-to-date information).
RELEASE STATUS
This is ISC DHCP 4.3.x The major theme for this release is "ipv6 uplift",
in which we enhance the v6 code to support many of the features found
in the v4 code. These include: support for v6, support for on_commit,
on_expiry and on_release in v6, support for accessing v6 relay options
and better log messages for v6 addresses. Non v6 features include:
support for the standard DDNS, better OMAPI class and sub-class support
allowing for dynamic addition and removal of sub-classes, and support for
DDNS without zone statements.
In this release, the DHCPv6 server should be fully functional on Linux,
Solaris, or any BSD. The DHCPv6 client should be similarly functional
except on Solaris.
The DHCPv4 server, relay, and client, should be fully functional
on Linux, Solaris, any BSD, HPUX, SCO, NextSTEP, and Irix.
If you are running the DHCP distribution on a machine which is a
firewall, or if there is a firewall between your DHCP server(s) and
DHCP clients, please read the section on firewalls which appears later
in this document.
If you wish to run the DHCP Distribution on Linux, please see the
Linux-specific notes later in this document. If you wish to run on an
SCO release, please see the SCO-specific notes later in this document.
You particularly need to read these notes if you intend to support
Windows 95 clients. If you are running HP-UX or Ultrix, please read the
notes for those operating systems below. If you are running NeXTSTEP,
please see the notes on NeXTSTEP below.
If you start dhcpd and get a message, "no free bpf", that means you
need to configure the Berkeley Packet Filter into your operating
system kernel. On NetBSD, FreeBSD and BSD/os, type ``man bpf'' for
information. On Digital Unix, type ``man pfilt''.
BUILDING THE DHCP DISTRIBUTION
UNPACKING IT
......@@ -142,12 +105,12 @@ information. On Digital Unix, type ``man pfilt''.
To build the DHCP Distribution, unpack the compressed tar file using
the tar utility and the gzip command - type something like:
gunzip dhcp-4.3.5.tar.gz
tar xvf dhcp-4.3.5.tar
gunzip dhcp-4.4.1.tar.gz
tar xvf dhcp-4.4.1.tar
CONFIGURING IT
Now, cd to the dhcp-4.3.5 subdirectory that you've just created and
Now, cd to the dhcp-4.4.1 subdirectory that you've just created and
configure the source tree by typing:
./configure
......@@ -163,6 +126,33 @@ You can get a list of these by typing:
./configure --help
If you want to use dynamic shared libraries automake, autoconf
(aka GNU autotools) and libtool must be available. The DHCP
distribution provides 3 configure.ac* files: the -lt version
has no libtool support and was copied to the configure.ac
standard file in the distribution. To enable libtool support
you should perform these steps:
cp configure.ac+lt configure.ac
autoreconf -i
after you can use the regenerated configure as usual
(with libtool support (--enable-libtool) on by default):
./configure
For compatibility (and people who don't read this documentation)
the --enable-libtool configuration file is supported even by
the distributed configure (and off by default). The previous
steps are performed and the regenerated configure called with
almost the same parameters (this "almost" makes the use of
this feature not recommended).
Note you can't go back from with libtool support to without libtool
support by restoring configure.ac and rerun autoreconf. If you
want or need to restore the without libtool support state the
required way is to simply restore the whole distribution.
DYNAMIC DNS UPDATES
A fully-featured implementation of dynamic DNS updates is included in
......
This diff is collapsed.
......@@ -4,18 +4,19 @@
# production code. Sadly, we are not there yet.
SUBDIRS = . tests
BINDLIBDIR = @BINDDIR@/lib
AM_CPPFLAGS = -DCLIENT_PATH='"PATH=$(sbindir):/sbin:/bin:/usr/sbin:/usr/bin"' \
-DLOCALSTATEDIR='"$(localstatedir)"'
AM_CPPFLAGS = -DCLIENT_PATH='"PATH=$(sbindir):/sbin:/bin:/usr/sbin:/usr/bin"'
AM_CPPFLAGS += -DLOCALSTATEDIR='"$(localstatedir)"'
dist_sysconf_DATA = dhclient.conf.example
sbin_PROGRAMS = dhclient
dhclient_SOURCES = clparse.c dhclient.c dhc6.c \
dhclient_SOURCES = client_tables.c clparse.c dhclient.c dhc6.c \
scripts/bsdos scripts/freebsd scripts/linux scripts/macos \
scripts/netbsd scripts/nextstep scripts/openbsd \
scripts/solaris scripts/openwrt
dhclient_LDADD = ../common/libdhcp.a ../omapip/libomapi.a $(BINDLIBDIR)/libirs.a \
$(BINDLIBDIR)/libdns.a $(BINDLIBDIR)/libisccfg.a $(BINDLIBDIR)/libisc.a
dhclient_LDADD = ../common/libdhcp.@A@ ../omapip/libomapi.@A@ \
@BINDLIBIRSDIR@/libirs.@A@ \
@BINDLIBDNSDIR@/libdns.@A@ \
@BINDLIBISCCFGDIR@/libisccfg.@A@ \
@BINDLIBISCDIR@/libisc.@A@
man_MANS = dhclient.8 dhclient-script.8 dhclient.conf.5 dhclient.leases.5
EXTRA_DIST = $(man_MANS)
/* client_tables.c
Tables of information only used by client... */
/*
* Copyright (c) 2017 by Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
*/
#include "dhcpd.h"
struct universe client_universe;
static struct option client_options[] = {
/* @todo dummy-client-parm should be removed with the first real param */
{ "dummy-client-parm", "T", &client_universe, 1, 1 },
{ NULL, NULL, NULL, 0, 0 }
};
#define CLIENT_HASH_SIZE (2*(sizeof(client_options) / sizeof(struct option)))
void initialize_client_option_spaces()
{
int i;
/* Set up the client option universe... */
client_universe.name = "client";
client_universe.concat_duplicates = 0;
client_universe.lookup_func = lookup_hashed_option;
client_universe.option_state_dereference =
hashed_option_state_dereference;
client_universe.save_func = save_hashed_option;
client_universe.delete_func = delete_hashed_option;
client_universe.encapsulate = hashed_option_space_encapsulate;
client_universe.foreach = hashed_option_space_foreach;
client_universe.length_size = 1; /* Never used ... */
client_universe.tag_size = 4;
client_universe.store_tag = putUChar;
client_universe.store_length = putUChar;
client_universe.site_code_min = 0;
client_universe.end = 0;
client_universe.index = universe_count++;
universes [client_universe.index] = &client_universe;
if (!option_name_new_hash(&client_universe.name_hash,
CLIENT_HASH_SIZE, MDL) ||
!option_code_new_hash(&client_universe.code_hash,
CLIENT_HASH_SIZE, MDL))
log_fatal ("Can't allocate client option hash table.");
for (i = 0 ; client_options[i].name ; i++) {
option_code_hash_add(client_universe.code_hash,
&client_options[i].code, 0,
&client_options[i], MDL);
option_name_hash_add(client_universe.name_hash,
client_options[i].name, 0,
&client_options[i], MDL);
}
/* Add the client option space to the option space hash. */
universe_hash_add (universe_hash,
client_universe.name, 0, &client_universe, MDL);
/* Make the client universe the configuration option universe. */
config_universe = &client_universe;
}
......@@ -3,12 +3,12 @@
Parser for dhclient config and lease files... */
/*
* Copyright (c) 2004-2016 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2017 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
......
This diff is collapsed.
.\" dhclient-script.8
.\"
.\" Copyright (c) 2012,2014,2016 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004-2005 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004-2017 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1996-2003 by Internet Software Consortium
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at http://mozilla.org/MPL/2.0/.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
......
.\" $Id: dhclient.8,v 1.36 2011/04/15 21:58:12 sar Exp $
.\"
.\" Copyright (c) 2004-2016 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004-2018 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1996-2003 by Internet Software Consortium
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at http://mozilla.org/MPL/2.0/.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
......@@ -134,6 +134,18 @@ dhclient - Dynamic Host Configuration Protocol Client
.B -w
]
[
.B --dad-wait-time
.I seconds
]
[
.B --prefix-len-hint
.I length
]
[
.B --decline-wait-time
.I seconds
]
[
.B -v
]
[
......@@ -351,12 +363,19 @@ Use a DUID with DHCPv4 clients. If no DUID is available in the
lease file one will be constructed and saved. The DUID will be
used to construct a RFC4361 style client id that will be included
in the client's messages. This client id can be overridden by
setting a client id in the configuration file. Overridding the
setting a client id in the configuration file. Overriding the
client id in this fashion is discouraged.
.TP
.BI \-I
Use the standard DDNS scheme from RFCs 4701 & 4702.
.TP
.TP
.BI \--decline-wait-time \ seconds
Specify the time (in seconds) that an IPv4 client should wait after
declining an address before issuing a discover. The default is
10 seconds as recommended by RFC 2131, Section 3.1.5. A value of
zero equates to no wait at all.
.PP
.BI \--version
Print version number and exit.
.PP
......@@ -409,6 +428,28 @@ overrides these default, with a value of either \fILL\fR or \fILLT\fR.
Restore normal address query for IPv6. This implies \fB-6\fR.
It is used to restore normal operation after using \fB-T\fR or \fB-P\fR.
Multiple addresses can be requested with multiple \fB\-N\fR flags.
.TP
.BI \--address-prefix-len \ length
Specify the length of the prefix for IPv6 addresses. This value is passed by
dhclient into the client script via the environment variable, ip6_prefixlen,
when binding IPv6 addresses. The default value is 128. Alternatively you may
change the default at compile time by setting DHCLIENT_DEFAULT_PREFIX_LEN in
includes/site.h.
.PP
.TP
.BI \--dad-wait-time \ seconds
Specify maximum time (in seconds) that the client should wait for the
duplicate address detection (DAD) to complete on an interface. This
value is propagated to the dhclient script in a dad_wait_time environment
variable. If any of the IPv6 addresses on the interface are tentative
(DAD is in progress), the script will wait for the specified number of
seconds for DAD to complete. If the script ignores this variable the
parameter has no effect.
.PP
.TP
.BI \--prefix-len-hint \ length
When used in conjunction with -P, it directs the client to use the given
length to use a prefix hint of, "::/length", when requesting new prefixes.
.PP
.I Modifying default file locations:
The following options can be used to modify the locations a client uses
......@@ -480,8 +521,9 @@ port will be used for the established connection.
When DDNS is enabled at compile time (see includes/site.h)
the client will open both a v4 and a v6 UDP socket on
random ports. These ports are opened even if DDNS is disabled
in the configuration file.
random ports. These ports are not opened unless/until the
client first attempts to do an update. If the client is not
configured to do updates, the ports will never be opened.
.PP
.SH CONFIGURATION
The syntax of the \fBdhclient.conf(5)\fR file is discussed separately.
......
This diff is collapsed.
.\" $Id: dhclient.conf.5,v 1.34 2012/01/24 22:23:39 sar Exp $
.\"
.\" Copyright (c) 2004-2016 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004-2017 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1996-2003 by Internet Software Consortium
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at http://mozilla.org/MPL/2.0/.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
......
.\" $Id: dhclient.leases.5,v 1.8 2011/02/23 23:50:55 sar Exp $
.\"
.\" Copyright (c) 2009-2011 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004-2017 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1997-2003 by Internet Software Consortium
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at http://mozilla.org/MPL/2.0/.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
......
......@@ -92,6 +92,51 @@ exit_with_hooks() {
exit $exit_status
}
# This function was largely borrowed from dhclient-script that
# ships with Centos, authored by Jiri Popelka and David Cantrell
# of Redhat. Thanks guys.
add_ipv6_addr_with_DAD() {
ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} alias
if [ ${dad_wait_time} -le 0 ]
then
# if we're not waiting for DAD, assume we're good
return 0
fi
# Repeatedly test whether newly added address passed
# duplicate address detection (DAD)
for i in $(seq 1 ${dad_wait_time}); do
sleep 1 # give the DAD some time
addr=$(ifconfig ${interface} \
| grep "${new_ip6_address} prefixlen ${new_ip6_prefixlen}")
# tentative flag == DAD is still not complete
tentative=$(echo "${addr}" | grep tentative)
# dadfailed flag == address is already in use somewhere else
dadfailed=$(echo "${addr}" | grep duplicated)
if [ -n "${dadfailed}" ] ; then
# dad failed, remove the address
ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} -alias
exit_with_hooks 3
fi
if [ -z "${tentative}" ] ; then
if [ -n "${addr}" ]; then
# DAD is over
return 0
else
# address was auto-removed (or not added at all)
exit_with_hooks 3
fi
fi
done
return 0
}
# Invoke the local dhcp client enter hooks, if they exist.
if [ -f /etc/dhclient-enter-hooks ]; then
exit_status=0
......@@ -335,6 +380,42 @@ if [ ${reason} = PREINIT6 ] ; then
# XXX: Remove any stale addresses from aborted clients.
# We need to give the kernel some time to active interface
interface_up_wait_time=5
for i in $(seq 0 ${interface_up_wait_time})
do
ifconfig ${interface} | grep inactive >/dev/null 2>&1
if [ $? -ne 0 ]; then
break;
fi
sleep 1
done
# Wait for duplicate address detection for this interface if the
# --dad-wait-time parameter has been specified and is greater than
# zero.
if [ ${dad_wait_time} -gt 0 ]; then
# Check if any IPv6 address on this interface is marked as
# tentative.
ifconfig ${interface} | grep inet6 | grep tentative \
>/dev/null 2>&1
if [ $? -eq 0 ]; then
# Wait for duplicate address detection to complete or for
# the timeout specified as --dad-wait-time.
for i in $(seq 0 $dad_wait_time)
do
# We're going to poll for the tentative flag every second.
sleep 1
ifconfig ${interface} | grep inet6 | grep tentative \
>/dev/null 2>&1
if [ $? -ne 0 ]; then
break;
fi
done
fi
fi
exit_with_hooks 0
fi
......@@ -349,7 +430,8 @@ if [ ${reason} = BOUND6 ] ; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} alias
# Add address to interface, check for DAD if dad_wait_time > 0
add_ipv6_addr_with_DAD
# Check for nameserver options.
make_resolv_conf
......
This diff is collapsed.
......@@ -108,6 +108,51 @@ commit_resolv_conf() {
to_commit="done"
}
# This function was largely borrowed from dhclient-script that
# ships with Centos, authored by Jiri Popelka and David Cantrell
# of Redhat. Thanks guys.
add_ipv6_addr_with_DAD() {
ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} alias
if [ ${dad_wait_time} -le 0 ]
then
# if we're not waiting for DAD, assume we're good
return 0
fi
# Repeatedly test whether newly added address passed
# duplicate address detection (DAD)
for i in $(seq 1 ${dad_wait_time}); do
sleep 1 # give the DAD some time
addr=$(ifconfig ${interface} \
| grep "${new_ip6_address} prefixlen ${new_ip6_prefixlen}")
# tentative flag == DAD is still not complete
tentative=$(echo "${addr}" | grep tentative)
# dadfailed flag == address is already in use somewhere else
dadfailed=$(echo "${addr}" | grep duplicated)
if [ -n "${dadfailed}" ] ; then
# dad failed, remove the address
ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} -alias
exit_with_hooks 3
fi
if [ -z "${tentative}" ] ; then
if [ -n "${addr}" ]; then
# DAD is over
return 0
else
# address was auto-removed (or not added at all)
exit_with_hooks 3
fi
fi
done
return 0
}
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
exit_status=$1
......@@ -144,8 +189,43 @@ if [ x$reason = xPREINIT6 ]; then
# Ensure interface is up.
ifconfig ${interface} up
# We need to give the kernel some time to active interface
interface_up_wait_time=5
for i in $(seq 0 ${interface_up_wait_time})
do
ifconfig ${interface} | grep inactive &> /dev/null
if [ $? -ne 0 ]; then
break;
fi
sleep 1
done
# XXX: Remove any stale addresses from aborted clients.
# Wait for duplicate address detection for this interface if the
# --dad-wait-time parameter has been specified and is greater than
# zero.
if [ ${dad_wait_time} -gt 0 ]; then
# Check if any IPv6 address on this interface is marked as
# tentative.
ifconfig ${interface} | grep inet6 | grep tentative \
&> /dev/null
if [ $? -eq 0 ]; then
# Wait for duplicate address detection to complete or for
# the timeout specified as --dad-wait-time.
for i in $(seq 0 $dad_wait_time)
do
# We're going to poll for the tentative flag every second.
sleep 1
ifconfig ${interface} | grep inet6 | grep tentative \
&> /dev/null
if [ $? -ne 0 ]; then
break;
fi
done
fi
fi
exit_with_hooks 0
fi
......@@ -160,7 +240,8 @@ if [ x$reason = xBOUND6 ]; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} alias
# Add address to interface, check for DAD if dad_wait_time > 0
add_ipv6_addr_with_DAD
# Check for nameserver options.
make_resolv_conf
......
......@@ -48,6 +48,51 @@ exit_with_hooks() {
exit $exit_status
}
# This function was largely borrowed from dhclient-script that
# ships with Centos, authored by Jiri Popelka and David Cantrell
# of Redhat. Thanks guys.
add_ipv6_addr_with_DAD() {
ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} alias
if [ ${dad_wait_time} -le 0 ]
then
# if we're not waiting for DAD, assume we're good
return 0
fi
# Repeatedly test whether newly added address passed
# duplicate address detection (DAD)
for i in $(seq 1 ${dad_wait_time}); do
sleep 1 # give the DAD some time
addr=$(ifconfig ${interface} \
| grep "${new_ip6_address} prefixlen ${new_ip6_prefixlen}")
# tentative flag == DAD is still not complete
tentative=$(echo "${addr}" | grep tentative)
# dadfailed flag == address is already in use somewhere else
dadfailed=$(echo "${addr}" | grep duplicated)
if [ -n "${dadfailed}" ] ; then
# dad failed, remove the address
ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} -alias
exit_with_hooks 3
fi
if [ -z "${tentative}" ] ; then
if [ -n "${addr}" ]; then
# DAD is over
return 0
else
# address was auto-removed (or not added at all)
exit_with_hooks 3
fi