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.4.0 with the follow...
details: https://anonhg.NetBSD.org/src/rev/aca5f4f4a810
branches: trunk
changeset: 329949:aca5f4f4a810
user: roy <roy%NetBSD.org@localhost>
date: Sat Jun 14 20:51:03 2014 +0000
description:
Import dhcpcd-6.4.0 with the following changes:
* Only fork when the RA has a RDNSS option AND a valid prefix OR no DHCPv6 instruction.
* Handle BSD per interface rtadv kernel flag.
* Add a reject route for the delegated prefix so that unassigned prefixes don't go back upstream.
* If not specified, Delegated Prefixes will get an automatic SLA of the interface index. If the biggest SLA and the assigned prefix fits into a /64 then dhcpcd creates a /64 prefix so that SLAAC
works. If bigger than /64 is needed then dhcpcd creates one rounded upto the nearest multiple of 8. Unless a configured SLA of 0 is assigned, a reject route for the Delegated Prefix is installed to
stop unassigned addresses trying to be resolved upstream. Addresses added from Delegated Prefixes now have a default address suffix of 1 instead of using a SLAAC style address.
* Don't spam timezone updates unless its actually changed.
* Support ND6_IFF_OVERRIDE_RTADV on BSD.
* Document why we don't send both FQDN and hostname options.
* Respect RFC4861 MAX_RTR_SOLICITATION_DELAY as specified in section 6.3.7.
* RFC2131 section 4.4.1 states the client SHOULD wait a random time between one and ten seconds to desynchronize the use of DHCP at startup. Instead we wait a random time between zero and one
second to mirror the more modern IPv6RS and DHCPv6 standards unless overridden by defining RFC2131_STRICT.
* Always send a carrier as it's no longer encapsulated in the IPv4 stack. When stopping and not departed, run with the STOPPED reason but do not process it in hooks.
* Poll kernel neighbour reachability (SIOCGNBRINFO_IN6) for each router instead of sending and listening for Neighbour Soliciation/Advertisement packets. The kernel is privy to a lot more
reachability information than userland is.
* Ensure that ND6_IFF_PERFORMNUD is set.
* controlgroup option changes group ownership of the control socket.
* Should use arc4random_uniform when wanting a randon number between 1 and N. Improve the compat arc4random function a little and re-stir on fork.
* -4 and -6 are now mutually exclusive and when running on a single interface per protocol pidfiles are created. This means that other control options suchs as -x and -n will require the -4 or -6
option as well.
* Implement Stable Private Addresses for SLAAC as per RFC7217. Enable this as default in dhcpcd.conf.
* Log error condition if a new or changed Router Advertisment to avoid spamming the log.
* Add an IPv6 link-local address before upping the interface if needed. Bring an interface up when we start it and not during discovery. As such, stop waiting on carrier for a second if we did.
* Add gateway option to enable the gateway or an interface/profile. Ensure the option and require options disable the nooption option - last wins.
* Restarting ntp/yp are not critical and their initialisation continues in the background as well so we may as well background the restart commands for faster dhcpcd performance.
diffstat:
external/bsd/dhcpcd/dist/arp.c | 57 +-
external/bsd/dhcpcd/dist/auth.c | 43 +-
external/bsd/dhcpcd/dist/auth.h | 16 +-
external/bsd/dhcpcd/dist/common.c | 77 +++-
external/bsd/dhcpcd/dist/common.h | 26 +-
external/bsd/dhcpcd/dist/config.h | 6 +-
external/bsd/dhcpcd/dist/control.c | 70 +-
external/bsd/dhcpcd/dist/control.h | 4 +-
external/bsd/dhcpcd/dist/crypt/crypt.h | 4 +-
external/bsd/dhcpcd/dist/crypt/hmac_md5.c | 6 +-
external/bsd/dhcpcd/dist/crypt/md5.h | 35 +
external/bsd/dhcpcd/dist/defs.h | 9 +-
external/bsd/dhcpcd/dist/dev.h | 4 +-
external/bsd/dhcpcd/dist/dhcp-common.c | 175 ++++---
external/bsd/dhcpcd/dist/dhcp-common.h | 21 +-
external/bsd/dhcpcd/dist/dhcp.h | 30 +-
external/bsd/dhcpcd/dist/dhcp6.c | 309 +++++++-----
external/bsd/dhcpcd/dist/dhcp6.h | 22 +-
external/bsd/dhcpcd/dist/dhcpcd-embedded.c | 4 +-
external/bsd/dhcpcd/dist/dhcpcd-embedded.c.in | 36 +
external/bsd/dhcpcd/dist/dhcpcd-hooks/15-timezone | 9 +-
external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf | 8 +-
external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ypbind | 35 +-
external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in | 49 +-
external/bsd/dhcpcd/dist/dhcpcd.h | 45 +-
external/bsd/dhcpcd/dist/duid.c | 8 +-
external/bsd/dhcpcd/dist/duid.h | 8 +-
external/bsd/dhcpcd/dist/eloop.c | 9 +-
external/bsd/dhcpcd/dist/if-options.h | 13 +-
external/bsd/dhcpcd/dist/if.c | 511 +++++++++++++++++++++
external/bsd/dhcpcd/dist/if.h | 154 ++++++
external/bsd/dhcpcd/dist/ipv4.c | 106 +++-
external/bsd/dhcpcd/dist/ipv4.h | 27 +-
external/bsd/dhcpcd/dist/ipv4ll.c | 7 +-
external/bsd/dhcpcd/dist/ipv6.c | 515 ++++++++++++++++++---
external/bsd/dhcpcd/dist/ipv6.h | 42 +-
external/bsd/dhcpcd/dist/ipv6nd.h | 36 +-
external/bsd/dhcpcd/dist/script.h | 4 +-
38 files changed, 1934 insertions(+), 606 deletions(-)
diffs (truncated from 4619 to 300 lines):
diff -r 4d807523151c -r aca5f4f4a810 external/bsd/dhcpcd/dist/arp.c
--- a/external/bsd/dhcpcd/dist/arp.c Sat Jun 14 20:50:12 2014 +0000
+++ b/external/bsd/dhcpcd/dist/arp.c Sat Jun 14 20:51:03 2014 +0000
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: arp.c,v 1.1.1.11 2014/02/25 13:14:29 roy Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.1.1.12 2014/06/14 20:51:04 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -28,6 +28,12 @@
* SUCH DAMAGE.
*/
+#include <sys/socket.h>
+
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
@@ -42,14 +48,14 @@
#include "dhcp.h"
#include "dhcpcd.h"
#include "eloop.h"
+#include "if.h"
#include "if-options.h"
#include "ipv4ll.h"
-#include "net.h"
#define ARP_LEN \
(sizeof(struct arphdr) + (2 * sizeof(uint32_t)) + (2 * HWADDR_LEN))
-static int
+static ssize_t
arp_send(const struct interface *ifp, int op, in_addr_t sip, in_addr_t tip)
{
uint8_t arp_buffer[ARP_LEN];
@@ -64,15 +70,15 @@
ar.ar_op = htons(op);
p = arp_buffer;
- len = sizeof(arp_buffer);
+ len = 0;
#define CHECK(fun, b, l) \
do { \
- if (len < (l)) \
+ if (len + (l) > sizeof(arp_buffer)) \
goto eexit; \
fun(p, (b), (l)); \
p += (l); \
- len -= (l); \
+ len += (l); \
} while (/* CONSTCOND */ 0)
#define APPEND(b, l) CHECK(memcpy, b, l)
#define ZERO(l) CHECK(memset, 0, l)
@@ -82,8 +88,7 @@
APPEND(&sip, sizeof(sip));
ZERO(ifp->hwlen);
APPEND(&tip, sizeof(tip));
- len = p - arp_buffer;
- return ipv4_sendrawpacket(ifp, ETHERTYPE_ARP, arp_buffer, len);
+ return if_sendrawpacket(ifp, ETHERTYPE_ARP, arp_buffer, len);
eexit:
errno = ENOBUFS;
@@ -111,10 +116,10 @@
dhcp_decline(ifp);
eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
if (state->lease.frominfo)
- start_interface(ifp);
+ dhcpcd_startinterface(ifp);
else
eloop_timeout_add_sec(ifp->ctx->eloop,
- DHCP_ARP_FAIL, start_interface, ifp);
+ DHCP_ARP_FAIL, dhcpcd_startinterface, ifp);
}
static void
@@ -132,14 +137,20 @@
const char *hwaddr;
struct in_addr ina;
char hwbuf[HWADDR_LEN * 3];
+ int flags;
state = D_STATE(ifp);
state->fail.s_addr = 0;
- for(;;) {
- bytes = ipv4_getrawpacket(ifp, ETHERTYPE_ARP,
- arp_buffer, sizeof(arp_buffer), NULL);
- if (bytes == 0 || bytes == -1)
+ flags = 0;
+ while (!(flags & RAW_EOF)) {
+ bytes = if_readrawpacket(ifp, ETHERTYPE_ARP,
+ arp_buffer, sizeof(arp_buffer), &flags);
+ if (bytes == 0 || bytes == -1) {
+ syslog(LOG_ERR, "%s: arp if_readrawpacket: %m",
+ ifp->name);
+ dhcp_close(ifp);
return;
+ }
/* We must have a full ARP header */
if ((size_t)bytes < sizeof(ar))
continue;
@@ -181,8 +192,8 @@
syslog(LOG_INFO,
"%s: found %s on hardware address %s",
ifp->name, inet_ntoa(ina), hwaddr);
- if (select_profile(ifp, hwaddr) == -1 &&
- select_profile(ifp, inet_ntoa(ina)) == -1)
+ if (dhcpcd_selectprofile(ifp, hwaddr) == -1 &&
+ dhcpcd_selectprofile(ifp, inet_ntoa(ina)) == -1)
{
state->probes = 0;
/* We didn't find a profile for this
@@ -197,7 +208,7 @@
}
dhcp_close(ifp);
eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
- start_interface(ifp);
+ dhcpcd_startinterface(ifp);
return;
}
@@ -236,7 +247,7 @@
if (state->new == NULL)
return;
if (state->arp_fd == -1) {
- state->arp_fd = ipv4_opensocket(ifp, ETHERTYPE_ARP);
+ state->arp_fd = if_openrawsocket(ifp, ETHERTYPE_ARP);
if (state->arp_fd == -1) {
syslog(LOG_ERR, "%s: %s: %m", __func__, ifp->name);
return;
@@ -272,7 +283,8 @@
state->probes = 0;
state->claims = 0;
tv.tv_sec = state->interval - DHCP_RAND_MIN;
- tv.tv_usec = arc4random() % (DHCP_RAND_MAX_U - DHCP_RAND_MIN_U);
+ tv.tv_usec = (suseconds_t)arc4random_uniform(
+ (DHCP_RAND_MAX - DHCP_RAND_MIN) * 1000000);
timernorm(&tv);
eloop_timeout_add_tv(ifp->ctx->eloop, &tv, dhcp_discover, ifp);
} else {
@@ -292,7 +304,7 @@
int arping = 0;
if (state->arp_fd == -1) {
- state->arp_fd = ipv4_opensocket(ifp, ETHERTYPE_ARP);
+ state->arp_fd = if_openrawsocket(ifp, ETHERTYPE_ARP);
if (state->arp_fd == -1) {
syslog(LOG_ERR, "%s: %s: %m", __func__, ifp->name);
return;
@@ -322,7 +334,8 @@
}
if (++state->probes < PROBE_NUM) {
tv.tv_sec = PROBE_MIN;
- tv.tv_usec = arc4random() % (PROBE_MAX_U - PROBE_MIN_U);
+ tv.tv_usec = (suseconds_t)arc4random_uniform(
+ (PROBE_MAX - PROBE_MIN) * 1000000);
timernorm(&tv);
eloop_timeout_add_tv(ifp->ctx->eloop, &tv, arp_probe, ifp);
} else {
@@ -335,7 +348,7 @@
&tv, arp_probe, ifp);
else
eloop_timeout_add_tv(ifp->ctx->eloop,
- &tv, start_interface, ifp);
+ &tv, dhcpcd_startinterface, ifp);
} else
eloop_timeout_add_tv(ifp->ctx->eloop,
&tv, dhcp_bind, ifp);
diff -r 4d807523151c -r aca5f4f4a810 external/bsd/dhcpcd/dist/auth.c
--- a/external/bsd/dhcpcd/dist/auth.c Sat Jun 14 20:50:12 2014 +0000
+++ b/external/bsd/dhcpcd/dist/auth.c Sat Jun 14 20:51:03 2014 +0000
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: auth.c,v 1.1.1.3 2014/03/14 11:27:37 roy Exp $");
+ __RCSID("$NetBSD: auth.c,v 1.1.1.4 2014/06/14 20:51:05 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -47,6 +47,11 @@
#include "dhcp6.h"
#include "dhcpcd.h"
+#ifdef __sun
+#define htonll
+#define ntohll
+#endif
+
#ifndef htonll
#if (BYTE_ORDER == LITTLE_ENDIAN)
static inline uint64_t
@@ -54,7 +59,7 @@
{
return (uint64_t)htonl((uint32_t)(x >> 32)) |
- (int64_t)htonl((uint32_t)(x & 0xffffffff)) << 32;
+ (uint64_t)htonl((uint32_t)(x & 0xffffffff)) << 32;
}
#else /* (BYTE_ORDER == LITTLE_ENDIAN) */
#define htonll(x) (x)
@@ -68,7 +73,7 @@
{
return (uint64_t)ntohl((uint32_t)(x >> 32)) |
- (int64_t)ntohl((uint32_t)(x & 0xffffffff)) << 32;
+ (uint64_t)ntohl((uint32_t)(x & 0xffffffff)) << 32;
}
#else /* (BYTE_ORDER == LITTLE_ENDIAN) */
#define ntohll(x) (x)
@@ -104,14 +109,14 @@
*/
const struct token *
dhcp_auth_validate(struct authstate *state, const struct auth *auth,
- const uint8_t *m, unsigned int mlen, int mp, int mt,
- const uint8_t *data, unsigned int dlen)
+ const uint8_t *m, size_t mlen, int mp, int mt,
+ const uint8_t *data, size_t dlen)
{
uint8_t protocol, algorithm, rdm, *mm, type;
uint64_t replay;
uint32_t secretid;
const uint8_t *d, *realm;
- unsigned int realm_len;
+ size_t realm_len;
const struct token *t;
time_t now;
uint8_t hmac[HMAC_LENGTH];
@@ -389,7 +394,9 @@
{
FILE *fp;
uint64_t rdm;
+#ifdef LOCK_EX
int flocked;
+#endif
fp = fopen(RDM_MONOFILE, "r+");
if (fp == NULL) {
@@ -398,10 +405,14 @@
fp = fopen(RDM_MONOFILE, "w");
if (fp == NULL)
return ++auth->last_replay; /* report error? */
+#ifdef LOCK_EX
flocked = flock(fileno(fp), LOCK_EX);
+#endif
rdm = 0;
} else {
+#ifdef LOCK_EX
flocked = flock(fileno(fp), LOCK_EX);
+#endif
if (fscanf(fp, "0x%016" PRIu64, &rdm) != 1)
rdm = 0; /* truncated? report error? */
}
@@ -419,13 +430,15 @@
/* report error? */
}
fflush(fp);
+#ifdef LOCK_EX
if (flocked == 0)
flock(fileno(fp), LOCK_UN);
+#endif
fclose(fp);
return rdm;
}
-#define JAN_1970 2208988800UL /* 1970 - 1900 in seconds */
+#define JAN_1970 2208988800U /* 1970 - 1900 in seconds */
static uint64_t
get_next_rdm_monotonic_clock(struct auth *auth)
{
@@ -437,7 +450,7 @@
if (clock_gettime(CLOCK_REALTIME, &ts) != 0)
return ++auth->last_replay; /* report error? */
pack[0] = htonl((uint32_t)ts.tv_sec + JAN_1970);
- frac = (ts.tv_nsec / 1e9 * 0x100000000ULL);
+ frac = ((double)ts.tv_nsec / 1e9 * 0x100000000ULL);
pack[1] = htonl((uint32_t)frac);
memcpy(&rdm, &pack, sizeof(rdm));
@@ -463,10 +476,10 @@
* mt is the DHCP message type.
* data and dlen refer to the authentication option within the message.
*/
-int
+ssize_t
dhcp_auth_encode(struct auth *auth, const struct token *t,
- uint8_t *m, unsigned int mlen, int mp, int mt,
- uint8_t *data, unsigned int dlen)
+ uint8_t *m, size_t mlen, int mp, int mt,
+ uint8_t *data, size_t dlen)
{
uint64_t rdm;
uint8_t hmac[HMAC_LENGTH];
@@ -545,7 +558,7 @@
dlen += sizeof(t->secretid) + sizeof(hmac);
break;
Home |
Main Index |
Thread Index |
Old Index