Module Name: src
Committed By: roy
Date: Wed Nov 26 13:43:06 UTC 2014
Modified Files:
src/external/bsd/dhcpcd/dist: arp.c defs.h dhcp.c dhcp6.c dhcpcd.8.in
dhcpcd.c dhcpcd.h if-options.c if-options.h if.c ipv4.c ipv4.h
ipv6nd.c
Log Message:
Sync
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/arp.c \
src/external/bsd/dhcpcd/dist/defs.h src/external/bsd/dhcpcd/dist/dhcpcd.h \
src/external/bsd/dhcpcd/dist/ipv4.c
cvs rdiff -u -r1.23 -r1.24 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/dhcp6.c \
src/external/bsd/dhcpcd/dist/if-options.h \
src/external/bsd/dhcpcd/dist/if.c src/external/bsd/dhcpcd/dist/ipv4.h
cvs rdiff -u -r1.36 -r1.37 src/external/bsd/dhcpcd/dist/dhcpcd.8.in
cvs rdiff -u -r1.17 -r1.18 src/external/bsd/dhcpcd/dist/dhcpcd.c \
src/external/bsd/dhcpcd/dist/ipv6nd.c
cvs rdiff -u -r1.18 -r1.19 src/external/bsd/dhcpcd/dist/if-options.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/dhcpcd/dist/arp.c
diff -u src/external/bsd/dhcpcd/dist/arp.c:1.7 src/external/bsd/dhcpcd/dist/arp.c:1.8
--- src/external/bsd/dhcpcd/dist/arp.c:1.7 Fri Nov 14 12:00:54 2014
+++ src/external/bsd/dhcpcd/dist/arp.c Wed Nov 26 13:43:06 2014
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: arp.c,v 1.7 2014/11/14 12:00:54 roy Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.8 2014/11/26 13:43:06 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -127,7 +127,7 @@ arp_packet(void *arg)
while (!(flags & RAW_EOF)) {
bytes = if_readrawpacket(ifp, ETHERTYPE_ARP,
arp_buffer, sizeof(arp_buffer), &flags);
- if (bytes == 0 || bytes == -1) {
+ if (bytes == -1) {
syslog(LOG_ERR, "%s: arp if_readrawpacket: %m",
ifp->name);
dhcp_close(ifp);
@@ -217,13 +217,15 @@ arp_announce1(void *arg)
if (++astate->claims < ANNOUNCE_NUM)
syslog(LOG_DEBUG,
- "%s: sending ARP announce (%d of %d), "
+ "%s: ARP announcing %s (%d of %d), "
"next in %d.0 seconds",
- ifp->name, astate->claims, ANNOUNCE_NUM, ANNOUNCE_WAIT);
+ ifp->name, inet_ntoa(astate->addr),
+ astate->claims, ANNOUNCE_NUM, ANNOUNCE_WAIT);
else
syslog(LOG_DEBUG,
- "%s: sending ARP announce (%d of %d)",
- ifp->name, astate->claims, ANNOUNCE_NUM);
+ "%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)
syslog(LOG_ERR, "send_arp: %m");
@@ -268,8 +270,9 @@ arp_probe1(void *arg)
eloop_timeout_add_tv(ifp->ctx->eloop, &tv, arp_probed, astate);
}
syslog(LOG_DEBUG,
- "%s: sending ARP probe (%d of %d), next in %0.1f seconds",
- ifp->name, astate->probes ? astate->probes : PROBE_NUM, PROBE_NUM,
+ "%s: ARP probing %s (%d of %d), next in %0.1f seconds",
+ ifp->name, inet_ntoa(astate->addr),
+ astate->probes ? astate->probes : PROBE_NUM, PROBE_NUM,
timeval_to_double(&tv));
if (arp_send(ifp, ARPOP_REQUEST, 0, astate->addr.s_addr) == -1)
syslog(LOG_ERR, "send_arp: %m");
Index: src/external/bsd/dhcpcd/dist/defs.h
diff -u src/external/bsd/dhcpcd/dist/defs.h:1.7 src/external/bsd/dhcpcd/dist/defs.h:1.8
--- src/external/bsd/dhcpcd/dist/defs.h:1.7 Fri Nov 14 12:00:54 2014
+++ src/external/bsd/dhcpcd/dist/defs.h Wed Nov 26 13:43:06 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.7 2014/11/14 12:00:54 roy Exp $ */
+/* $NetBSD: defs.h,v 1.8 2014/11/26 13:43:06 roy Exp $ */
/*
* dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "6.6.2"
+#define VERSION "6.6.3"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
Index: src/external/bsd/dhcpcd/dist/dhcpcd.h
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.h:1.7 src/external/bsd/dhcpcd/dist/dhcpcd.h:1.8
--- src/external/bsd/dhcpcd/dist/dhcpcd.h:1.7 Fri Nov 14 12:00:54 2014
+++ src/external/bsd/dhcpcd/dist/dhcpcd.h Wed Nov 26 13:43:06 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: dhcpcd.h,v 1.7 2014/11/14 12:00:54 roy Exp $ */
+/* $NetBSD: dhcpcd.h,v 1.8 2014/11/26 13:43:06 roy Exp $ */
/*
* dhcpcd - DHCP client daemon
@@ -96,6 +96,8 @@ struct dhcpcd_ctx {
char **ifdv; /* denied interfaces */
int ifc; /* listed interfaces */
char **ifv; /* listed interfaces */
+ int ifcc; /* configured interfaces */
+ char **ifcv; /* configured interfaces */
unsigned char *duid;
size_t duid_len;
int pid_fd;
Index: src/external/bsd/dhcpcd/dist/ipv4.c
diff -u src/external/bsd/dhcpcd/dist/ipv4.c:1.7 src/external/bsd/dhcpcd/dist/ipv4.c:1.8
--- src/external/bsd/dhcpcd/dist/ipv4.c:1.7 Fri Nov 14 12:00:54 2014
+++ src/external/bsd/dhcpcd/dist/ipv4.c Wed Nov 26 13:43:06 2014
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: ipv4.c,v 1.7 2014/11/14 12:00:54 roy Exp $");
+ __RCSID("$NetBSD: ipv4.c,v 1.8 2014/11/26 13:43:06 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -233,6 +233,11 @@ ipv4_ifcmp(const struct interface *si, c
return -1;
if (!sis->new && tis->new)
return 1;
+ /* Always prefer proper leases */
+ if (!(sis->added & STATE_FAKE) && (sis->added & STATE_FAKE))
+ return -1;
+ if ((sis->added & STATE_FAKE) && !(sis->added & STATE_FAKE))
+ return 1;
/* If we are either, they neither have a lease, or they both have.
* We need to check for IPv4LL and make it non-preferred. */
if (sis->new && tis->new) {
@@ -593,7 +598,7 @@ ipv4_buildroutes(struct dhcpcd_ctx *ctx)
struct rt_head *nrs, *dnr;
struct rt *or, *rt, *rtn;
struct interface *ifp;
- const struct dhcp_state *state;
+ const struct dhcp_state *state, *ostate;
nrs = malloc(sizeof(*nrs));
if (nrs == NULL) {
@@ -626,7 +631,10 @@ ipv4_buildroutes(struct dhcpcd_ctx *ctx)
rt->src.s_addr = state->addr.s_addr;
/* Do we already manage it? */
if ((or = find_route(ctx->ipv4_routes, rt, NULL))) {
- if (or->iface != ifp ||
+ if (state->added & STATE_FAKE)
+ continue;
+ if (or->flags & STATE_FAKE ||
+ or->iface != ifp ||
or->src.s_addr != state->addr.s_addr ||
rt->gate.s_addr != or->gate.s_addr ||
rt->metric != or->metric)
@@ -637,9 +645,13 @@ ipv4_buildroutes(struct dhcpcd_ctx *ctx)
TAILQ_REMOVE(ctx->ipv4_routes, or, next);
free(or);
} else {
- if (n_route(rt) != 0)
+ if (!(state->added & STATE_FAKE) &&
+ n_route(rt) != 0)
continue;
}
+ rt->flags = STATE_ADDED;
+ if (state->added & STATE_FAKE)
+ rt->flags |= STATE_FAKE;
TAILQ_REMOVE(dnr, rt, next);
TAILQ_INSERT_TAIL(nrs, rt, next);
}
@@ -789,7 +801,8 @@ ipv4_applyaddr(void *arg)
} else {
ipv4_addaddr(ifn,
&nstate->lease);
- nstate->added = 1;
+ nstate->added =
+ STATE_ADDED;
}
break;
}
@@ -866,7 +879,7 @@ ipv4_applyaddr(void *arg)
state->addr.s_addr != 0)
delete_address(ifp);
- state->added = 1;
+ state->added = STATE_ADDED;
state->defend = 0;
state->addr.s_addr = lease->addr.s_addr;
state->net.s_addr = lease->net.s_addr;
Index: src/external/bsd/dhcpcd/dist/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/dhcp.c:1.23 src/external/bsd/dhcpcd/dist/dhcp.c:1.24
--- src/external/bsd/dhcpcd/dist/dhcp.c:1.23 Fri Nov 14 12:00:54 2014
+++ src/external/bsd/dhcpcd/dist/dhcp.c Wed Nov 26 13:43:06 2014
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp.c,v 1.23 2014/11/14 12:00:54 roy Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.24 2014/11/26 13:43:06 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -1599,7 +1599,8 @@ send_message(struct interface *iface, ui
if (dhcp_open(iface) == -1)
return;
- if (state->added && state->addr.s_addr != INADDR_ANY &&
+ if (state->added && !(state->added & STATE_FAKE) &&
+ state->addr.s_addr != INADDR_ANY &&
state->new != NULL &&
(state->new->cookie == htonl(MAGIC_COOKIE) ||
iface->options->options & DHCPCD_INFORM))
@@ -1967,15 +1968,15 @@ applyaddr:
if (ifo->options & DHCPCD_ARP) {
if (state->added) {
if (astate == NULL) {
- /* We don't care about what happens
- * to the ARP announcement */
astate = arp_new(ifp);
+ astate->addr = state->addr;
astate->announced_cb =
dhcp_arp_announced;
}
if (astate) {
arp_announce(astate);
- arp_free_but(astate);
+ if (!ipv4ll)
+ arp_free_but(astate);
}
} else if (!ipv4ll)
arp_close(ifp);
@@ -2185,6 +2186,7 @@ dhcp_drop(struct interface *ifp, const c
dhcp_auth_reset(&state->auth);
dhcp_close(ifp);
}
+
if (ifp->options->options & DHCPCD_RELEASE) {
unlink(state->leasefile);
if (ifp->carrier != LINK_DOWN &&
@@ -2203,6 +2205,7 @@ dhcp_drop(struct interface *ifp, const c
#endif
}
}
+
free(state->old);
state->old = state->new;
state->new = NULL;
@@ -2785,7 +2788,7 @@ dhcp_handlepacket(void *arg)
while (!(flags & RAW_EOF)) {
bytes = (size_t)if_readrawpacket(ifp, ETHERTYPE_IP,
ifp->ctx->packet, udp_dhcp_len, &flags);
- if (bytes == 0 || (ssize_t)bytes == -1) {
+ if ((ssize_t)bytes == -1) {
syslog(LOG_ERR, "%s: dhcp if_readrawpacket: %m",
ifp->name);
dhcp_close(ifp);
@@ -2793,7 +2796,7 @@ dhcp_handlepacket(void *arg)
break;
}
if (valid_udp_packet(ifp->ctx->packet, bytes,
- &from, flags & RAW_PARTIALCSUM) == -1)
+ &from, flags & RAW_PARTIALCSUM) == -1)
{
syslog(LOG_ERR, "%s: invalid UDP packet from %s",
ifp->name, inet_ntoa(from));
@@ -3129,6 +3132,24 @@ dhcp_start1(void *arg)
if (state->offer) {
get_lease(ifp->ctx, &state->lease, state->offer);
state->lease.frominfo = 1;
+ if (state->new == NULL &&
+ ipv4_iffindaddr(ifp, &state->lease.addr, &state->lease.net))
+ {
+ /* We still have the IP address from the last lease.
+ * Fake add the address and routes from it so the lease
+ * can be cleaned up. */
+ state->new = malloc(sizeof(*state->new));
+ if (state->new) {
+ memcpy(state->new, state->offer,
+ sizeof(*state->new));
+ state->addr = state->lease.addr;
+ state->net = state->lease.net;
+ state->added |= STATE_ADDED | STATE_FAKE;
+ ipv4_sortinterfaces(ifp->ctx);
+ ipv4_buildroutes(ifp->ctx);
+ } else
+ syslog(LOG_ERR, "%s: %m", __func__);
+ }
if (state->offer->cookie == 0) {
if (state->offer->yiaddr == state->addr.s_addr) {
free(state->offer);
@@ -3148,6 +3169,22 @@ dhcp_start1(void *arg)
free(state->offer);
state->offer = NULL;
state->lease.addr.s_addr = 0;
+ /* Technically we should discard the lease
+ * as it's expired, just as DHCPv6 addresses
+ * would be by the kernel.
+ * However, this may violate POLA so
+ * we currently leave it be.
+ * If we get a totally different lease from
+ * the DHCP server we'll drop it anyway, as
+ * we will on any other event which would
+ * trigger a lease drop.
+ * This should only happen if dhcpcd stops
+ * running and the lease expires before
+ * dhcpcd starts again. */
+#if 0
+ if (state->new)
+ dhcp_drop(ifp, "EXPIRE");
+#endif
} else {
l = (uint32_t)(now.tv_sec - st.st_mtime);
state->lease.leasetime -= l;
@@ -3171,7 +3208,8 @@ dhcp_start1(void *arg)
if (state->offer == NULL || state->offer->cookie == 0) {
/* If we don't have an address yet, enter the reboot
* state to ensure at least fallback in short order. */
- if (state->addr.s_addr == INADDR_ANY)
+ if (state->addr.s_addr == INADDR_ANY ||
+ state->added & STATE_FAKE)
state->state = DHS_REBOOT;
dhcp_discover(ifp);
} else
Index: src/external/bsd/dhcpcd/dist/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/dhcp6.c:1.6 src/external/bsd/dhcpcd/dist/dhcp6.c:1.7
--- src/external/bsd/dhcpcd/dist/dhcp6.c:1.6 Fri Nov 7 20:51:02 2014
+++ src/external/bsd/dhcpcd/dist/dhcp6.c Wed Nov 26 13:43:06 2014
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp6.c,v 1.6 2014/11/07 20:51:02 roy Exp $");
+ __RCSID("$NetBSD: dhcp6.c,v 1.7 2014/11/26 13:43:06 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -2554,7 +2554,7 @@ dhcp6_handledata(void *arg)
ctx = dhcpcd_ctx->ipv6;
ctx->rcvhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
bytes = recvmsg(ctx->dhcp_fd, &ctx->rcvhdr, 0);
- if (bytes == -1 || bytes == 0) {
+ if (bytes == -1) {
syslog(LOG_ERR, "recvmsg: %m");
close(ctx->dhcp_fd);
eloop_event_delete(dhcpcd_ctx->eloop, ctx->dhcp_fd, 0);
@@ -2565,7 +2565,7 @@ dhcp6_handledata(void *arg)
ctx->sfrom = inet_ntop(AF_INET6, &ctx->from.sin6_addr,
ctx->ntopbuf, sizeof(ctx->ntopbuf));
if (len < sizeof(struct dhcp6_message)) {
- syslog(LOG_ERR, "DHCPv6 RA packet too short from %s",
+ syslog(LOG_ERR, "DHCPv6 packet too short from %s",
ctx->sfrom);
return;
}
Index: src/external/bsd/dhcpcd/dist/if-options.h
diff -u src/external/bsd/dhcpcd/dist/if-options.h:1.6 src/external/bsd/dhcpcd/dist/if-options.h:1.7
--- src/external/bsd/dhcpcd/dist/if-options.h:1.6 Fri Nov 7 20:51:02 2014
+++ src/external/bsd/dhcpcd/dist/if-options.h Wed Nov 26 13:43:06 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: if-options.h,v 1.6 2014/11/07 20:51:02 roy Exp $ */
+/* $NetBSD: if-options.h,v 1.7 2014/11/26 13:43:06 roy Exp $ */
/*
* dhcpcd - DHCP client daemon
@@ -65,7 +65,6 @@
#define DHCPCD_LASTLEASE (1ULL << 7)
#define DHCPCD_INFORM (1ULL << 8)
#define DHCPCD_REQUEST (1ULL << 9)
-
#define DHCPCD_IPV4LL (1ULL << 10)
#define DHCPCD_DUID (1ULL << 11)
#define DHCPCD_PERSISTENT (1ULL << 12)
Index: src/external/bsd/dhcpcd/dist/if.c
diff -u src/external/bsd/dhcpcd/dist/if.c:1.6 src/external/bsd/dhcpcd/dist/if.c:1.7
--- src/external/bsd/dhcpcd/dist/if.c:1.6 Fri Nov 7 20:51:02 2014
+++ src/external/bsd/dhcpcd/dist/if.c Wed Nov 26 13:43:06 2014
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: if.c,v 1.6 2014/11/07 20:51:02 roy Exp $");
+ __RCSID("$NetBSD: if.c,v 1.7 2014/11/26 13:43:06 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -169,6 +169,18 @@ if_setflag(struct interface *ifp, short
return r;
}
+static int
+if_hasconf(struct dhcpcd_ctx *ctx, const char *ifname)
+{
+ int i;
+
+ for (i = 0; i < ctx->ifcc; i++) {
+ if (strcmp(ctx->ifcv[i], ifname) == 0)
+ return 1;
+ }
+ return 0;
+}
+
struct if_head *
if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
{
@@ -286,6 +298,13 @@ if_discover(struct dhcpcd_ctx *ctx, int
if (!dev_initialized(ctx, p))
continue;
+ /* Don't allow loopback or pointopoint unless explicit */
+ if (ifa->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) {
+ if ((argc == 0 || argc == -1) &&
+ ctx->ifac == 0 && !if_hasconf(ctx, p))
+ continue;
+ }
+
if (if_vimaster(p) == 1) {
syslog(argc ? LOG_ERR : LOG_DEBUG,
"%s: is a Virtual Interface Master, skipping", p);
@@ -303,13 +322,7 @@ if_discover(struct dhcpcd_ctx *ctx, int
ifp->carrier = if_carrier(ifp);
sdl_type = 0;
- /* Don't allow loopback unless explicit */
- if (ifp->flags & IFF_LOOPBACK) {
- if ((argc == 0 || argc == -1) && ctx->ifac == 0) {
- if_free(ifp);
- continue;
- }
- } else if (ifa->ifa_addr != NULL) {
+ if (ifa->ifa_addr != NULL) {
#ifdef AF_LINK
sdl = (const struct sockaddr_dl *)(void *)ifa->ifa_addr;
@@ -338,8 +351,9 @@ if_discover(struct dhcpcd_ctx *ctx, int
#ifdef IFT_BRIDGE
case IFT_BRIDGE:
/* Don't allow bridge unless explicit */
- if ((argc == 0 || argc == -1)
- && ctx->ifac == 0)
+ if ((argc == 0 || argc == -1) &&
+ ctx->ifac == 0 &&
+ !if_hasconf(ctx, ifp->name))
{
if_free(ifp);
continue;
@@ -387,24 +401,29 @@ if_discover(struct dhcpcd_ctx *ctx, int
#endif
/* We only work on ethernet by default */
- if (!(ifp->flags & IFF_POINTOPOINT) &&
- ifp->family != ARPHRD_ETHER)
- {
- if ((argc == 0 || argc == -1) && ctx->ifac == 0) {
+ if (ifp->family != ARPHRD_ETHER) {
+ if ((argc == 0 || argc == -1) &&
+ ctx->ifac == 0 && !if_hasconf(ctx, ifp->name))
+ {
if_free(ifp);
continue;
}
switch (ifp->family) {
case ARPHRD_IEEE1394: /* FALLTHROUGH */
case ARPHRD_INFINIBAND:
+#ifdef ARPHRD_LOOPBACK
+ case ARPHRD_LOOPBACK:
+#endif
+#ifdef ARPHRD_PPP
+ case ARPHRD_PPP:
+#endif
/* We don't warn for supported families */
break;
default:
syslog(LOG_WARNING,
- "%s: unsupported interface type %.2x"
- ", falling back to ethernet",
- ifp->name, sdl_type);
- ifp->family = ARPHRD_ETHER;
+ "%s: unsupported interface type %.2x, "
+ "family %.2x",
+ ifp->name, sdl_type, ifp->family);
break;
}
}
Index: src/external/bsd/dhcpcd/dist/ipv4.h
diff -u src/external/bsd/dhcpcd/dist/ipv4.h:1.6 src/external/bsd/dhcpcd/dist/ipv4.h:1.7
--- src/external/bsd/dhcpcd/dist/ipv4.h:1.6 Fri Nov 7 20:51:03 2014
+++ src/external/bsd/dhcpcd/dist/ipv4.h Wed Nov 26 13:43:06 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: ipv4.h,v 1.6 2014/11/07 20:51:03 roy Exp $ */
+/* $NetBSD: ipv4.h,v 1.7 2014/11/26 13:43:06 roy Exp $ */
/*
* dhcpcd - DHCP client daemon
@@ -40,6 +40,7 @@ struct rt {
const struct interface *iface;
unsigned int metric;
struct in_addr src;
+ uint8_t flags;
};
TAILQ_HEAD(rt_head, rt);
@@ -68,6 +69,9 @@ int inet_cidrtoaddr(int, struct in_addr
uint32_t ipv4_getnetmask(uint32_t);
int ipv4_addrexists(struct dhcpcd_ctx *, const struct in_addr *);
+#define STATE_ADDED 0x01
+#define STATE_FAKE 0x02
+
void ipv4_buildroutes(struct dhcpcd_ctx *);
void ipv4_applyaddr(void *);
int ipv4_routedeleted(struct dhcpcd_ctx *, const struct rt *);
Index: src/external/bsd/dhcpcd/dist/dhcpcd.8.in
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.36 src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.37
--- src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.36 Fri Nov 7 20:51:02 2014
+++ src/external/bsd/dhcpcd/dist/dhcpcd.8.in Wed Nov 26 13:43:06 2014
@@ -1,4 +1,4 @@
-.\" $NetBSD: dhcpcd.8.in,v 1.36 2014/11/07 20:51:02 roy Exp $
+.\" $NetBSD: dhcpcd.8.in,v 1.37 2014/11/26 13:43:06 roy Exp $
.\" Copyright (c) 2006-2014 Roy Marples
.\" All rights reserved
.\"
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 30, 2014
+.Dd November 18, 2014
.Dt DHCPCD 8
.Os
.Sh NAME
@@ -102,6 +102,16 @@ It will then attempt to renew its lease
changes when the lease beings to expire or the DHCP server sends message
to renew early.
.Pp
+If any interface reports a working carrier then
+.Nm
+will try and obtain a lease before forking to the background,
+otherwise it will fork right away.
+This behaviour can be modified with the
+.Fl b , Fl Fl background
+and
+.Fl w , Fl Fl waitip
+options.
+.Pp
.Nm
is also an implementation of the BOOTP client specified in
.Li RFC 951 .
@@ -143,8 +153,11 @@ If a list of interfaces are given on the
.Nm
only works with those interfaces, otherwise
.Nm
-discovers available Ethernet interfaces.
-This is called Master mode and this behaviour can be forced with the
+discovers available Ethernet interfaces that can be configured.
+When
+.Nm
+is operating on more than one interface,
+it is called Master mode. and this behaviour can be forced with the
.Fl M , Fl Fl master
option so that an individual interface can start
.Nm
@@ -152,15 +165,6 @@ but only one instance is running.
The
.Nm dhcpcd-ui
project expects dhcpcd to be running this way.
-If any interface reports a working carrier then
-.Nm
-will try and obtain a lease before forking to the background,
-otherwise it will fork right away.
-This behaviour can be modified with the
-.Fl b , Fl Fl background
-and
-.Fl w , Fl Fl waitip
-options.
.Pp
If a single interface is given then
.Nm
Index: src/external/bsd/dhcpcd/dist/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.c:1.17 src/external/bsd/dhcpcd/dist/dhcpcd.c:1.18
--- src/external/bsd/dhcpcd/dist/dhcpcd.c:1.17 Fri Nov 14 12:00:54 2014
+++ src/external/bsd/dhcpcd/dist/dhcpcd.c Wed Nov 26 13:43:06 2014
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcpcd.c,v 1.17 2014/11/14 12:00:54 roy Exp $");
+ __RCSID("$NetBSD: dhcpcd.c,v 1.18 2014/11/26 13:43:06 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -152,6 +152,12 @@ free_globals(struct dhcpcd_ctx *ctx)
free(ctx->ifdv);
ctx->ifdv = NULL;
}
+ if (ctx->ifcc) {
+ for (; ctx->ifcc > 0; ctx->ifcc--)
+ free(ctx->ifcv[ctx->ifcc - 1]);
+ free(ctx->ifcv);
+ ctx->ifcv = NULL;
+ }
#ifdef INET
if (ctx->dhcp_opts) {
@@ -354,7 +360,8 @@ configure_interface1(struct interface *i
if (ifp->flags & IFF_NOARP ||
ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC))
ifo->options &= ~(DHCPCD_ARP | DHCPCD_IPV4LL);
- if (!(ifp->flags & (IFF_POINTOPOINT | IFF_LOOPBACK | IFF_MULTICAST)))
+ if (ifp->flags & (IFF_POINTOPOINT | IFF_LOOPBACK) ||
+ !(ifp->flags & IFF_MULTICAST))
ifo->options &= ~DHCPCD_IPV6RS;
if (ifo->metric != -1)
@@ -386,9 +393,13 @@ configure_interface1(struct interface *i
/* If we haven't specified a ClientID and our hardware address
* length is greater than DHCP_CHADDR_LEN then we enforce a ClientID
- * of the hardware address family and the hardware address. */
+ * of the hardware address family and the hardware address.
+ * If there is no hardware address and no ClientID set,
+ * force a DUID based ClientID. */
if (ifp->hwlen > DHCP_CHADDR_LEN)
ifo->options |= DHCPCD_CLIENTID;
+ else if (ifp->hwlen == 0 && !(ifo->options & DHCPCD_CLIENTID))
+ ifo->options |= DHCPCD_CLIENTID | DHCPCD_DUID;
/* Firewire and InfiniBand interfaces require ClientID and
* the broadcast option being set. */
@@ -435,19 +446,24 @@ configure_interface1(struct interface *i
* dhcpcd-6.1.0 and earlier used the interface name,
* falling back to interface index if name > 4.
*/
- memcpy(ifo->iaid, ifp->hwaddr + ifp->hwlen - sizeof(ifo->iaid),
- sizeof(ifo->iaid));
-#if 0
- len = strlen(ifp->name);
- if (len <= sizeof(ifo->iaid)) {
- memcpy(ifo->iaid, ifp->name, len);
- memset(ifo->iaid + len, 0, sizeof(ifo->iaid) - len);
- } else {
- /* IAID is the same size as a uint32_t */
- len = htonl(ifp->index);
- memcpy(ifo->iaid, &len, sizeof(len));
+ if (ifp->hwlen >= sizeof(ifo->iaid))
+ memcpy(ifo->iaid,
+ ifp->hwaddr + ifp->hwlen - sizeof(ifo->iaid),
+ sizeof(ifo->iaid));
+ else {
+ uint32_t len;
+
+ len = (uint32_t)strlen(ifp->name);
+ if (len <= sizeof(ifo->iaid)) {
+ memcpy(ifo->iaid, ifp->name, len);
+ memset(ifo->iaid + len, 0,
+ sizeof(ifo->iaid) - len);
+ } else {
+ /* IAID is the same size as a uint32_t */
+ len = htonl(ifp->index);
+ memcpy(ifo->iaid, &len, sizeof(len));
+ }
}
-#endif
ifo->options |= DHCPCD_IAID;
}
@@ -941,6 +957,23 @@ if_reboot(struct interface *ifp, int arg
}
static void
+reload_config(struct dhcpcd_ctx *ctx)
+{
+ struct if_options *ifo;
+
+ free_globals(ctx);
+ ifo = read_config(ctx, NULL, NULL, NULL);
+ add_options(ctx, NULL, ifo, ctx->argc, ctx->argv);
+ /* We need to preserve these two options. */
+ if (ctx->options & DHCPCD_MASTER)
+ ifo->options |= DHCPCD_MASTER;
+ if (ctx->options & DHCPCD_DAEMONISED)
+ ifo->options |= DHCPCD_DAEMONISED;
+ ctx->options = ifo->options;
+ free_options(ifo);
+}
+
+static void
reconf_reboot(struct dhcpcd_ctx *ctx, int action, int argc, char **argv, int oi)
{
struct if_head *ifs;
@@ -1008,7 +1041,6 @@ handle_signal1(void *arg)
struct dhcpcd_ctx *ctx;
struct dhcpcd_siginfo *si;
struct interface *ifp;
- struct if_options *ifo;
int do_release;
ctx = dhcpcd_ctx;
@@ -1027,16 +1059,7 @@ handle_signal1(void *arg)
break;
case SIGHUP:
syslog(LOG_INFO, sigmsg, "HUP", (int)si->pid, "rebinding");
- free_globals(ctx);
- ifo = read_config(ctx, NULL, NULL, NULL);
- add_options(ctx, NULL, ifo, ctx->argc, ctx->argv);
- /* We need to preserve these two options. */
- if (ctx->options & DHCPCD_MASTER)
- ifo->options |= DHCPCD_MASTER;
- if (ctx->options & DHCPCD_DAEMONISED)
- ifo->options |= DHCPCD_DAEMONISED;
- ctx->options = ifo->options;
- free_options(ifo);
+ reload_config(ctx);
/* Preserve any options passed on the commandline
* when we were started. */
reconf_reboot(ctx, 1, ctx->argc, ctx->argv,
@@ -1219,6 +1242,7 @@ dhcpcd_handleargs(struct dhcpcd_ctx *ctx
return 0;
}
+ reload_config(ctx);
/* XXX: Respect initial commandline options? */
reconf_reboot(ctx, do_reboot, argc, argv, optind);
return 0;
@@ -1701,7 +1725,7 @@ main(int argc, char **argv)
syslog(LOG_WARNING, "no interfaces have a carrier");
if (dhcpcd_daemonise(&ctx))
goto exit_success;
- } else if (t > 0) {
+ } else if (t > 0 && ctx.options & DHCPCD_DAEMONISE) {
eloop_timeout_add_sec(ctx.eloop, t,
handle_exit_timeout, &ctx);
}
Index: src/external/bsd/dhcpcd/dist/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/ipv6nd.c:1.17 src/external/bsd/dhcpcd/dist/ipv6nd.c:1.18
--- src/external/bsd/dhcpcd/dist/ipv6nd.c:1.17 Fri Nov 7 20:51:03 2014
+++ src/external/bsd/dhcpcd/dist/ipv6nd.c Wed Nov 26 13:43:06 2014
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: ipv6nd.c,v 1.17 2014/11/07 20:51:03 roy Exp $");
+ __RCSID("$NetBSD: ipv6nd.c,v 1.18 2014/11/26 13:43:06 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -1503,7 +1503,7 @@ ipv6nd_handledata(void *arg)
ctx->rcvhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
CMSG_SPACE(sizeof(int));
len = recvmsg(ctx->nd_fd, &ctx->rcvhdr, 0);
- if (len == -1 || len == 0) {
+ if (len == -1) {
syslog(LOG_ERR, "recvmsg: %m");
eloop_event_delete(dhcpcd_ctx->eloop, ctx->nd_fd, 0);
close(ctx->nd_fd);
Index: src/external/bsd/dhcpcd/dist/if-options.c
diff -u src/external/bsd/dhcpcd/dist/if-options.c:1.18 src/external/bsd/dhcpcd/dist/if-options.c:1.19
--- src/external/bsd/dhcpcd/dist/if-options.c:1.18 Fri Nov 14 12:00:54 2014
+++ src/external/bsd/dhcpcd/dist/if-options.c Wed Nov 26 13:43:06 2014
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: if-options.c,v 1.18 2014/11/14 12:00:54 roy Exp $");
+ __RCSID("$NetBSD: if-options.c,v 1.19 2014/11/26 13:43:06 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -2168,10 +2168,30 @@ read_config(struct dhcpcd_ctx *ctx,
}
/* Start of an interface block, skip if not ours */
if (strcmp(option, "interface") == 0) {
+ char **n;
+
if (ifname && line && strcmp(line, ifname) == 0)
skip = 0;
else
skip = 1;
+ if (ifname)
+ continue;
+
+ n = realloc(ctx->ifcv,
+ sizeof(char *) * ((size_t)ctx->ifcc + 1));
+ if (n == NULL) {
+ syslog(LOG_ERR, "%s: %m", __func__);
+ continue;
+ }
+ ctx->ifcv = n;
+ ctx->ifcv[ctx->ifcc] = strdup(line);
+ if (ctx->ifcv[ctx->ifcc] == NULL) {
+ syslog(LOG_ERR, "%s: %m", __func__);
+ continue;
+ }
+ ctx->ifcc++;
+ syslog(LOG_DEBUG, "allowing interface %s",
+ ctx->ifcv[ctx->ifcc - 1]);
continue;
}
/* Start of an ssid block, skip if not ours */