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 Sync
details: https://anonhg.NetBSD.org/src/rev/1b6f1256e5c4
branches: trunk
changeset: 337883:1b6f1256e5c4
user: roy <roy%NetBSD.org@localhost>
date: Sat May 02 15:18:36 2015 +0000
description:
Sync
diffstat:
external/bsd/dhcpcd/dist/arp.c | 91 +++++++-
external/bsd/dhcpcd/dist/arp.h | 6 +-
external/bsd/dhcpcd/dist/common.c | 9 +-
external/bsd/dhcpcd/dist/defs.h | 4 +-
external/bsd/dhcpcd/dist/dhcp.c | 303 +++++++++++++++++++----------
external/bsd/dhcpcd/dist/dhcp.h | 11 +-
external/bsd/dhcpcd/dist/dhcp6.c | 134 +++++++------
external/bsd/dhcpcd/dist/dhcp6.h | 3 +-
external/bsd/dhcpcd/dist/dhcpcd.c | 91 ++++++--
external/bsd/dhcpcd/dist/dhcpcd.conf.5.in | 15 +-
external/bsd/dhcpcd/dist/eloop.c | 5 +-
external/bsd/dhcpcd/dist/if-bsd.c | 73 +++++-
external/bsd/dhcpcd/dist/if-options.c | 16 +-
external/bsd/dhcpcd/dist/if-options.h | 9 +-
external/bsd/dhcpcd/dist/if.c | 154 ++++++++-------
external/bsd/dhcpcd/dist/if.h | 28 ++-
external/bsd/dhcpcd/dist/ipv4.c | 294 ++++++++++++++++------------
external/bsd/dhcpcd/dist/ipv4.h | 16 +-
external/bsd/dhcpcd/dist/ipv4ll.c | 29 ++-
external/bsd/dhcpcd/dist/ipv6.c | 15 +-
external/bsd/dhcpcd/dist/ipv6.h | 16 +-
external/bsd/dhcpcd/dist/ipv6nd.c | 122 ++++++++++-
external/bsd/dhcpcd/dist/ipv6nd.h | 15 +-
external/bsd/dhcpcd/dist/script.c | 12 +-
24 files changed, 965 insertions(+), 506 deletions(-)
diffs (truncated from 3165 to 300 lines):
diff -r db8ea064db77 -r 1b6f1256e5c4 external/bsd/dhcpcd/dist/arp.c
--- a/external/bsd/dhcpcd/dist/arp.c Sat May 02 14:54:18 2015 +0000
+++ b/external/bsd/dhcpcd/dist/arp.c Sat May 02 15:18:36 2015 +0000
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: arp.c,v 1.11 2015/03/27 18:53:15 christos Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.12 2015/05/02 15:18:36 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -44,6 +44,7 @@
#define ELOOP_QUEUE 5
#include "config.h"
#include "arp.h"
+#include "if.h"
#include "ipv4.h"
#include "common.h"
#include "dhcp.h"
@@ -57,7 +58,7 @@
(sizeof(struct arphdr) + (2 * sizeof(uint32_t)) + (2 * HWADDR_LEN))
static ssize_t
-arp_send(const struct interface *ifp, int op, in_addr_t sip, in_addr_t tip)
+arp_request(const struct interface *ifp, in_addr_t sip, in_addr_t tip)
{
uint8_t arp_buffer[ARP_LEN];
struct arphdr ar;
@@ -68,7 +69,7 @@
ar.ar_pro = htons(ETHERTYPE_IP);
ar.ar_hln = ifp->hwlen;
ar.ar_pln = sizeof(sip);
- ar.ar_op = htons((uint16_t)op);
+ ar.ar_op = htons(ARPOP_REQUEST);
p = arp_buffer;
len = 0;
@@ -99,12 +100,20 @@
void
arp_report_conflicted(const struct arp_state *astate, const struct arp_msg *amsg)
{
- char buf[HWADDR_LEN * 3];
+
+ if (amsg) {
+ char buf[HWADDR_LEN * 3];
- logger(astate->iface->ctx, LOG_ERR, "%s: hardware address %s claims %s",
- astate->iface->name,
- hwaddr_ntoa(amsg->sha, astate->iface->hwlen, buf, sizeof(buf)),
- inet_ntoa(astate->failed));
+ logger(astate->iface->ctx, LOG_ERR,
+ "%s: hardware address %s claims %s",
+ astate->iface->name,
+ hwaddr_ntoa(amsg->sha, astate->iface->hwlen,
+ buf, sizeof(buf)),
+ inet_ntoa(astate->failed));
+ } else
+ logger(astate->iface->ctx, LOG_ERR,
+ "%s: DAD detected %s",
+ astate->iface->name, inet_ntoa(astate->failed));
}
static void
@@ -226,8 +235,7 @@
"%s: ARP announcing %s (%d of %d)",
ifp->name, inet_ntoa(astate->addr),
astate->claims, ANNOUNCE_NUM);
- if (arp_send(ifp, ARPOP_REQUEST,
- astate->addr.s_addr, astate->addr.s_addr) == -1)
+ if (arp_request(ifp, astate->addr.s_addr, astate->addr.s_addr) == -1)
logger(ifp->ctx, LOG_ERR, "send_arp: %m");
eloop_timeout_add_sec(ifp->ctx->eloop, ANNOUNCE_WAIT,
astate->claims < ANNOUNCE_NUM ? arp_announce1 : arp_announced,
@@ -274,7 +282,7 @@
ifp->name, inet_ntoa(astate->addr),
astate->probes ? astate->probes : PROBE_NUM, PROBE_NUM,
timespec_to_double(&tv));
- if (arp_send(ifp, ARPOP_REQUEST, 0, astate->addr.s_addr) == -1)
+ if (arp_request(ifp, 0, astate->addr.s_addr) == -1)
logger(ifp->ctx, LOG_ERR, "send_arp: %m");
}
@@ -289,19 +297,38 @@
arp_probe1(astate);
}
-struct arp_state *
-arp_new(struct interface *ifp) {
+static struct arp_state *
+arp_find(struct interface *ifp, const struct in_addr *addr)
+{
struct arp_state *astate;
struct dhcp_state *state;
- astate = calloc(1, sizeof(*astate));
- if (astate == NULL) {
+ state = D_STATE(ifp);
+ TAILQ_FOREACH(astate, &state->arp_states, next) {
+ if (astate->addr.s_addr == addr->s_addr && astate->iface == ifp)
+ return astate;
+ }
+ errno = ESRCH;
+ return NULL;
+}
+
+struct arp_state *
+arp_new(struct interface *ifp, const struct in_addr *addr)
+{
+ struct arp_state *astate;
+ struct dhcp_state *state;
+
+ if (addr && (astate = arp_find(ifp, addr)))
+ return astate;
+
+ if ((astate = calloc(1, sizeof(*astate))) == NULL) {
logger(ifp->ctx, LOG_ERR, "%s: %s: %m", ifp->name, __func__);
return NULL;
}
-
+ state = D_STATE(ifp);
astate->iface = ifp;
- state = D_STATE(ifp);
+ if (addr)
+ astate->addr = *addr;
TAILQ_INSERT_TAIL(&state->arp_states, astate, next);
return astate;
}
@@ -366,3 +393,33 @@
#endif
}
}
+
+void
+arp_handleifa(int cmd, struct interface *ifp, const struct in_addr *addr,
+ int flags)
+{
+#ifdef IN_IFF_DUPLICATED
+ struct dhcp_state *state = D_STATE(ifp);
+ struct arp_state *astate, *asn;
+
+ if (cmd != RTM_NEWADDR || (state = D_STATE(ifp)) == NULL)
+ return;
+
+ TAILQ_FOREACH_SAFE(astate, &state->arp_states, next, asn) {
+ if (astate->addr.s_addr == addr->s_addr) {
+ if (flags & IN_IFF_DUPLICATED) {
+ if (astate->conflicted_cb)
+ astate->conflicted_cb(astate, NULL);
+ } else if (!(flags & IN_IFF_NOTUSEABLE)) {
+ if (astate->probed_cb)
+ astate->probed_cb(astate);
+ }
+ }
+ }
+#else
+ UNUSED(cmd);
+ UNUSED(ifp);
+ UNUSED(addr);
+ UNUSED(flags);
+#endif
+}
diff -r db8ea064db77 -r 1b6f1256e5c4 external/bsd/dhcpcd/dist/arp.h
--- a/external/bsd/dhcpcd/dist/arp.h Sat May 02 14:54:18 2015 +0000
+++ b/external/bsd/dhcpcd/dist/arp.h Sat May 02 15:18:36 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arp.h,v 1.8 2015/01/30 09:47:05 roy Exp $ */
+/* $NetBSD: arp.h,v 1.9 2015/05/02 15:18:36 roy Exp $ */
/*
* dhcpcd - DHCP client daemon
@@ -71,11 +71,13 @@
void arp_report_conflicted(const struct arp_state *, const struct arp_msg *);
void arp_announce(struct arp_state *);
void arp_probe(struct arp_state *);
-struct arp_state *arp_new(struct interface *);
+struct arp_state *arp_new(struct interface *, const struct in_addr *);
void arp_cancel(struct arp_state *);
void arp_free(struct arp_state *);
void arp_free_but(struct arp_state *);
void arp_close(struct interface *);
+
+void arp_handleifa(int, struct interface *, const struct in_addr *, int);
#else
#define arp_close(a) {}
#endif
diff -r db8ea064db77 -r 1b6f1256e5c4 external/bsd/dhcpcd/dist/common.c
--- a/external/bsd/dhcpcd/dist/common.c Sat May 02 14:54:18 2015 +0000
+++ b/external/bsd/dhcpcd/dist/common.c Sat May 02 15:18:36 2015 +0000
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: common.c,v 1.11 2015/03/31 18:01:09 christos Exp $");
+ __RCSID("$NetBSD: common.c,v 1.12 2015/05/02 15:18:36 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -28,11 +28,6 @@
* SUCH DAMAGE.
*/
-/* Needed define to get at getline for glibc and FreeBSD */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE
-#endif
-
#ifdef __APPLE__
# include <mach/mach_time.h>
# include <mach/kern_return.h>
@@ -196,8 +191,8 @@
return;
serrno = errno;
+ va_start(va, fmt);
- va_start(va, fmt);
#ifndef HAVE_PRINTF_M
/* Print strerrno(errno) in place of %m */
if (ctx == NULL || !(ctx->options & DHCPCD_QUIET) || ctx->log_fd != -1)
diff -r db8ea064db77 -r 1b6f1256e5c4 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h Sat May 02 14:54:18 2015 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h Sat May 02 15:18:36 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.16 2015/03/27 11:33:46 roy Exp $ */
+/* $NetBSD: defs.h,v 1.17 2015/05/02 15:18:36 roy Exp $ */
/*
* dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "6.8.1"
+#define VERSION "6.8.2"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
diff -r db8ea064db77 -r 1b6f1256e5c4 external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c Sat May 02 14:54:18 2015 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c Sat May 02 15:18:36 2015 +0000
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp.c,v 1.29 2015/03/28 14:16:52 christos Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.30 2015/05/02 15:18:36 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -163,6 +163,12 @@
const uint8_t *op = NULL;
size_t bl = 0;
+ /* Check we have the magic cookie */
+ if (dhcp->cookie != htonl(MAGIC_COOKIE)) {
+ errno = ENOTSUP;
+ return NULL;
+ }
+
while (p < e) {
o = *p++;
if (o == opt) {
@@ -621,11 +627,11 @@
p = get_option(ifp->ctx, dhcp, DHO_STATICROUTE, &len);
else
p = NULL;
- if (p) {
+ /* RFC 2131 Section 5.8 states length MUST be in multiples of 8 */
+ if (p && len % 8 == 0) {
e = p + len;
while (p < e) {
- route = calloc(1, sizeof(*route));
- if (route == NULL) {
+ if ((route = calloc(1, sizeof(*route))) == NULL) {
logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
ipv4_freeroutes(routes);
return NULL;
@@ -634,6 +640,13 @@
p += 4;
memcpy(&route->gate.s_addr, p, 4);
p += 4;
+ /* RFC 2131 Section 5.8 states default route is
+ * illegal */
+ if (route->dest.s_addr == htonl(INADDR_ANY)) {
+ errno = EINVAL;
+ free(route);
+ continue;
+ }
route->net.s_addr = route_netmask(route->dest.s_addr);
TAILQ_INSERT_TAIL(routes, route, next);
}
@@ -647,8 +660,7 @@
if (p) {
e = p + len;
while (p < e) {
- route = calloc(1, sizeof(*route));
- if (route == NULL) {
+ if ((route = calloc(1, sizeof(*route))) == NULL) {
logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
ipv4_freeroutes(routes);
return NULL;
@@ -701,10 +713,10 @@
{
struct dhcp_message *dhcp;
uint8_t *m, *lp, *p, *auth;
Home |
Main Index |
Thread Index |
Old Index