Module Name: src
Committed By: roy
Date: Mon Aug 15 11:04:53 UTC 2016
Modified Files:
src/external/bsd/dhcpcd/dist: defs.h dhcp.c dhcp6.c dhcpcd.8.in eloop.c
if-bsd.c ipv4.c ipv6.c ipv6nd.c
Log Message:
Sync
To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/external/bsd/dhcpcd/dist/defs.h
cvs rdiff -u -r1.44 -r1.45 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.23 -r1.24 src/external/bsd/dhcpcd/dist/dhcp6.c
cvs rdiff -u -r1.49 -r1.50 src/external/bsd/dhcpcd/dist/dhcpcd.8.in
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/dhcpcd/dist/eloop.c
cvs rdiff -u -r1.32 -r1.33 src/external/bsd/dhcpcd/dist/if-bsd.c
cvs rdiff -u -r1.24 -r1.25 src/external/bsd/dhcpcd/dist/ipv4.c
cvs rdiff -u -r1.20 -r1.21 src/external/bsd/dhcpcd/dist/ipv6.c
cvs rdiff -u -r1.31 -r1.32 src/external/bsd/dhcpcd/dist/ipv6nd.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/defs.h
diff -u src/external/bsd/dhcpcd/dist/defs.h:1.29 src/external/bsd/dhcpcd/dist/defs.h:1.30
--- src/external/bsd/dhcpcd/dist/defs.h:1.29 Fri Jul 29 10:07:57 2016
+++ src/external/bsd/dhcpcd/dist/defs.h Mon Aug 15 11:04:53 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.29 2016/07/29 10:07:57 roy Exp $ */
+/* $NetBSD: defs.h,v 1.30 2016/08/15 11:04:53 roy Exp $ */
/*
* dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "6.11.2"
+#define VERSION "6.11.3"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
Index: src/external/bsd/dhcpcd/dist/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/dhcp.c:1.44 src/external/bsd/dhcpcd/dist/dhcp.c:1.45
--- src/external/bsd/dhcpcd/dist/dhcp.c:1.44 Fri Jul 29 10:07:57 2016
+++ src/external/bsd/dhcpcd/dist/dhcp.c Mon Aug 15 11:04:53 2016
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp.c,v 1.44 2016/07/29 10:07:57 roy Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.45 2016/08/15 11:04:53 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -1541,7 +1541,6 @@ dhcp_openudp(struct interface *ifp)
struct dhcp_state *state;
#ifdef SO_BINDTODEVICE
struct ifreq ifr;
- char *p;
#endif
if ((s = xsocket(PF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP)) == -1)
@@ -1554,10 +1553,6 @@ dhcp_openudp(struct interface *ifp)
if (ifp) {
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name));
- /* We can only bind to the real device */
- p = strchr(ifr.ifr_name, ':');
- if (p)
- *p = '\0';
if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, &ifr,
sizeof(ifr)) == -1)
goto eexit;
@@ -2401,6 +2396,7 @@ dhcp_inform(struct interface *ifp)
state->state = DHS_INFORM;
free(state->offer);
state->offer = NULL;
+ state->offer_len = 0;
if (ifo->req_addr.s_addr == INADDR_ANY) {
ia = ipv4_iffindaddr(ifp, NULL, NULL);
@@ -2976,8 +2972,8 @@ dhcp_handledhcp(struct interface *ifp, s
return;
}
}
- memcpy(state->offer, bootp, bootp_len);
state->offer_len = bootp_len;
+ memcpy(state->offer, bootp, bootp_len);
bootp_copied = true;
if (ifp->ctx->options & DHCPCD_TEST) {
free(state->old);
@@ -3054,8 +3050,8 @@ rapidcommit:
return;
}
}
- memcpy(state->offer, bootp, bootp_len);
state->offer_len = bootp_len;
+ memcpy(state->offer, bootp, bootp_len);
}
lease->frominfo = 0;
@@ -3439,6 +3435,7 @@ dhcp_start1(void *arg)
clock_gettime(CLOCK_MONOTONIC, &state->started);
free(state->offer);
state->offer = NULL;
+ state->offer_len = 0;
if (state->arping_index < ifo->arping_len) {
struct arp_state *astate;
@@ -3495,6 +3492,7 @@ dhcp_start1(void *arg)
{
free(state->offer);
state->offer = NULL;
+ state->offer_len = 0;
}
}
}
@@ -3660,7 +3658,7 @@ dhcp_handleifa(int cmd, struct ipv4_addr
if (cmd == RTM_DELADDR) {
if (IPV4_BRD_EQ(state->addr, ia)) {
logger(ifp->ctx, LOG_INFO,
- "%s: removing IP address %s", ifp->name, ia->saddr);
+ "%s: deleted IP address %s", ifp->name, ia->saddr);
dhcp_drop(ifp, "EXPIRE");
}
return;
Index: src/external/bsd/dhcpcd/dist/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/dhcp6.c:1.23 src/external/bsd/dhcpcd/dist/dhcp6.c:1.24
--- src/external/bsd/dhcpcd/dist/dhcp6.c:1.23 Fri Jul 29 10:07:57 2016
+++ src/external/bsd/dhcpcd/dist/dhcp6.c Mon Aug 15 11:04:53 2016
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp6.c,v 1.23 2016/07/29 10:07:57 roy Exp $");
+ __RCSID("$NetBSD: dhcp6.c,v 1.24 2016/08/15 11:04:53 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -3177,6 +3177,22 @@ dhcp6_open(struct dhcpcd_ctx *dctx)
logger(dctx, LOG_WARNING, "setsockopt: SO_REUSEPORT: %m");
#endif
+ if (!(dctx->options & DHCPCD_MASTER)) {
+ /* Bind to the link-local address to allow more than one
+ * DHCPv6 client to work. */
+ struct interface *ifp;
+ struct ipv6_addr *ia;
+
+ TAILQ_FOREACH(ifp, dctx->ifaces, next) {
+ if (ifp->active)
+ break;
+ }
+ if (ifp != NULL && (ia = ipv6_linklocal(ifp)) != NULL) {
+ memcpy(&sa.sin6_addr, &ia->addr, sizeof(sa.sin6_addr));
+ sa.sin6_scope_id = ifp->index;
+ }
+ }
+
if (bind(ctx->dhcp_fd, (struct sockaddr *)&sa, sizeof(sa)) == -1)
goto errexit;
@@ -3233,6 +3249,9 @@ dhcp6_start1(void *arg)
size_t i;
const struct dhcp_compat *dhc;
+ if (ifp->ctx->ipv6->dhcp_fd == -1 && dhcp6_open(ifp->ctx) == -1)
+ return;
+
state = D6_STATE(ifp);
/* If no DHCPv6 options are configured,
match configured DHCPv4 options to DHCPv6 equivalents. */
@@ -3297,9 +3316,6 @@ dhcp6_start(struct interface *ifp, enum
if (!(ifp->options->options & DHCPCD_DHCP6))
return 0;
- if (ifp->ctx->ipv6->dhcp_fd == -1 && dhcp6_open(ifp->ctx) == -1)
- return -1;
-
ifp->if_data[IF_DATA_DHCP6] = calloc(1, sizeof(*state));
state = D6_STATE(ifp);
if (state == NULL)
Index: src/external/bsd/dhcpcd/dist/dhcpcd.8.in
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.49 src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.50
--- src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.49 Fri Jul 29 10:07:57 2016
+++ src/external/bsd/dhcpcd/dist/dhcpcd.8.in Mon Aug 15 11:04:53 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: dhcpcd.8.in,v 1.49 2016/07/29 10:07:57 roy Exp $
+.\" $NetBSD: dhcpcd.8.in,v 1.50 2016/08/15 11:04:53 roy Exp $
.\" Copyright (c) 2006-2016 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 July 27, 2016
+.Dd August 15, 2016
.Dt DHCPCD 8
.Os
.Sh NAME
@@ -636,7 +636,7 @@ Don't use IPv4LL (aka APIPA, aka Bonjour
Removes the
.Ar option
from the DHCP message before processing.
-.It Fl P , Fl FL printpidfile
+.It Fl P , Fl Fl printpidfile
Print the
.Pa pidfile
.Nm
Index: src/external/bsd/dhcpcd/dist/eloop.c
diff -u src/external/bsd/dhcpcd/dist/eloop.c:1.14 src/external/bsd/dhcpcd/dist/eloop.c:1.15
--- src/external/bsd/dhcpcd/dist/eloop.c:1.14 Mon May 9 10:15:59 2016
+++ src/external/bsd/dhcpcd/dist/eloop.c Mon Aug 15 11:04:53 2016
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: eloop.c,v 1.14 2016/05/09 10:15:59 roy Exp $");
+ __RCSID("$NetBSD: eloop.c,v 1.15 2016/08/15 11:04:53 roy Exp $");
/*
* eloop - portable event based main loop.
@@ -747,20 +747,20 @@ int
eloop_signal_mask(struct eloop *eloop, sigset_t *oldset)
{
sigset_t newset;
-#ifndef HAVE_KQUEUE
size_t i;
+#ifndef HAVE_KQUEUE
struct sigaction sa;
#endif
assert(eloop != NULL);
- sigfillset(&newset);
+ sigemptyset(&newset);
+ for (i = 0; i < eloop->signals_len; i++)
+ sigaddset(&newset, eloop->signals[i]);
if (sigprocmask(SIG_SETMASK, &newset, oldset) == -1)
return -1;
-#ifdef HAVE_KQUEUE
- UNUSED(eloop);
-#else
+#ifndef HAVE_KQUEUE
memset(&sa, 0, sizeof(sa));
sa.sa_sigaction = eloop_signal3;
sa.sa_flags = SA_SIGINFO;
Index: src/external/bsd/dhcpcd/dist/if-bsd.c
diff -u src/external/bsd/dhcpcd/dist/if-bsd.c:1.32 src/external/bsd/dhcpcd/dist/if-bsd.c:1.33
--- src/external/bsd/dhcpcd/dist/if-bsd.c:1.32 Fri Jul 29 10:07:58 2016
+++ src/external/bsd/dhcpcd/dist/if-bsd.c Mon Aug 15 11:04:53 2016
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: if-bsd.c,v 1.32 2016/07/29 10:07:58 roy Exp $");
+ __RCSID("$NetBSD: if-bsd.c,v 1.33 2016/08/15 11:04:53 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -912,6 +912,8 @@ if_address6(unsigned char cmd, const str
struct in6_addr mask;
struct priv *priv;
+ priv = (struct priv *)ia->iface->ctx->priv;
+
memset(&ifa, 0, sizeof(ifa));
strlcpy(ifa.ifra_name, ia->iface->name, sizeof(ifa.ifra_name));
/*
@@ -941,11 +943,48 @@ if_address6(unsigned char cmd, const str
ifa_scope(&ifa.ifra_addr, ia->iface->index);
ipv6_mask(&mask, ia->prefix_len);
ADDADDR(&ifa.ifra_prefixmask, &mask);
+
+#undef ADDADDR
+
+ /*
+ * Every BSD kernel wants to add the prefix of the address to it's
+ * list of RA received prefixes.
+ * THIS IS WRONG because there (as the comments in the kernel state)
+ * is no API for managing prefix lifetime and the kernel should not
+ * pretend it's from a RA either.
+ *
+ * The issue is that the very first assigned prefix will inherit the
+ * lifetime of the address, but any subsequent alteration of the
+ * address OR it's lifetime will not affect the prefix lifetime.
+ * As such, we cannot stop the prefix from timing out and then
+ * constantly removing the prefix route dhcpcd is capable of adding
+ * in it's absense.
+ *
+ * What we can do to mitigate the issue is to add the address with
+ * infinite lifetimes, so the prefix route will never time out.
+ * Once done, we can then set lifetimes on the address and all is good.
+ * The downside of this approach is that we need to manually remove
+ * the kernel route because it has no lifetime, but this is OK as
+ * dhcpcd will handle this too.
+ *
+ * This issue is discussed on the NetBSD mailing lists here:
+ * http://mail-index.netbsd.org/tech-net/2016/08/05/msg006044.html
+ *
+ * NOT fixed in NetBSD - patch under development
+ * NOT fixed in FreeBSD - bug 195197
+ * Fixed in OpenBSD-5.9
+ */
+#if !(defined(OpenBSD) && OpenBSD >= 201605)
+ if (cmd == RTM_NEWADDR && !(ia->flags & IPV6_AF_ADDED)) {
+ ifa.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME;
+ ifa.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME;
+ (void)ioctl(priv->pf_inet6_fd, SIOCAIFADDR_IN6, &ifa);
+ }
+#endif
+
ifa.ifra_lifetime.ia6t_vltime = ia->prefix_vltime;
ifa.ifra_lifetime.ia6t_pltime = ia->prefix_pltime;
-#undef ADDADDR
- priv = (struct priv *)ia->iface->ctx->priv;
return ioctl(priv->pf_inet6_fd,
cmd == RTM_DELADDR ? SIOCDIFADDR_IN6 : SIOCAIFADDR_IN6, &ifa);
}
@@ -1088,7 +1127,7 @@ if_route6(unsigned char cmd, const struc
#endif
addrs = RTA_NETMASK;
- flags = 0;
+ flags = (int)rt->flags;
#ifdef RTF_PINNED
if (cmd != RTM_ADD)
flags |= RTF_PINNED;
@@ -1109,8 +1148,10 @@ if_route6(unsigned char cmd, const struc
if (IN6_IS_ADDR_UNSPECIFIED(&rt->gate))
g = NULL;
- else
+ else {
g = &gate;
+ ifa_scope(g, rt->iface->index);
+ }
return if_rtmsg(cmd, rt->iface, addrs, flags,
#ifdef RTP_CONNECTED
Index: src/external/bsd/dhcpcd/dist/ipv4.c
diff -u src/external/bsd/dhcpcd/dist/ipv4.c:1.24 src/external/bsd/dhcpcd/dist/ipv4.c:1.25
--- src/external/bsd/dhcpcd/dist/ipv4.c:1.24 Fri Jul 29 10:07:58 2016
+++ src/external/bsd/dhcpcd/dist/ipv4.c Mon Aug 15 11:04:53 2016
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: ipv4.c,v 1.24 2016/07/29 10:07:58 roy Exp $");
+ __RCSID("$NetBSD: ipv4.c,v 1.25 2016/08/15 11:04:53 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -385,7 +385,7 @@ ipv4_handlert(struct dhcpcd_ctx *ctx, in
/* If we manage the route, remove it */
if ((f = find_route(ctx->ipv4_routes, rt, NULL))) {
- desc_route("removing", f);
+ desc_route("deleted", f);
TAILQ_REMOVE(ctx->ipv4_routes, f, next);
free(f);
}
Index: src/external/bsd/dhcpcd/dist/ipv6.c
diff -u src/external/bsd/dhcpcd/dist/ipv6.c:1.20 src/external/bsd/dhcpcd/dist/ipv6.c:1.21
--- src/external/bsd/dhcpcd/dist/ipv6.c:1.20 Fri Jul 29 10:07:58 2016
+++ src/external/bsd/dhcpcd/dist/ipv6.c Mon Aug 15 11:04:53 2016
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: ipv6.c,v 1.20 2016/07/29 10:07:58 roy Exp $");
+ __RCSID("$NetBSD: ipv6.c,v 1.21 2016/08/15 11:04:53 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -2182,7 +2182,7 @@ ipv6_handlert(struct dhcpcd_ctx *ctx, in
}
/* If we manage the route, remove it */
if ((f = find_route6(ctx->ipv6->routes, rt))) {
- desc_route("removing", f);
+ desc_route("deleted", f);
TAILQ_REMOVE(ctx->ipv6->routes, f, next);
free(f);
}
@@ -2407,6 +2407,8 @@ ipv6_build_ra_routes(struct ipv6_ctx *ct
continue;
if (rap->iface->options->options & DHCPCD_IPV6RA_OWN) {
TAILQ_FOREACH(addr, &rap->addrs, next) {
+ if (addr->prefix_vltime == 0)
+ continue;
rt = make_prefix(rap->iface, rap, addr);
if (rt)
TAILQ_INSERT_TAIL(dnr, rt, next);
Index: src/external/bsd/dhcpcd/dist/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/ipv6nd.c:1.31 src/external/bsd/dhcpcd/dist/ipv6nd.c:1.32
--- src/external/bsd/dhcpcd/dist/ipv6nd.c:1.31 Fri Jul 29 10:07:58 2016
+++ src/external/bsd/dhcpcd/dist/ipv6nd.c Mon Aug 15 11:04:53 2016
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: ipv6nd.c,v 1.31 2016/07/29 10:07:58 roy Exp $");
+ __RCSID("$NetBSD: ipv6nd.c,v 1.32 2016/08/15 11:04:53 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -1332,6 +1332,7 @@ ipv6nd_expirera(void *arg)
struct ra *rap, *ran;
struct timespec now, lt, expire, next;
uint8_t expired, valid, validone;
+ struct ipv6_addr *ia;
ifp = arg;
clock_gettime(CLOCK_MONOTONIC, &now);
@@ -1365,6 +1366,39 @@ ipv6nd_expirera(void *arg)
}
}
+ /* Not every prefix is tied to an address which
+ * the kernel can expire, so we need to handle it ourself.
+ * Also, some OS don't support address lifetimes (Solaris). */
+ TAILQ_FOREACH(ia, &rap->addrs, next) {
+ if (ia->prefix_vltime == ND6_INFINITE_LIFETIME ||
+ ia->prefix_vltime == 0)
+ continue;
+ lt.tv_sec = (time_t)ia->prefix_vltime;
+ lt.tv_nsec = 0;
+ timespecadd(&ia->acquired, <, &expire);
+ if (timespeccmp(&now, &expire, >)) {
+ if (ia->flags & IPV6_AF_ADDED) {
+ logger(ia->iface->ctx, LOG_WARNING,
+ "%s: expired address %s",
+ ia->iface->name, ia->saddr);
+ if (if_address6(RTM_DELADDR, ia)== -1 &&
+ errno != EADDRNOTAVAIL &&
+ errno != ENXIO)
+ logger(ia->iface->ctx, LOG_ERR,
+ "if_address6: %m");
+ }
+ ia->prefix_vltime = ia->prefix_pltime = 0;
+ ia->flags &=
+ ~(IPV6_AF_ADDED | IPV6_AF_DADCOMPLETED);
+ expired = 1;
+ } else {
+ timespecsub(&expire, &now, <);
+ if (!timespecisset(&next) ||
+ timespeccmp(&next, <, >))
+ next = lt;
+ }
+ }
+
/* XXX FixMe!
* We need to extract the lifetime from each option and check
* if that has expired or not.