Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/dhcpcd/dist Import dhcpcd-6.3.0 with the follow...
details: https://anonhg.NetBSD.org/src/rev/3c6eb6ab8125
branches: trunk
changeset: 326997:3c6eb6ab8125
user: roy <roy%NetBSD.org@localhost>
date: Tue Feb 25 13:14:27 2014 +0000
description:
Import dhcpcd-6.3.0 with the following changes:
* IAID must be inside an interface block.
* Detect IPv6 address flags on Linux.
* Check that we have ctrl_interface defined in wpa_supplicant.conf and pass this parameter to wpa_cli(8). If not set, warn about not interacting with wpa_supplicant(8).
* Skip Virtual Interface Masters. Currently this only applies to FreeBSD VAP masters as dhcpcd should only work on wlandev created clones.
* Fix handling of ARP failures, thanks to Sebastian Huber.
* Implement RFC 1321 MD5 Message-Digest if not provided in libc.
* Implement RFC 2104 HMAC Keyed Hashing.
* Implement RFC 3118 Authentication for DHCP Messages and RFC 3315 Authentication options.
* Add nodhcp and nodhcp6 directives. Thanks to Sebastian Huber for the initial patch and testing.
* Implement support for RFC 3203, FORCERENEW message.
* Implement Force Renew Nonce Capability option, RFC6704
* Support RECONFIGURE DHCPv6 messages.
* Add support for DHCP auto configuration, RFC 2563.
* Add support for the following RFCs
+ DHCP SLP Directory Agent, RFC2610
+ DHCP Name Service Search, RFC2937
+ DHCP PANA Authentication Agent, RFC5192
+ DHCP Lost Server, RFC5223
+ DHCP CAPWAP, RFC5417
+ DHCP Mobility Services, RFC5678
+ DHCP SIP UA, RFC6011
+ DHCP ANDSF, RFC6153
+ DHCP RDNSS Selection for MIF Nodes, RFC6731
+ DHCP TFTP Server Address, RFC5859
+ DHCP PXELINUX, RFC5071
+ DHCP Access Network Domain Name, RFC5986
+ DHCP Virtual Subnet Selection, RFC6607
+ DHCP Relay Agent Remote-ID, RFC4649
+ DHCP Relay Agent Subscriber-ID, RFC4580
+ DHCPv6 Relay-ID, RFC5460
+ DHCPv6 LIS Discovery, RFC5986
+ DHCPv6 SIP UA, RFC6011
+ DHCPv6 Network Boot, RFC5970
+ DHCPv6 Home Info Discovery in MIPv6, RFC6610
+ DHCPv6 RDNSS Selection for MIF Nodes, RFC6731
+ DHCPv6 Kerberos, RFC6784
+ DHCPv6 Relay-Triggered Reconfiguration, RFC6977
+ DHCPv6 SOL_MAX_RT, RFC7083
* Open UDP sockets for *.*.*.*:bootpc and $ip_address:bootpc to avoid kernel ICMP unreachable messages
* Moved global variables into context variables so dhcpcd is entirely thread safe.
dhcpcd doens't use threads, but it can now be used in a pure threads (ie no process) environment.
* Remove DEBUG_MEMORY guard and always free memory and resources. Remove all atexit(3) and exit(3) calls, instead exiting via the eloop.
* Replace get_line with sscanf where applicable.
* Remove custom set_cloexec and set_nonblock functions. Instead pass O_CLOEXEC or SOCK_CLOEXEC to open, socket, etc.
* Don't use PATH_MAX - we already know the maximum length from the initial directory and IF_NAMESIZE.
* Add a USE_SIGNALS define. If we're not using signals then we also create a control socket in the non MASTER case. We then use this to communicate instead of signals.
* Fix arping moving to the next test if we find the IP address but do not have a profile for it. Thanks to David McGurty for the analysis.
* Respect initial commandline arguments when rebooting via a signal.
diffstat:
external/bsd/dhcpcd/dist/arp.c | 98 +-
external/bsd/dhcpcd/dist/arp.h | 5 +-
external/bsd/dhcpcd/dist/auth.c | 650 ++++++++++
external/bsd/dhcpcd/dist/auth.h | 88 +
external/bsd/dhcpcd/dist/bpf.c | 19 +-
external/bsd/dhcpcd/dist/common.c | 133 +-
external/bsd/dhcpcd/dist/common.h | 13 +-
external/bsd/dhcpcd/dist/control.c | 215 ++-
external/bsd/dhcpcd/dist/control.h | 17 +-
external/bsd/dhcpcd/dist/crypt/crypt.h | 35 +
external/bsd/dhcpcd/dist/crypt/hmac_md5.c | 89 +
external/bsd/dhcpcd/dist/defs.h | 18 +-
external/bsd/dhcpcd/dist/dev.h | 23 +-
external/bsd/dhcpcd/dist/dhcp-common.c | 40 +-
external/bsd/dhcpcd/dist/dhcp-common.h | 17 +-
external/bsd/dhcpcd/dist/dhcp.h | 34 +-
external/bsd/dhcpcd/dist/dhcp6.c | 685 +++++++----
external/bsd/dhcpcd/dist/dhcp6.h | 45 +-
external/bsd/dhcpcd/dist/dhcpcd-definitions.conf | 264 ++++-
external/bsd/dhcpcd/dist/dhcpcd-embedded.c | 123 +-
external/bsd/dhcpcd/dist/dhcpcd-embedded.h | 6 +-
external/bsd/dhcpcd/dist/dhcpcd-hooks/10-wpa_supplicant | 58 +-
external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in | 17 +-
external/bsd/dhcpcd/dist/dhcpcd.c | 957 ++++++++-------
external/bsd/dhcpcd/dist/dhcpcd.h | 97 +-
external/bsd/dhcpcd/dist/duid.c | 41 +-
external/bsd/dhcpcd/dist/duid.h | 9 +-
external/bsd/dhcpcd/dist/eloop.c | 276 ++--
external/bsd/dhcpcd/dist/eloop.h | 82 +-
external/bsd/dhcpcd/dist/if-options.h | 20 +-
external/bsd/dhcpcd/dist/if-pref.c | 18 +-
external/bsd/dhcpcd/dist/if-pref.h | 4 +-
external/bsd/dhcpcd/dist/ipv4.c | 102 +-
external/bsd/dhcpcd/dist/ipv4.h | 20 +-
external/bsd/dhcpcd/dist/ipv4ll.c | 24 +-
external/bsd/dhcpcd/dist/ipv6.c | 160 +-
external/bsd/dhcpcd/dist/ipv6.h | 53 +-
external/bsd/dhcpcd/dist/ipv6nd.h | 15 +-
external/bsd/dhcpcd/dist/net.h | 20 +-
external/bsd/dhcpcd/dist/platform-bsd.c | 35 +-
external/bsd/dhcpcd/dist/platform.h | 12 +-
41 files changed, 3182 insertions(+), 1455 deletions(-)
diffs (truncated from 8062 to 300 lines):
diff -r 9c295665b9ff -r 3c6eb6ab8125 external/bsd/dhcpcd/dist/arp.c
--- a/external/bsd/dhcpcd/dist/arp.c Tue Feb 25 13:07:29 2014 +0000
+++ b/external/bsd/dhcpcd/dist/arp.c Tue Feb 25 13:14:27 2014 +0000
@@ -1,9 +1,9 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: arp.c,v 1.1.1.10 2014/01/03 22:10:43 roy Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.1.1.11 2014/02/25 13:14:29 roy Exp $");
/*
* dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2013 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2014 Roy Marples <roy%marples.name@localhost>
* All rights reserved
* Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,7 @@
#include <syslog.h>
#include <unistd.h>
+#include "config.h"
#include "arp.h"
#include "ipv4.h"
#include "common.h"
@@ -97,9 +98,9 @@
/* If we failed without a magic cookie then we need to try
* and defend our IPv4LL address. */
if ((state->offer != NULL &&
- state->offer->cookie != htonl(MAGIC_COOKIE)) ||
+ state->offer->cookie != htonl(MAGIC_COOKIE)) ||
(state->new != NULL &&
- state->new->cookie != htonl(MAGIC_COOKIE)))
+ state->new->cookie != htonl(MAGIC_COOKIE)))
{
ipv4ll_handle_failure(ifp);
return;
@@ -108,12 +109,12 @@
unlink(state->leasefile);
if (!state->lease.frominfo)
dhcp_decline(ifp);
- dhcp_close(ifp);
- eloop_timeout_delete(NULL, ifp);
+ eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
if (state->lease.frominfo)
start_interface(ifp);
else
- eloop_timeout_add_sec(DHCP_ARP_FAIL, start_interface, ifp);
+ eloop_timeout_add_sec(ifp->ctx->eloop,
+ DHCP_ARP_FAIL, start_interface, ifp);
}
static void
@@ -130,6 +131,7 @@
struct if_options *opts = ifp->options;
const char *hwaddr;
struct in_addr ina;
+ char hwbuf[HWADDR_LEN * 3];
state = D_STATE(ifp);
state->fail.s_addr = 0;
@@ -170,41 +172,52 @@
if (state->arping_index &&
state->arping_index <= opts->arping_len &&
(reply_s == opts->arping[state->arping_index - 1] ||
- (reply_s == 0 &&
- reply_t == opts->arping[state->arping_index - 1])))
+ (reply_s == 0 &&
+ reply_t == opts->arping[state->arping_index - 1])))
{
ina.s_addr = reply_s;
hwaddr = hwaddr_ntoa((unsigned char *)hw_s,
- (size_t)ar.ar_hln);
+ (size_t)ar.ar_hln, hwbuf, sizeof(hwbuf));
syslog(LOG_INFO,
"%s: found %s on hardware address %s",
ifp->name, inet_ntoa(ina), hwaddr);
if (select_profile(ifp, hwaddr) == -1 &&
- errno == ENOENT)
- select_profile(ifp, inet_ntoa(ina));
+ select_profile(ifp, inet_ntoa(ina)) == -1)
+ {
+ state->probes = 0;
+ /* We didn't find a profile for this
+ * address or hwaddr, so move to the next
+ * arping profile */
+ if (state->arping_index <
+ ifp->options->arping_len)
+ {
+ arp_probe(ifp);
+ return;
+ }
+ }
dhcp_close(ifp);
- eloop_timeout_delete(NULL, ifp);
+ eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
start_interface(ifp);
return;
}
- /* Check for conflict */
+ /* RFC 2131 3.1.5, Client-server interaction
+ * RFC 3927 2.2.1, Probe Conflict Detection */
if (state->offer &&
(reply_s == state->offer->yiaddr ||
- (reply_s == 0 && reply_t == state->offer->yiaddr)))
+ (reply_s == 0 && reply_t == state->offer->yiaddr)))
state->fail.s_addr = state->offer->yiaddr;
- /* Handle IPv4LL conflicts */
+ /* RFC 3927 2.5, Conflict Defense */
if (IN_LINKLOCAL(htonl(state->addr.s_addr)) &&
- (reply_s == state->addr.s_addr ||
- (reply_s == 0 && reply_t == state->addr.s_addr)))
+ reply_s == state->addr.s_addr)
state->fail.s_addr = state->addr.s_addr;
if (state->fail.s_addr) {
syslog(LOG_ERR, "%s: hardware address %s claims %s",
ifp->name,
hwaddr_ntoa((unsigned char *)hw_s,
- (size_t)ar.ar_hln),
+ (size_t)ar.ar_hln, hwbuf, sizeof(hwbuf)),
inet_ntoa(state->fail));
errno = EEXIST;
arp_failure(ifp);
@@ -228,12 +241,13 @@
syslog(LOG_ERR, "%s: %s: %m", __func__, ifp->name);
return;
}
- eloop_event_add(state->arp_fd, arp_packet, ifp);
+ eloop_event_add(ifp->ctx->eloop,
+ state->arp_fd, arp_packet, ifp);
}
if (++state->claims < ANNOUNCE_NUM)
syslog(LOG_DEBUG,
"%s: sending ARP announce (%d of %d), "
- "next in %d.00 seconds",
+ "next in %d.0 seconds",
ifp->name, state->claims, ANNOUNCE_NUM, ANNOUNCE_WAIT);
else
syslog(LOG_DEBUG,
@@ -243,10 +257,14 @@
state->new->yiaddr, state->new->yiaddr) == -1)
syslog(LOG_ERR, "send_arp: %m");
if (state->claims < ANNOUNCE_NUM) {
- eloop_timeout_add_sec(ANNOUNCE_WAIT, arp_announce, ifp);
+ eloop_timeout_add_sec(ifp->ctx->eloop,
+ ANNOUNCE_WAIT, arp_announce, ifp);
return;
}
if (state->new->cookie != htonl(MAGIC_COOKIE)) {
+ /* Check if doing DHCP */
+ if (!(ifp->options->options & DHCPCD_DHCP))
+ return;
/* We should pretend to be at the end
* of the DHCP negotation cycle unless we rebooted */
if (state->interval != 0)
@@ -256,9 +274,9 @@
tv.tv_sec = state->interval - DHCP_RAND_MIN;
tv.tv_usec = arc4random() % (DHCP_RAND_MAX_U - DHCP_RAND_MIN_U);
timernorm(&tv);
- eloop_timeout_add_tv(&tv, dhcp_discover, ifp);
+ eloop_timeout_add_tv(ifp->ctx->eloop, &tv, dhcp_discover, ifp);
} else {
- eloop_event_delete(state->arp_fd);
+ eloop_event_delete(ifp->ctx->eloop, state->arp_fd);
close(state->arp_fd);
state->arp_fd = -1;
}
@@ -279,7 +297,8 @@
syslog(LOG_ERR, "%s: %s: %m", __func__, ifp->name);
return;
}
- eloop_event_add(state->arp_fd, arp_packet, ifp);
+ eloop_event_add(ifp->ctx->eloop,
+ state->arp_fd, arp_packet, ifp);
}
if (state->arping_index < ifp->options->arping_len) {
@@ -305,21 +324,24 @@
tv.tv_sec = PROBE_MIN;
tv.tv_usec = arc4random() % (PROBE_MAX_U - PROBE_MIN_U);
timernorm(&tv);
- eloop_timeout_add_tv(&tv, arp_probe, ifp);
+ eloop_timeout_add_tv(ifp->ctx->eloop, &tv, arp_probe, ifp);
} else {
tv.tv_sec = ANNOUNCE_WAIT;
tv.tv_usec = 0;
if (arping) {
state->probes = 0;
if (++state->arping_index < ifp->options->arping_len)
- eloop_timeout_add_tv(&tv, arp_probe, ifp);
+ eloop_timeout_add_tv(ifp->ctx->eloop,
+ &tv, arp_probe, ifp);
else
- eloop_timeout_add_tv(&tv, start_interface, ifp);
+ eloop_timeout_add_tv(ifp->ctx->eloop,
+ &tv, start_interface, ifp);
} else
- eloop_timeout_add_tv(&tv, dhcp_bind, ifp);
+ eloop_timeout_add_tv(ifp->ctx->eloop,
+ &tv, dhcp_bind, ifp);
}
syslog(LOG_DEBUG,
- "%s: sending ARP probe (%d of %d), next in %0.2f seconds",
+ "%s: sending ARP probe (%d of %d), next in %0.1f seconds",
ifp->name, state->probes ? state->probes : PROBE_NUM, PROBE_NUM,
timeval_to_double(&tv));
if (arp_send(ifp, ARPOP_REQUEST, 0, addr.s_addr) == -1)
@@ -335,3 +357,19 @@
state->arping_index = 0;
arp_probe(ifp);
}
+
+void
+arp_close(struct interface *ifp)
+{
+ struct dhcp_state *state = D_STATE(ifp);
+
+ if (state == NULL)
+ return;
+
+ if (state->arp_fd != -1) {
+ eloop_event_delete(ifp->ctx->eloop, state->arp_fd);
+ close(state->arp_fd);
+ state->arp_fd = -1;
+ }
+}
+
diff -r 9c295665b9ff -r 3c6eb6ab8125 external/bsd/dhcpcd/dist/arp.h
--- a/external/bsd/dhcpcd/dist/arp.h Tue Feb 25 13:07:29 2014 +0000
+++ b/external/bsd/dhcpcd/dist/arp.h Tue Feb 25 13:14:27 2014 +0000
@@ -1,8 +1,8 @@
-/* $NetBSD: arp.h,v 1.1.1.3 2013/06/21 19:33:08 roy Exp $ */
+/* $NetBSD: arp.h,v 1.1.1.4 2014/02/25 13:14:30 roy Exp $ */
/*
* dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2013 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2014 Roy Marples <roy%marples.name@localhost>
* All rights reserved
* Redistribution and use in source and binary forms, with or without
@@ -47,4 +47,5 @@
void arp_announce(void *);
void arp_probe(void *);
void arp_start(struct interface *);
+void arp_close(struct interface *);
#endif
diff -r 9c295665b9ff -r 3c6eb6ab8125 external/bsd/dhcpcd/dist/auth.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/dhcpcd/dist/auth.c Tue Feb 25 13:14:27 2014 +0000
@@ -0,0 +1,650 @@
+#include <sys/cdefs.h>
+ __RCSID("$NetBSD: auth.c,v 1.1.1.1 2014/02/25 13:14:30 roy Exp $");
+
+/*
+ * dhcpcd - DHCP client daemon
+ * Copyright (c) 2006-2014 Roy Marples <roy%marples.name@localhost>
+ * All rights reserved
+
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/file.h>
+#include <sys/queue.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "auth.h"
+#include "crypt/crypt.h"
+#include "dhcp.h"
+#include "dhcp6.h"
+#include "dhcpcd.h"
Home |
Main Index |
Thread Index |
Old Index