CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2021-02-24 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 25 07:55:53 UTC 2021

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
For SMALLPROG, do not compile in IPv6 support unless SMALLPROG_INET6 is
defined, as in the same manner as other utilities.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.54 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.55
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.54	Mon Jun 15 17:02:58 2020
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Thu Feb 25 07:55:53 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.54 2020/06/15 17:02:58 roy Exp $
+# $NetBSD: Makefile,v 1.55 2021/02/25 07:55:53 rin Exp $
 #
 
 WARNS?=		6
@@ -54,7 +54,7 @@ SRCS+=		ipv4ll.c
 .endif
 .endif
 
-.if (${USE_INET6} != "no")
+.if (!defined(SMALLPROG) || defined(SMALLPROG_INET6)) && (${USE_INET6} != "no")
 CPPFLAGS+=	-DINET6
 SRCS+=		ipv6.c ipv6nd.c
 # -DSMALL already strips out prefix delegation



CVS commit: src/external/bsd/dhcpcd/dist

2020-12-28 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Dec 28 13:57:40 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/hooks: 20-resolv.conf
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.c if-bsd.c
if-options.c ipv6nd.c privsep.c script.c

Log Message:
Sync with dhcpcd-9.4.0


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf
cvs rdiff -u -r1.44 -r1.45 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.26 -r1.27 src/external/bsd/dhcpcd/dist/src/dhcp6.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.47 -r1.48 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.25 -r1.26 src/external/bsd/dhcpcd/dist/src/if-bsd.c
cvs rdiff -u -r1.30 -r1.31 src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/src/privsep.c
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/src/script.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/hooks/20-resolv.conf
diff -u src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.5 src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.6
--- src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.5	Fri Nov 20 13:24:58 2020
+++ src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf	Mon Dec 28 13:57:40 2020
@@ -7,9 +7,15 @@
 # or dnsmasq. This is important as the libc resolver isn't that powerful.
 
 resolv_conf_dir="$state_dir/resolv.conf"
+nocarrier_roaming_dir="$state_dir/roaming"
 NL="
 "
 : ${resolvconf:=resolvconf}
+if type "$resolvconf" >/dev/null 2>&1; then
+	have_resolvconf=true
+else
+	have_resolvconf=false
+fi
 
 build_resolv_conf()
 {
@@ -164,7 +170,7 @@ add_resolv_conf()
 	for x in ${new_domain_name_servers}; do
 		conf="${conf}nameserver $x$NL"
 	done
-	if type "$resolvconf" >/dev/null 2>&1; then
+	if $have_resolvconf; then
 		[ -n "$ifmetric" ] && export IF_METRIC="$ifmetric"
 		printf %s "$conf" | "$resolvconf" -a "$ifname"
 		return $?
@@ -180,7 +186,7 @@ add_resolv_conf()
 
 remove_resolv_conf()
 {
-	if type "$resolvconf" >/dev/null 2>&1; then
+	if $have_resolvconf; then
 		"$resolvconf" -d "$ifname" -f
 	else
 		if [ -e "$resolv_conf_dir/$ifname" ]; then
@@ -199,7 +205,18 @@ BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
 esac
 
 if $if_configured; then
-	if $if_up || [ "$reason" = ROUTERADVERT ]; then
+	if $have_resolvconf && [ "$reason" = NOCARRIER_ROAMING ]; then
+		# avoid calling resolvconf -c on CARRIER unless we roam
+		mkdir -p "$nocarrier_roaming_dir"
+		echo " " >"$nocarrier_roaming_dir/$interface"
+		"$resolvconf" -C "$interface.*"
+	elif $have_resolvconf && [ "$reason" = CARRIER ]; then
+		# Not all resolvconf implementations support -c
+		if [ -e "$nocarrier_roaming_dir/$interface" ]; then
+			rm -f "$nocarrier_roaming_dir/$interface"
+			"$resolvconf" -c "$interface.*"
+		fi
+	elif $if_up || [ "$reason" = ROUTERADVERT ]; then
 		add_resolv_conf
 	elif $if_down; then
 		remove_resolv_conf

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.44 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.45
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.44	Sat Nov 28 14:27:20 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Mon Dec 28 13:57:40 2020
@@ -3886,20 +3886,9 @@ dhcp_init(struct interface *ifp)
 	state->clientid = NULL;
 
 	if (ifo->options & DHCPCD_ANONYMOUS) {
-		uint8_t duid[DUID_LEN];
-		uint8_t duid_len;
-
-		duid_len = (uint8_t)duid_make(duid, ifp, DUID_LL);
-		if (duid_len != 0) {
-			state->clientid = malloc((size_t)duid_len + 6);
-			if (state->clientid == NULL)
-goto eexit;
-			state->clientid[0] =(uint8_t)(duid_len + 5);
-			state->clientid[1] = 255; /* RFC 4361 */
-			memcpy(state->clientid + 2, ifo->iaid, 4);
-			memset(state->clientid + 2, 0, 4); /* IAID */
-			memcpy(state->clientid + 6, duid, duid_len);
-		}
+		/* Removing the option could show that we want anonymous.
+		 * As such keep it as it's already in the hwaddr field. */
+		goto make_clientid;
 	} else if (*ifo->clientid) {
 		state->clientid = malloc((size_t)(ifo->clientid[0] + 1));
 		if (state->clientid == NULL)
@@ -3917,6 +3906,7 @@ dhcp_init(struct interface *ifp)
 			memcpy(state->clientid + 6, ifp->ctx->duid,
 			ifp->ctx->duid_len);
 		} else {
+make_clientid:
 			len = (uint8_t)(ifp->hwlen + 1);
 			state->clientid = malloc((size_t)len + 1);
 			if (state->clientid == NULL)

Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.26 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.27
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.26	Sat Nov 28 14:27:20 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c	Mon Dec 28 13:57:40 2020
@@ -2065,7 +2065,8 @@ dhcp6_checkstatusok(const struct interfa
 	state->lerror = code;
 	errno = 0;
 
-	if (code != 0 && ifp->ctx->options & DHCPCD_TEST)
+	/* code cannot be D6_STATUS_OK, so 

CVS commit: src/external/bsd/dhcpcd/dist/src

2020-11-28 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Nov 28 14:27:20 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.8.in dhcpcd.c
if-options.c

Log Message:
Sync with dhcpcd-9.3.4


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.25 -r1.26 src/external/bsd/dhcpcd/dist/src/dhcp6.c
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in
cvs rdiff -u -r1.46 -r1.47 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.29 -r1.30 src/external/bsd/dhcpcd/dist/src/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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.43 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.44
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.43	Fri Nov 20 13:24:58 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Sat Nov 28 14:27:20 2020
@@ -2364,13 +2364,21 @@ dhcp_bind(struct interface *ifp)
 		return;
 	}
 
+	/* Add the address */
+	if (ipv4_applyaddr(ifp) == NULL) {
+		/* There was an error adding the address.
+		 * If we are in oneshot, exit with a failure. */
+		if (ctx->options & DHCPCD_ONESHOT) {
+			loginfox("exiting due to oneshot");
+			eloop_exit(ctx->eloop, EXIT_FAILURE);
+		}
+		return;
+	}
+
 	/* Close the BPF filter as we can now receive DHCP messages
 	 * on a UDP socket. */
 	dhcp_closebpf(ifp);
 
-	/* Add the address */
-	ipv4_applyaddr(ifp);
-
 openudp:
 	/* If not in master mode, open an address specific socket. */
 	if (ctx->options & DHCPCD_MASTER ||

Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.25 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.26
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.25	Fri Nov 20 13:24:58 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c	Sat Nov 28 14:27:20 2020
@@ -2064,6 +2064,10 @@ dhcp6_checkstatusok(const struct interfa
 	free(sbuf);
 	state->lerror = code;
 	errno = 0;
+
+	if (code != 0 && ifp->ctx->options & DHCPCD_TEST)
+		eloop_exit(ifp->ctx->eloop, EXIT_FAILURE);
+
 	return (int)code;
 }
 

Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.10 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.11
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.10	Fri Nov 20 13:24:58 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in	Sat Nov 28 14:27:20 2020
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd November 3, 2020
+.Dd November 25, 2020
 .Dt DHCPCD 8
 .Os
 .Sh NAME
@@ -264,18 +264,29 @@ Use this
 .Ar script
 instead of the default
 .Pa @SCRIPT@ .
-.It Fl D , Fl Fl duid
+.It Fl D , Fl Fl duid Op Ar ll | lt | uuid | value
 Use a DHCP Unique Identifier.
 If a system UUID is available, that will be used to create a DUID-UUID,
 otheriwse if persistent storage is available then a DUID-LLT
 (link local address + time) is generated,
 otherwise DUID-LL is generated (link local address).
+The DUID type can be hinted as an optional parameter if the file
+.Pa @DBDIR@/duid
+does not exist.
+If not
+.Va ll ,
+.Va lt
+or
+.Va uuid
+then
+.Va value
+will be converted from 00:11:22:33 format.
 This, plus the IAID will be used as the
 .Fl I , Fl Fl clientid .
 The DUID generated will be held in
 .Pa @DBDIR@/duid
 and should not be copied to other hosts.
-This file also takes precedence over the above rules.
+This file also takes precedence over the above rules except for setting a value.
 .It Fl d , Fl Fl debug
 Echo debug messages to the stderr and syslog.
 .It Fl E , Fl Fl lastlease
@@ -747,7 +758,7 @@ This is the default behaviour and sets
 .Ev if_configured=true .
 .It Fl Fl noconfigure
 .Nm
-will not configure the system add all.
+will not configure the system at all.
 This is only of use if the
 .Fl Fl script
 that

Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.46 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.47
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.46	Fri Nov 20 13:24:58 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Sat Nov 28 14:27:20 2020
@@ -841,13 +841,17 @@ dhcpcd_initduid(struct dhcpcd_ctx *ctx, 
 {
 	char buf[DUID_LEN * 3];
 
-	if (ctx->duid != NULL)
+	if (ctx->duid != NULL) {
+		if (ifp == NULL)
+			goto log;
 		return;
+	}
 
 	duid_init(ctx, ifp);
 	if (ctx->duid == NULL)
 		return;
 
+log:
 	loginfox("DUID %s",
 	hwaddr_ntoa(ctx->duid, ctx->duid_len, buf, sizeof(buf)));
 }
@@ -991,17 +995,20 @@ void
 dhcpcd_activateinterface(struct interface *ifp, unsigned long long options)
 {
 
-	if (!ifp->active) {
-		ifp->active = IF_ACTIVE;
-		dhcpcd_initstate2(ifp, options);
-		/* It's possible we might not have been able to load
-		 * a config. */
-		if (ifp->active) {
-			configure_interface1(ifp);
-			run_preinit(ifp);
-			

CVS commit: src/external/bsd/dhcpcd/dist

2020-11-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Nov 20 13:24:58 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/hooks: 20-resolv.conf 50-ntp.conf
50-ypbind.in
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.8.in dhcpcd.c
if-options.c ipv6.c ipv6nd.c privsep.c script.c

Log Message:
Sync with dhcpcd-9.3.3


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf \
src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in
cvs rdiff -u -r1.42 -r1.43 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.24 -r1.25 src/external/bsd/dhcpcd/dist/src/dhcp6.c
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in
cvs rdiff -u -r1.45 -r1.46 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.28 -r1.29 src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/src/ipv6.c
cvs rdiff -u -r1.25 -r1.26 src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/privsep.c
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/src/script.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/hooks/20-resolv.conf
diff -u src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.4 src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.5
--- src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.4	Thu Apr  2 12:41:47 2020
+++ src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf	Fri Nov 20 13:24:58 2020
@@ -198,8 +198,10 @@ BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
 	;;
 esac
 
-if $if_up || [ "$reason" = ROUTERADVERT ]; then
-	add_resolv_conf
-elif $if_down; then
-	remove_resolv_conf
+if $if_configured; then
+	if $if_up || [ "$reason" = ROUTERADVERT ]; then
+		add_resolv_conf
+	elif $if_down; then
+		remove_resolv_conf
+	fi
 fi
Index: src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf
diff -u src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf:1.4 src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf:1.5
--- src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf:1.4	Thu Apr  2 12:41:48 2020
+++ src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf	Fri Nov 20 13:24:58 2020
@@ -135,8 +135,10 @@ BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
 ;;
 esac
 
-if $if_up; then
-	add_ntp_conf
-elif $if_down; then
-	remove_ntp_conf
+if $if_configured; then
+	if $if_up; then
+		add_ntp_conf
+	elif $if_down; then
+		remove_ntp_conf
+	fi
 fi

Index: src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in
diff -u src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in:1.2 src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in:1.3
--- src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in:1.2	Sat Sep 22 13:17:46 2018
+++ src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in	Fri Nov 20 13:24:58 2020
@@ -68,7 +68,9 @@ restore_yp_binding()
 	fi
 }
 
-if [ "$reason" = PREINIT ]; then
+if ! $if_configured; then
+	;
+elif [ "$reason" = PREINIT ]; then
 	rm -f "$ypbind_dir/$interface".*
 elif $if_up || $if_down; then
 	if [ -n "$new_nis_domain" ]; then

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.42 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.43
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.42	Sun Nov  1 14:24:01 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Fri Nov 20 13:24:58 2020
@@ -2346,6 +2346,24 @@ dhcp_bind(struct interface *ifp)
 
 	old_state = state->added;
 
+	if (!(ifo->options & DHCPCD_CONFIGURE)) {
+		struct ipv4_addr *ia;
+
+		script_runreason(ifp, state->reason);
+		dhcpcd_daemonise(ifp->ctx);
+
+		/* We we are not configuring the address, we need to keep
+		 * the BPF socket open if the address does not exist. */
+		ia = ipv4_iffindaddr(ifp, >lease.addr, NULL);
+		if (ia != NULL) {
+			state->addr = ia;
+			state->added = STATE_ADDED;
+			dhcp_closebpf(ifp);
+			goto openudp;
+		}
+		return;
+	}
+
 	/* Close the BPF filter as we can now receive DHCP messages
 	 * on a UDP socket. */
 	dhcp_closebpf(ifp);
@@ -2353,6 +2371,7 @@ dhcp_bind(struct interface *ifp)
 	/* Add the address */
 	ipv4_applyaddr(ifp);
 
+openudp:
 	/* If not in master mode, open an address specific socket. */
 	if (ctx->options & DHCPCD_MASTER ||
 	(state->old != NULL &&
@@ -2361,7 +2380,6 @@ dhcp_bind(struct interface *ifp)
 		return;
 
 	dhcp_closeinet(ifp);
-
 #ifdef PRIVSEP
 	if (IN_PRIVSEP_SE(ctx)) {
 		if (ps_inet_openbootp(state->addr) == -1)
@@ -2805,7 +2823,13 @@ dhcp_drop(struct interface *ifp, const c
 	state->new = NULL;
 	state->new_len = 0;
 	state->reason = reason;
-	ipv4_applyaddr(ifp);
+	if (ifp->options->options & DHCPCD_CONFIGURE)
+		ipv4_applyaddr(ifp);
+	else {
+		state->addr = NULL;
+		state->added = 0;
+		script_runreason(ifp, state->reason);
+	}
 	free(state->old);
 	state->old = NULL;
 	state->old_len = 0;
@@ -4219,6 +4243,20 @@ dhcp_handleifa(int cmd, struct ipv4_addr
 

CVS commit: src/external/bsd/dhcpcd/dist/src

2020-11-01 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Nov  1 14:24:01 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcpcd.8.in dhcpcd.c logerr.c
privsep.c

Log Message:
Sync with dhcpcd-9.3.2


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in
cvs rdiff -u -r1.44 -r1.45 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/logerr.c
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/privsep.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.41 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.42
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.41	Mon Oct 12 14:09:03 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Sun Nov  1 14:24:01 2020
@@ -1520,21 +1520,15 @@ again:
 #endif
 }
 
-void
-dhcp_close(struct interface *ifp)
+static void
+dhcp_closebpf(struct interface *ifp)
 {
 	struct dhcpcd_ctx *ctx = ifp->ctx;
 	struct dhcp_state *state = D_STATE(ifp);
 
-	if (state == NULL)
-		return;
-
 #ifdef PRIVSEP
-	if (IN_PRIVSEP_SE(ctx)) {
+	if (IN_PRIVSEP_SE(ctx))
 		ps_bpf_closebootp(ifp);
-		if (state->addr != NULL)
-			ps_inet_closebootp(state->addr);
-	}
 #endif
 
 	if (state->bpf != NULL) {
@@ -1542,11 +1536,38 @@ dhcp_close(struct interface *ifp)
 		bpf_close(state->bpf);
 		state->bpf = NULL;
 	}
+}
+
+static void
+dhcp_closeinet(struct interface *ifp)
+{
+	struct dhcpcd_ctx *ctx = ifp->ctx;
+	struct dhcp_state *state = D_STATE(ifp);
+
+#ifdef PRIVSEP
+	if (IN_PRIVSEP_SE(ctx)) {
+		if (state->addr != NULL)
+			ps_inet_closebootp(state->addr);
+	}
+#endif
+
 	if (state->udp_rfd != -1) {
 		eloop_event_delete(ctx->eloop, state->udp_rfd);
 		close(state->udp_rfd);
 		state->udp_rfd = -1;
 	}
+}
+
+void
+dhcp_close(struct interface *ifp)
+{
+	struct dhcp_state *state = D_STATE(ifp);
+
+	if (state == NULL)
+		return;
+
+	dhcp_closebpf(ifp);
+	dhcp_closeinet(ifp);
 
 	state->interval = 0;
 }
@@ -2061,12 +2082,14 @@ dhcp_addr_duplicated(struct interface *i
 
 #ifdef ARP
 #ifdef KERNEL_RFC5227
+#ifdef ARPING
 static void
 dhcp_arp_announced(struct arp_state *state)
 {
 
 	arp_free(state);
 }
+#endif
 #else
 static void
 dhcp_arp_defend_failed(struct arp_state *astate)
@@ -2321,23 +2344,24 @@ dhcp_bind(struct interface *ifp)
 			logerr("dhcp_writefile: %s", state->leasefile);
 	}
 
+	old_state = state->added;
+
 	/* Close the BPF filter as we can now receive DHCP messages
 	 * on a UDP socket. */
-	old_state = state->added;
-	if (ctx->options & DHCPCD_MASTER ||
-	state->old == NULL ||
-	state->old->yiaddr != state->new->yiaddr || old_state & STATE_FAKE)
-		dhcp_close(ifp);
+	dhcp_closebpf(ifp);
 
+	/* Add the address */
 	ipv4_applyaddr(ifp);
 
 	/* If not in master mode, open an address specific socket. */
 	if (ctx->options & DHCPCD_MASTER ||
 	(state->old != NULL &&
-	state->old->yiaddr == state->new->yiaddr &&
-	old_state & STATE_ADDED && !(old_state & STATE_FAKE)))
+	 state->old->yiaddr == state->new->yiaddr &&
+	 old_state & STATE_ADDED && !(old_state & STATE_FAKE)))
 		return;
 
+	dhcp_closeinet(ifp);
+
 #ifdef PRIVSEP
 	if (IN_PRIVSEP_SE(ctx)) {
 		if (ps_inet_openbootp(state->addr) == -1)
@@ -2926,6 +2950,8 @@ dhcp_handledhcp(struct interface *ifp, s
 	unsigned int i;
 	char *msg;
 	bool bootp_copied;
+	uint32_t v6only_time = 0;
+	bool use_v6only = false;
 #ifdef AUTH
 	const uint8_t *auth;
 	size_t auth_len;
@@ -3143,6 +3169,23 @@ dhcp_handledhcp(struct interface *ifp, s
 		}
 	}
 
+	if (has_option_mask(ifo->requestmask, DHO_IPV6_PREFERRED_ONLY)) {
+		if (get_option_uint32(ifp->ctx, _time, bootp, bootp_len,
+		DHO_IPV6_PREFERRED_ONLY) == 0 &&
+		(state->state == DHS_DISCOVER || state->state == DHS_REBOOT))
+		{
+			char v6msg[128];
+
+			use_v6only = true;
+			if (v6only_time < MIN_V6ONLY_WAIT)
+v6only_time = MIN_V6ONLY_WAIT;
+			snprintf(v6msg, sizeof(v6msg),
+			"IPv6-Only Preferred received (%u seconds)",
+			v6only_time);
+			LOGDHCP(LOG_INFO, v6msg);
+		}
+	}
+
 	/* DHCP Auto-Configure, RFC 2563 */
 	if (type == DHCP_OFFER && bootp->yiaddr == 0) {
 		LOGDHCP(LOG_WARNING, "no address given");
@@ -3177,12 +3220,22 @@ dhcp_handledhcp(struct interface *ifp, s
 			}
 			eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
 			eloop_timeout_add_sec(ifp->ctx->eloop,
-			DHCP_MAX, dhcp_discover, ifp);
+			use_v6only ? v6only_time : DHCP_MAX,
+			dhcp_discover, ifp);
 		}
 #endif
 		return;
 	}
 
+	if (use_v6only) {
+		dhcp_drop(ifp, "EXPIRE");
+		dhcp_unlink(ifp->ctx, state->leasefile);
+		eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
+		eloop_timeout_add_sec(ifp->ctx->eloop, v6only_time,
+		dhcp_discover, ifp);
+		return;
+	}
+
 	/* Ensure that the address 

CVS commit: src/external/bsd/dhcpcd/dist/src

2020-10-12 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Oct 12 14:09:03 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.c if-bsd.c
ipv6.c ipv6nd.c logerr.c privsep.c script.c

Log Message:
Sync withn dhcpcd-9.3.1


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.23 -r1.24 src/external/bsd/dhcpcd/dist/src/dhcp6.c
cvs rdiff -u -r1.43 -r1.44 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.24 -r1.25 src/external/bsd/dhcpcd/dist/src/if-bsd.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/dhcpcd/dist/src/ipv6.c
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/logerr.c
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/privsep.c
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/script.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.40 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.41
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.40	Mon Oct  5 16:02:15 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Mon Oct 12 14:09:03 2020
@@ -1712,7 +1712,7 @@ send_message(struct interface *ifp, uint
 
 	if (callback == NULL) {
 		/* No carrier? Don't bother sending the packet. */
-		if (ifp->carrier <= LINK_DOWN)
+		if (!if_is_link_up(ifp))
 			return;
 		logdebugx("%s: sending %s with xid 0x%x",
 		ifp->name,
@@ -1731,7 +1731,7 @@ send_message(struct interface *ifp, uint
 		(arc4random_uniform(MSEC_PER_SEC * 2) - MSEC_PER_SEC);
 		/* No carrier? Don't bother sending the packet.
 		 * However, we do need to advance the timeout. */
-		if (ifp->carrier <= LINK_DOWN)
+		if (!if_is_link_up(ifp))
 			goto fail;
 		logdebugx("%s: sending %s (xid 0x%x), next in %0.1f seconds",
 		ifp->name,
@@ -2633,7 +2633,7 @@ dhcp_reboot(struct interface *ifp)
 	state->state = DHS_REBOOT;
 	state->interval = 0;
 
-	if (ifo->options & DHCPCD_LINK && ifp->carrier <= LINK_DOWN) {
+	if (ifo->options & DHCPCD_LINK && !if_is_link_up(ifp)) {
 		loginfox("%s: waiting for carrier", ifp->name);
 		return;
 	}
@@ -2733,7 +2733,7 @@ dhcp_drop(struct interface *ifp, const c
 		state->state = DHS_RELEASE;
 
 		dhcp_unlink(ifp->ctx, state->leasefile);
-		if (ifp->carrier > LINK_DOWN &&
+		if (if_is_link_up(ifp) &&
 		state->new != NULL &&
 		state->lease.server.s_addr != INADDR_ANY)
 		{

Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.23 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.24
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.23	Mon Oct  5 16:02:15 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c	Mon Oct 12 14:09:03 2020
@@ -1237,7 +1237,7 @@ dhcp6_sendmessage(struct interface *ifp,
 	};
 	char uaddr[INET6_ADDRSTRLEN];
 
-	if (!callback && ifp->carrier <= LINK_DOWN)
+	if (!callback && !if_is_link_up(ifp))
 		return 0;
 
 	if (!IN6_IS_ADDR_UNSPECIFIED(>unicast)) {
@@ -1298,7 +1298,7 @@ dhcp6_sendmessage(struct interface *ifp,
 		+ (unsigned int)((float)state->RT
 		* ((float)lr / DHCP6_RAND_DIV));
 
-		if (ifp->carrier > LINK_DOWN)
+		if (if_is_link_up(ifp))
 			logdebugx("%s: %s %s (xid 0x%02x%02x%02x)%s%s,"
 			" next in %0.1f seconds",
 			ifp->name,
@@ -1320,7 +1320,7 @@ dhcp6_sendmessage(struct interface *ifp,
 		}
 	}
 
-	if (ifp->carrier <= LINK_DOWN)
+	if (!if_is_link_up(ifp))
 		return 0;
 
 	/* Update the elapsed time */
@@ -2906,7 +2906,7 @@ dhcp6_delegate_prefix(struct interface *
 if (ia->sla_len == 0) {
 	/* no SLA configured, so lets
 	 * automate it */
-	if (ifd->carrier != LINK_UP) {
+	if (!if_is_link_up(ifd)) {
 		logdebugx(
 		"%s: has no carrier, cannot"
 		" delegate addresses",
@@ -2922,7 +2922,7 @@ dhcp6_delegate_prefix(struct interface *
 	sla = >sla[j];
 	if (strcmp(ifd->name, sla->ifname))
 		continue;
-	if (ifd->carrier != LINK_UP) {
+	if (!if_is_link_up(ifd)) {
 		logdebugx(
 		"%s: has no carrier, cannot"
 		" delegate addresses",
@@ -4029,7 +4029,7 @@ dhcp6_freedrop(struct interface *ifp, in
 		if (drop && options & DHCPCD_RELEASE &&
 		state->state != DH6S_DELEGATED)
 		{
-			if (ifp->carrier == LINK_UP &&
+			if (if_is_link_up(ifp) &&
 			state->state != DH6S_RELEASED &&
 			state->state != DH6S_INFORMED)
 			{

Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.43 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.44
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.43	Mon Oct  5 16:02:15 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Mon Oct 12 14:09:03 2020
@@ -97,9 +97,6 @@ const int dhcpcd_signals_ignore[] = {
 const size_t dhcpcd_signals_ignore_len = __arraycount(dhcpcd_signals_ignore);
 #endif
 
-#define 

CVS commit: src/external/bsd/dhcpcd/dist/src

2020-10-05 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Oct  5 16:02:15 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcp6.c dhcpcd.c
if-bsd.c if-options.c ipv6nd.c logerr.c privsep.c script.c

Log Message:
Sync with dhcpcd-9.3.0


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/external/bsd/dhcpcd/dist/src/bpf.c
cvs rdiff -u -r1.39 -r1.40 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.22 -r1.23 src/external/bsd/dhcpcd/dist/src/dhcp6.c
cvs rdiff -u -r1.42 -r1.43 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.23 -r1.24 src/external/bsd/dhcpcd/dist/src/if-bsd.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.27 -r1.28 src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/logerr.c
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/privsep.c
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/script.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/src/bpf.c
diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.16 src/external/bsd/dhcpcd/dist/src/bpf.c:1.17
--- src/external/bsd/dhcpcd/dist/src/bpf.c:1.16	Mon Jun 15 16:59:05 2020
+++ src/external/bsd/dhcpcd/dist/src/bpf.c	Mon Oct  5 16:02:15 2020
@@ -70,14 +70,14 @@
 	(insn)->jt = 0;		\
 	(insn)->jf = 0;		\
 	(insn)->k = (uint32_t)(v);\
-};
+}
 
 #define	BPF_SET_JUMP(insn, c, v, t, f) {			\
 	(insn)->code = (c);	\
 	(insn)->jt = (t);	\
 	(insn)->jf = (f);	\
 	(insn)->k = (uint32_t)(v);\
-};
+}
 
 size_t
 bpf_frame_header_len(const struct interface *ifp)
@@ -585,9 +585,6 @@ static const struct bpf_insn bpf_bootp_e
 };
 #define BPF_BOOTP_ETHER_LEN	__arraycount(bpf_bootp_ether)
 
-#define BOOTP_MIN_SIZE		sizeof(struct ip) + sizeof(struct udphdr) + \
-sizeof(struct bootp)
-
 static const struct bpf_insn bpf_bootp_base[] = {
 	/* Make sure it's an IPv4 packet. */
 	BPF_STMT(BPF_LD + BPF_B + BPF_IND, 0),

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.39 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.40
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.39	Sun Sep  6 14:55:34 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Mon Oct  5 16:02:15 2020
@@ -1164,7 +1164,7 @@ read_lease(struct interface *ifp, struct
 		logdebugx("reading standard input");
 		sbytes = read(fileno(stdin), buf.buf, sizeof(buf.buf));
 	} else {
-		logdebugx("%s: reading lease `%s'",
+		logdebugx("%s: reading lease: %s",
 		ifp->name, state->leasefile);
 		sbytes = dhcp_readfile(ifp->ctx, state->leasefile,
 		buf.buf, sizeof(buf.buf));
@@ -2314,7 +2314,7 @@ dhcp_bind(struct interface *ifp)
 	state->state = DHS_BOUND;
 	if (!state->lease.frominfo &&
 	!(ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC))) {
-		logdebugx("%s: writing lease `%s'",
+		logdebugx("%s: writing lease: %s",
 		ifp->name, state->leasefile);
 		if (dhcp_writefile(ifp->ctx, state->leasefile, 0640,
 		state->new, state->new_len) == -1)
@@ -2865,10 +2865,10 @@ log_dhcp(int loglevel, const char *msg,
 		print_string(sname, sizeof(sname), OT_STRING | OT_DOMAIN,
 		bootp->sname, sizeof(bootp->sname));
 		if (a == NULL)
-			logmessage(loglevel, "%s: %s %s %s `%s'",
+			logmessage(loglevel, "%s: %s %s %s %s",
 			ifp->name, msg, tfrom, inet_ntoa(addr), sname);
 		else
-			logmessage(loglevel, "%s: %s %s %s %s `%s'",
+			logmessage(loglevel, "%s: %s %s %s %s %s",
 			ifp->name, msg, a, tfrom, inet_ntoa(addr), sname);
 	} else {
 		if (r != 0) {
@@ -3477,6 +3477,16 @@ dhcp_packet(struct interface *ifp, uint8
 #ifdef PRIVSEP
 	const struct dhcp_state *state = D_CSTATE(ifp);
 
+	/* It's possible that an interface departs and arrives in short
+	 * order to receive a BPF frame out of order.
+	 * There is a similar check in ARP, but much lower down the stack.
+	 * It's not needed for other inet protocols because we send the
+	 * message as a whole and select the interface off that and then
+	 * check state. BPF on the other hand is very interface
+	 * specific and we do need this check. */
+	if (state == NULL)
+		return;
+
 	/* Ignore double reads */
 	if (IN_PRIVSEP(ifp->ctx)) {
 		switch (state->state) {

Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.22 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.23
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.22	Thu Jul  2 13:59:19 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c	Mon Oct  5 16:02:15 2020
@@ -147,7 +147,7 @@ struct dhcp_compat {
 	uint16_t dhcp6_opt;
 };
 
-const struct dhcp_compat dhcp_compats[] = {
+static const struct dhcp_compat dhcp_compats[] = {
 	{ DHO_DNSSERVER,	D6_OPTION_DNS_SERVERS },
 	{ DHO_HOSTNAME,		D6_OPTION_FQDN },
 	{ DHO_DNSDOMAIN,	D6_OPTION_FQDN },
@@ -2588,7 +2588,7 @@ dhcp6_readlease(struct interface *ifp, i
 		logdebugx("reading 

CVS commit: src/external/bsd/dhcpcd/include

2020-09-06 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Sep  6 14:57:18 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/include: config.h

Log Message:
dhcpcd: Use ppoll(2)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/include/config.h

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/include/config.h
diff -u src/external/bsd/dhcpcd/include/config.h:1.6 src/external/bsd/dhcpcd/include/config.h:1.7
--- src/external/bsd/dhcpcd/include/config.h:1.6	Thu Jun  4 13:09:45 2020
+++ src/external/bsd/dhcpcd/include/config.h	Sun Sep  6 14:57:18 2020
@@ -18,7 +18,7 @@
 #define	HAVE_SYS_QUEUE_H
 #define	HAVE_SYS_RBTREE_H
 #define	HAVE_REALLOCARRAY
-#define	HAVE_POLLTS
+#define	HAVE_PPOLL
 #define	HAVE_SYS_BITOPS_H
 #define	HAVE_MD5_H
 #define	SHA2_H			



CVS commit: src/external/bsd/dhcpcd/dist/src

2020-09-06 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Sep  6 14:55:34 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcpcd.8.in dhcpcd.c
if-options.c ipv6.c ipv6nd.c logerr.c privsep.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in \
src/external/bsd/dhcpcd/dist/src/logerr.c
cvs rdiff -u -r1.41 -r1.42 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.26 -r1.27 src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.13 -r1.14 src/external/bsd/dhcpcd/dist/src/ipv6.c
cvs rdiff -u -r1.22 -r1.23 src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/privsep.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.38 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.39
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.38	Thu Jun  4 13:08:13 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Sun Sep  6 14:55:34 2020
@@ -777,7 +777,7 @@ make_message(struct bootp **bootpm, cons
 	(type == DHCP_REQUEST &&
 	state->addr->mask.s_addr == lease->mask.s_addr &&
 	(state->new == NULL || IS_DHCP(state->new)) &&
-	!(state->added & STATE_FAKE
+	!(state->added & (STATE_FAKE | STATE_EXPIRED)
 		bootp->ciaddr = state->addr->addr.s_addr;
 
 	bootp->op = BOOTREQUEST;
@@ -836,7 +836,7 @@ make_message(struct bootp **bootpm, cons
 		if (type == DHCP_DECLINE ||
 		(type == DHCP_REQUEST &&
 		(state->addr == NULL ||
-		state->added & STATE_FAKE ||
+		state->added & (STATE_FAKE | STATE_EXPIRED) ||
 		lease->addr.s_addr != state->addr->addr.s_addr)))
 		{
 			putip = true;
@@ -1745,7 +1745,7 @@ send_message(struct interface *ifp, uint
 		goto fail;
 	len = (size_t)r;
 
-	if (!(state->added & STATE_FAKE) &&
+	if (!(state->added & (STATE_FAKE | STATE_EXPIRED)) &&
 	state->addr != NULL &&
 	ipv4_iffindaddr(ifp, >lease.addr, NULL) != NULL)
 		from.s_addr = state->lease.addr.s_addr;
@@ -1869,14 +1869,16 @@ dhcp_discover(void *arg)
 	state->state = DHS_DISCOVER;
 	dhcp_new_xid(ifp);
 	eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
-	if (ifo->fallback)
-		eloop_timeout_add_sec(ifp->ctx->eloop,
-		ifo->reboot, dhcp_fallback, ifp);
+	if (!(state->added & STATE_EXPIRED)) {
+		if (ifo->fallback)
+			eloop_timeout_add_sec(ifp->ctx->eloop,
+			ifo->reboot, dhcp_fallback, ifp);
 #ifdef IPV4LL
-	else if (ifo->options & DHCPCD_IPV4LL)
-		eloop_timeout_add_sec(ifp->ctx->eloop,
-		ifo->reboot, ipv4ll_start, ifp);
+		else if (ifo->options & DHCPCD_IPV4LL)
+			eloop_timeout_add_sec(ifp->ctx->eloop,
+			ifo->reboot, ipv4ll_start, ifp);
 #endif
+	}
 	if (ifo->options & DHCPCD_REQUEST)
 		loginfox("%s: soliciting a DHCP lease (requesting %s)",
 		ifp->name, inet_ntoa(ifo->req_addr));
@@ -1897,30 +1899,21 @@ dhcp_request(void *arg)
 }
 
 static void
-dhcp_expire1(struct interface *ifp)
-{
-	struct dhcp_state *state = D_STATE(ifp);
-
-	eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
-	dhcp_drop(ifp, "EXPIRE");
-	dhcp_unlink(ifp->ctx, state->leasefile);
-	state->interval = 0;
-	if (!(ifp->options->options & DHCPCD_LINK) || ifp->carrier > LINK_DOWN)
-		dhcp_discover(ifp);
-}
-
-static void
 dhcp_expire(void *arg)
 {
 	struct interface *ifp = arg;
+	struct dhcp_state *state = D_STATE(ifp);
 
 	if (ifp->options->options & DHCPCD_LASTLEASE_EXTEND) {
 		logwarnx("%s: DHCP lease expired, extending lease", ifp->name);
-		return;
+		state->added |= STATE_EXPIRED;
+	} else {
+		logerrx("%s: DHCP lease expired", ifp->name);
+		dhcp_drop(ifp, "EXPIRE");
+		dhcp_unlink(ifp->ctx, state->leasefile);
 	}
-
-	logerrx("%s: DHCP lease expired", ifp->name);
-	dhcp_expire1(ifp);
+	state->interval = 0;
+	dhcp_discover(ifp);
 }
 
 #if defined(ARP) || defined(IN_IFF_DUPLICATED)
@@ -2291,7 +2284,9 @@ dhcp_bind(struct interface *ifp)
 		return;
 	}
 	if (state->reason == NULL) {
-		if (state->old && !(state->added & STATE_FAKE)) {
+		if (state->old &&
+		!(state->added & (STATE_FAKE | STATE_EXPIRED)))
+		{
 			if (state->old->yiaddr == state->new->yiaddr &&
 			lease->server.s_addr &&
 			state->state != DHS_REBIND)
@@ -2364,19 +2359,6 @@ dhcp_bind(struct interface *ifp)
 	eloop_event_add(ctx->eloop, state->udp_rfd, dhcp_handleifudp, ifp);
 }
 
-static void
-dhcp_lastlease(void *arg)
-{
-	struct interface *ifp = arg;
-	struct dhcp_state *state = D_STATE(ifp);
-
-	loginfox("%s: timed out contacting a DHCP server, using last lease",
-	ifp->name);
-	dhcp_bind(ifp);
-	state->interval = 0;
-	dhcp_discover(ifp);
-}
-
 static size_t
 dhcp_message_new(struct bootp **bootp,
 const struct in_addr *addr, const struct in_addr *mask)
@@ -2476,6 +2458,26 @@ dhcp_arp_bind(struct interface 

CVS commit: src/external/bsd/dhcpcd/dist/src

2020-07-03 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Jul  3 10:46:45 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcpcd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/external/bsd/dhcpcd/dist/src/dhcpcd.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/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.40 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.41
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.40	Thu Jul  2 13:59:19 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Fri Jul  3 10:46:45 2020
@@ -2186,6 +2186,8 @@ printpidfile:
 
 	if (!(ctx.options & DHCPCD_TEST)) {
 		/* Ensure we have the needed directories */
+		if (mkdir(DBDIR, 0750) == -1 && errno != EEXIST)
+			logerr("%s: mkdir `%s'", __func__, DBDIR);
 		if (mkdir(RUNDIR, 0755) == -1 && errno != EEXIST)
 			logerr("%s: mkdir `%s'", __func__, RUNDIR);
 		if ((pid = pidfile_lock(ctx.pidfile)) != 0) {
@@ -2284,13 +2286,6 @@ printpidfile:
 		}
 	}
 
-	/* If we're not running in privsep, we need to create the DB
-	 * directory here. */
-	if (!(ctx.options & DHCPCD_PRIVSEP)) {
-		if (mkdir(DBDIR, 0755) == -1 && errno != EEXIST)
-			logerr("%s: mkdir `%s'", __func__, DBDIR);
-	}
-
 #ifdef PRIVSEP
 	if (IN_PRIVSEP() && ps_start() == -1) {
 		logerr("ps_start");



CVS commit: src/external/bsd/dhcpcd/dist/src

2020-07-02 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Jul  2 17:15:00 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: logerr.c

Log Message:
dhcpcd: Fix SMALL build


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/logerr.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/src/logerr.c
diff -u src/external/bsd/dhcpcd/dist/src/logerr.c:1.6 src/external/bsd/dhcpcd/dist/src/logerr.c:1.7
--- src/external/bsd/dhcpcd/dist/src/logerr.c:1.6	Thu Jul  2 13:59:19 2020
+++ src/external/bsd/dhcpcd/dist/src/logerr.c	Thu Jul  2 17:15:00 2020
@@ -117,16 +117,15 @@ logprintdate(FILE *stream)
 __printflike(3, 0) static int
 vlogprintf_r(struct logctx *ctx, FILE *stream, const char *fmt, va_list args)
 {
-	FILE *err;
 	int len = 0, e;
 	va_list a;
 #ifndef SMALL
+	FILE *err = ctx->log_err == NULL ? stderr : ctx->log_err;
 	bool log_pid;
 #ifdef LOGERR_TAG
 	bool log_tag;
 #endif
 
-	err = ctx->log_err == NULL ? stderr : ctx->log_err;
 	if ((stream == err && ctx->log_opts & LOGERR_ERR_DATE) ||
 	(stream != err && ctx->log_opts & LOGERR_LOG_DATE))
 	{



CVS commit: src/external/bsd/dhcpcd/dist/src

2020-07-02 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Jul  2 13:59:19 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp6.c dhcpcd.c if-bsd.c
if-options.c ipv6.c ipv6.h ipv6nd.c logerr.c privsep.c script.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/external/bsd/dhcpcd/dist/src/dhcp6.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.39 -r1.40 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.22 -r1.23 src/external/bsd/dhcpcd/dist/src/if-bsd.c
cvs rdiff -u -r1.25 -r1.26 src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/src/ipv6.c
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/src/ipv6.h
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcpcd/dist/src/logerr.c \
src/external/bsd/dhcpcd/dist/src/privsep.c
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/script.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/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.21 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.22
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.21	Mon Jun 15 16:59:05 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c	Thu Jul  2 13:59:19 2020
@@ -3183,14 +3183,12 @@ dhcp6_bind(struct interface *ifp, const 
 			state->state = DH6S_BOUND;
 		state->failed = false;
 
-		if ((state->renew != 0 || state->rebind != 0) &&
-		state->renew != ND6_INFINITE_LIFETIME)
+		if (state->renew && state->renew != ND6_INFINITE_LIFETIME)
 			eloop_timeout_add_sec(ifp->ctx->eloop,
 			state->renew,
 			state->state == DH6S_INFORMED ?
 			dhcp6_startinform : dhcp6_startrenew, ifp);
-		if ((state->rebind != 0 || state->expire != 0) &&
-		state->rebind != ND6_INFINITE_LIFETIME)
+		if (state->rebind && state->rebind != ND6_INFINITE_LIFETIME)
 			eloop_timeout_add_sec(ifp->ctx->eloop,
 			state->rebind, dhcp6_startrebind, ifp);
 		if (state->expire != ND6_INFINITE_LIFETIME)
Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.21 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.22
--- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.21	Mon Jun 15 16:59:05 2020
+++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c	Thu Jul  2 13:59:19 2020
@@ -61,6 +61,16 @@
 /* Debugging Router Solicitations is a lot of spam, so disable it */
 //#define DEBUG_RS
 
+#ifndef ND_RA_FLAG_HOME_AGENT
+#define	ND_RA_FLAG_HOME_AGENT	0x20	/* Home Agent flag in RA */
+#endif
+#ifndef ND_RA_FLAG_PROXY
+#define	ND_RA_FLAG_PROXY	0x04	/* Proxy */
+#endif
+#ifndef ND_OPT_PI_FLAG_ROUTER
+#define	ND_OPT_PI_FLAG_ROUTER	0x20	/* Router flag in PI */
+#endif
+
 #ifndef ND_OPT_RDNSS
 #define ND_OPT_RDNSS			25
 struct nd_opt_rdnss {   /* RDNSS option RFC 6106 */
@@ -1096,6 +1106,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx,
 	uint32_t old_lifetime;
 	int ifmtu;
 	int loglevel;
+	unsigned int flags;
 #ifdef IPV6_MANAGETEMPADDR
 	bool new_ia;
 #endif
@@ -1299,13 +1310,15 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx,
 		case ND_OPT_PREFIX_INFORMATION:
 			loglevel = new_data ? LOG_ERR : LOG_DEBUG;
 			if (ndo.nd_opt_len != 4) {
-logmessage(loglevel, "%s: invalid option len for prefix",
+logmessage(loglevel,
+"%s: invalid option len for prefix",
 ifp->name);
 continue;
 			}
 			memcpy(, p, sizeof(pi));
 			if (pi.nd_opt_pi_prefix_len > 128) {
-logmessage(loglevel, "%s: invalid prefix len", ifp->name);
+logmessage(loglevel, "%s: invalid prefix len",
+ifp->name);
 continue;
 			}
 			/* nd_opt_pi_prefix is not aligned. */
@@ -1314,27 +1327,33 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx,
 			if (IN6_IS_ADDR_MULTICAST(_prefix) ||
 			IN6_IS_ADDR_LINKLOCAL(_prefix))
 			{
-logmessage(loglevel, "%s: invalid prefix in RA", ifp->name);
+logmessage(loglevel, "%s: invalid prefix in RA",
+ifp->name);
 continue;
 			}
 			if (ntohl(pi.nd_opt_pi_preferred_time) >
 			ntohl(pi.nd_opt_pi_valid_time))
 			{
-logmessage(loglevel, "%s: pltime > vltime", ifp->name);
+logmessage(loglevel, "%s: pltime > vltime",
+ifp->name);
 continue;
 			}
+
+			flags = IPV6_AF_RAPFX;
+			/* If no flags are set, that means the prefix is
+			 * available via the router. */
+			if (pi.nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK)
+flags |= IPV6_AF_ONLINK;
+			if (pi.nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO &&
+			rap->iface->options->options &
+			DHCPCD_IPV6RA_AUTOCONF)
+flags |= IPV6_AF_AUTOCONF;
+			if (pi.nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ROUTER)
+flags |= IPV6_AF_ROUTER;
+
 			ia = ipv6nd_rapfindprefix(rap,
 			_prefix, pi.nd_opt_pi_prefix_len);
 			if (ia == NULL) {
-unsigned int flags;
-
-flags = IPV6_AF_RAPFX;
-if (pi.nd_opt_pi_flags_reserved &
-ND_OPT_PI_FLAG_AUTO &&
-

CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2020-06-15 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Jun 15 17:02:58 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
dhcpcd: Build privsep resource limited sandbox.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.53 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.54
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.53	Thu Jun 11 16:05:54 2020
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Mon Jun 15 17:02:58 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.53 2020/06/11 16:05:54 roy Exp $
+# $NetBSD: Makefile,v 1.54 2020/06/15 17:02:58 roy Exp $
 #
 
 WARNS?=		6
@@ -17,7 +17,7 @@ SRCS+=		if-bsd.c
 # This should be fine for ramdisk based installers
 .if !defined(SMALLPROG)
 CPPFLAGS+=	-DPRIVSEP -DPRIVSEP_USER=\"_dhcpcd\"
-SRCS+=		privsep.c privsep-root.c privsep-inet.c
+SRCS+=		privsep.c privsep-root.c privsep-inet.c privsep-control.c
 SRCS+=		privsep-bsd.c
 .endif
 



CVS commit: src/external/bsd/dhcpcd/dist/src

2020-06-15 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Jun 15 16:59:05 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: bpf.c dhcp6.c dhcpcd.c if-bsd.c
if-options.c ipv6nd.c logerr.c privsep.c script.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/src/bpf.c
cvs rdiff -u -r1.20 -r1.21 src/external/bsd/dhcpcd/dist/src/dhcp6.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.38 -r1.39 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.21 -r1.22 src/external/bsd/dhcpcd/dist/src/if-bsd.c
cvs rdiff -u -r1.24 -r1.25 src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/src/logerr.c \
src/external/bsd/dhcpcd/dist/src/privsep.c
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/script.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/src/bpf.c
diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.15 src/external/bsd/dhcpcd/dist/src/bpf.c:1.16
--- src/external/bsd/dhcpcd/dist/src/bpf.c:1.15	Sun May 31 12:52:11 2020
+++ src/external/bsd/dhcpcd/dist/src/bpf.c	Mon Jun 15 16:59:05 2020
@@ -703,6 +703,14 @@ bpf_bootp(const struct bpf *bpf, __unuse
 		return -1;
 	return 0;
 #else
+#ifdef PRIVSEP
+#if defined(__sun) /* Solaris cannot send via BPF. */
+#elif defined(BIOCSETF)
+#warning No BIOCSETWF support - a compromised BPF can be used as a raw socket
+#else
+#warning A compromised PF_PACKET socket can be used as a raw socket
+#endif
+#endif
 	return bpf_bootp_rw(bpf, true);
 #endif
 }

Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.20 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.21
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.20	Thu Jun  4 13:08:13 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c	Mon Jun 15 16:59:05 2020
@@ -541,12 +541,12 @@ dhcp6_delegateaddr(struct in6_addr *addr
 		state->reason = "DELEGATED6";
 	}
 
-	if (sla == NULL || sla->sla_set == 0) {
+	if (sla == NULL || !sla->sla_set) {
 		/* No SLA set, so make an assumption of
 		 * desired SLA and prefix length. */
 		asla.sla = ifp->index;
 		asla.prefix_len = 0;
-		asla.sla_set = 0;
+		asla.sla_set = false;
 		sla = 
 	} else if (sla->prefix_len == 0) {
 		/* An SLA was given, but prefix length was not.
@@ -554,7 +554,7 @@ dhcp6_delegateaddr(struct in6_addr *addr
 		 * potentially more than one interface. */
 		asla.sla = sla->sla;
 		asla.prefix_len = 0;
-		asla.sla_set = 0;
+		asla.sla_set = sla->sla_set;
 		sla = 
 	}
 
@@ -562,16 +562,15 @@ dhcp6_delegateaddr(struct in6_addr *addr
 		uint32_t sla_max;
 		int bits;
 
-		if (ia->sla_max == 0) {
+		sla_max = ia->sla_max;
+		if (sla_max == 0 && (sla == NULL || !sla->sla_set)) {
 			const struct interface *ifi;
 
-			sla_max = 0;
 			TAILQ_FOREACH(ifi, ifp->ctx->ifaces, next) {
 if (ifi->index > sla_max)
 	sla_max = ifi->index;
 			}
-		} else
-			sla_max = ia->sla_max;
+		}
 
 		bits = fls32(sla_max);
 
@@ -1727,6 +1726,7 @@ dhcp6_fail(struct interface *ifp)
 		if (state->old != NULL)
 			script_runreason(ifp, "EXPIRE6");
 		dhcp_unlink(ifp->ctx, state->leasefile);
+		dhcp6_addrequestedaddrs(ifp);
 	}
 
 	if (!dhcp6_startdiscoinform(ifp)) {
@@ -2672,6 +2672,7 @@ ex:
 	free(state->new);
 	state->new = NULL;
 	state->new_len = 0;
+	dhcp6_addrequestedaddrs(ifp);
 	return bytes == 0 ? 0 : -1;
 }
 
Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.20 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.21
--- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.20	Sun May 31 12:52:11 2020
+++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c	Mon Jun 15 16:59:05 2020
@@ -1100,7 +1100,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx,
 	bool new_ia;
 #endif
 
-	if (ifp == NULL) {
+	if (ifp == NULL || RS_STATE(ifp) == NULL) {
 #ifdef DEBUG_RS
 		logdebugx("RA for unexpected interface from %s", sfrom);
 #endif
@@ -1155,10 +1155,8 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx,
 		if (ifp == rap->iface)
 			break;
 	}
-	if (rap != NULL && rap->willexpire) {
-		logerrx("settng def RA");
+	if (rap != NULL && rap->willexpire)
 		ipv6nd_applyra(ifp);
-	}
 #endif
 
 	TAILQ_FOREACH(rap, ctx->ra_routers, next) {

Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.38 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.39
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.38	Thu Jun  4 13:08:13 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Mon Jun 15 16:59:05 2020
@@ -943,9 +943,12 @@ dhcpcd_startinterface(void *arg)
 		}
 
 #ifdef DHCP6
-		if (ifo->options & DHCPCD_DHCP6) {
+		/* DHCPv6 could be turned off, but the interface
+		 * is still delegated to. */
+		if (ifp->active)
 			dhcp6_find_delegates(ifp);
 
+		if (ifo->options & DHCPCD_DHCP6) {
 			if (ifp->active == IF_ACTIVE_USER) {
 enum DH6S d6_state;
 

CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2020-06-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Jun 11 16:05:54 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
dhcpcd: Disable priviledge separation and sandboxing for SMALLPROG builds

It's a fair chunk of code and is probably safe enough for our ramdisks.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.52 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.53
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.52	Sat May  2 19:35:03 2020
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Thu Jun 11 16:05:54 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.52 2020/05/02 19:35:03 fox Exp $
+# $NetBSD: Makefile,v 1.53 2020/06/11 16:05:54 roy Exp $
 #
 
 WARNS?=		6
@@ -13,9 +13,13 @@ SRCS+=		if.c if-options.c route.c sa.c s
 SRCS+=		dhcp-common.c dhcpcd-embedded.c
 SRCS+=		if-bsd.c
 
+# Disable privilege separation and sandboxing
+# This should be fine for ramdisk based installers
+.if !defined(SMALLPROG)
 CPPFLAGS+=	-DPRIVSEP -DPRIVSEP_USER=\"_dhcpcd\"
 SRCS+=		privsep.c privsep-root.c privsep-inet.c
 SRCS+=		privsep-bsd.c
+.endif
 
 CPPFLAGS+=	-DHAVE_CONFIG_H -D_OPENBSD_SOURCE
 
@@ -31,7 +35,9 @@ SRCS+=		auth.c
 .if (${USE_INET} != "no")
 CPPFLAGS+=	-DINET
 SRCS+=		bpf.c dhcp.c ipv4.c
+.if !defined(SMALLPROG)
 SRCS+=		privsep-bpf.c
+.endif
 
 .if (${MKLIBCSANITIZER:Uno} == "yes")
 .if (${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} == 8)



CVS commit: src/external/bsd/dhcpcd/include

2020-06-04 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Jun  4 13:09:45 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/include: config.h

Log Message:
dhcpcd: kqueue(2) support removed in favour of pollts(2)


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcpcd/include/config.h

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/include/config.h
diff -u src/external/bsd/dhcpcd/include/config.h:1.5 src/external/bsd/dhcpcd/include/config.h:1.6
--- src/external/bsd/dhcpcd/include/config.h:1.5	Thu Apr  2 12:56:01 2020
+++ src/external/bsd/dhcpcd/include/config.h	Thu Jun  4 13:09:45 2020
@@ -18,8 +18,7 @@
 #define	HAVE_SYS_QUEUE_H
 #define	HAVE_SYS_RBTREE_H
 #define	HAVE_REALLOCARRAY
-#define	HAVE_KQUEUE
-#define	HAVE_KQUEUE1
+#define	HAVE_POLLTS
 #define	HAVE_SYS_BITOPS_H
 #define	HAVE_MD5_H
 #define	SHA2_H			



CVS commit: src/external/bsd/dhcpcd/dist/src

2020-06-04 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Jun  4 13:08:13 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.8.in dhcpcd.c
if-bsd.c privsep.c script.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/external/bsd/dhcpcd/dist/src/dhcp.c \
src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.19 -r1.20 src/external/bsd/dhcpcd/dist/src/dhcp6.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in \
src/external/bsd/dhcpcd/dist/src/script.c
cvs rdiff -u -r1.20 -r1.21 src/external/bsd/dhcpcd/dist/src/if-bsd.c
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcpcd/dist/src/privsep.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.37 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.38
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.37	Sun May 31 12:52:11 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Thu Jun  4 13:08:13 2020
@@ -1034,7 +1034,7 @@ make_message(struct bootp **bootpm, cons
 	auth = NULL;	/* appease GCC */
 	auth_len = 0;
 	if (ifo->auth.options & DHCPCD_AUTH_SEND) {
-		ssize_t alen = dhcp_auth_encode(>auth,
+		ssize_t alen = dhcp_auth_encode(ifp->ctx, >auth,
 		state->auth.token,
 		NULL, 0, 4, type, NULL, 0);
 		if (alen != -1 && alen > UINT8_MAX) {
@@ -1129,7 +1129,7 @@ make_message(struct bootp **bootpm, cons
 
 #ifdef AUTH
 	if (ifo->auth.options & DHCPCD_AUTH_SEND && auth_len != 0)
-		dhcp_auth_encode(>auth, state->auth.token,
+		dhcp_auth_encode(ifp->ctx, >auth, state->auth.token,
 		(uint8_t *)bootp, len, 4, type, auth, auth_len);
 #endif
 
@@ -2747,6 +2747,18 @@ dhcp_drop(struct interface *ifp, const c
 #endif
 		}
 	}
+#ifdef AUTH
+	else if (state->auth.reconf != NULL) {
+		/*
+		 * Drop the lease as the token may only be present
+		 * in the initial reply message and not subsequent
+		 * renewals.
+		 * If dhcpcd is restarted, the token is lost.
+		 * XXX persist this in another file?
+		 */
+		dhcp_unlink(ifp->ctx, state->leasefile);
+	}
+#endif
 
 	eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
 #ifdef AUTH
@@ -4176,3 +4188,24 @@ dhcp_handleifa(int cmd, struct ipv4_addr
 
 	return ia;
 }
+
+#ifndef SMALL
+int
+dhcp_dump(struct interface *ifp)
+{
+	struct dhcp_state *state;
+
+	ifp->if_data[IF_DATA_DHCP] = state = calloc(1, sizeof(*state));
+	if (state == NULL) {
+		logerr(__func__);
+		return -1;
+	}
+	state->new_len = read_lease(ifp, >new);
+	if (state->new == NULL) {
+		logerr("read_lease");
+		return -1;
+	}
+	state->reason = "DUMP";
+	return script_runreason(ifp, state->reason);
+}
+#endif
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.37 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.38
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.37	Sun May 31 12:52:11 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Thu Jun  4 13:08:13 2020
@@ -29,6 +29,7 @@
 const char dhcpcd_copyright[] = "Copyright (c) 2006-2020 Roy Marples";
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -86,6 +87,7 @@ const int dhcpcd_signals[] = {
 	SIGHUP,
 	SIGUSR1,
 	SIGUSR2,
+	SIGCHLD,
 };
 const size_t dhcpcd_signals_len = __arraycount(dhcpcd_signals);
 
@@ -1340,6 +1342,9 @@ stop_all_interfaces(struct dhcpcd_ctx *c
 	struct interface *ifp;
 
 	ctx->options |= DHCPCD_EXITING;
+	if (ctx->ifaces == NULL)
+		return;
+
 	/* Drop the last interface first */
 	TAILQ_FOREACH_REVERSE(ifp, ctx->ifaces, if_head, next) {
 		if (!ifp->active)
@@ -1395,7 +1400,7 @@ dhcpcd_signal_cb(int sig, void *arg)
 	unsigned long long opts;
 	int exit_code;
 
-	if (ctx->options & DHCPCD_FORKED) {
+	if (sig != SIGCHLD && ctx->options & DHCPCD_FORKED) {
 		pid_t pid = pidfile_read(ctx->pidfile);
 		if (pid == -1) {
 			if (errno != ENOENT)
@@ -1441,6 +1446,10 @@ dhcpcd_signal_cb(int sig, void *arg)
 		if (logopen(ctx->logfile) == -1)
 			logerr(__func__);
 		return;
+	case SIGCHLD:
+		while (waitpid(-1, NULL, WNOHANG) > 0)
+			;
+		return;
 	default:
 		logerrx("received signal %d but don't know what to do with it",
 		sig);
@@ -1663,20 +1672,13 @@ dumperr:
 	return 0;
 }
 
-static const char *dumpskip[] = {
-	"PATH=",
-	"pid=",
-	"chroot=",
-};
-
 static int
 dhcpcd_readdump(struct dhcpcd_ctx *ctx)
 {
 	int error = 0;
-	size_t nifaces, buflen = 0, dlen, i;
+	size_t nifaces, buflen = 0, dlen;
 	ssize_t len;
-	char *buf = NULL, *dp, *de;
-	const char *skip;
+	char *buf = NULL;
 
 again1:
 	len = read(ctx->control_fd, , sizeof(nifaces));
@@ -1723,26 +1725,7 @@ again3:
 			error = -1;
 			goto out;
 		}
-		dp = buf;
-		de = dp + dlen;
-		if (*(de - 1) != '\0') {
-			errno = EINVAL;
-			error = -1;
-			goto out;
-		}
-		while (dp < de) {
-			for (i = 0; i < __arraycount(dumpskip); i++) {
-skip = dumpskip[i];
-if (strncmp(dp, skip, strlen(skip)) == 0)
-	

CVS commit: src/external/bsd/dhcpcd/dist

2020-05-31 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun May 31 12:52:11 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/hooks: dhcpcd-run-hooks.in
src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcp6.c dhcpcd.8.in
dhcpcd.c if-bsd.c if-options.c ipv6.c ipv6.h ipv6nd.c logerr.c
privsep.c script.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/dhcpcd/dist/src/bpf.c
cvs rdiff -u -r1.36 -r1.37 src/external/bsd/dhcpcd/dist/src/dhcp.c \
src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.18 -r1.19 src/external/bsd/dhcpcd/dist/src/dhcp6.c
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in \
src/external/bsd/dhcpcd/dist/src/script.c
cvs rdiff -u -r1.19 -r1.20 src/external/bsd/dhcpcd/dist/src/if-bsd.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.23 -r1.24 src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/src/ipv6.c
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/ipv6.h
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcpcd/dist/src/logerr.c
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/dhcpcd/dist/src/privsep.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/hooks/dhcpcd-run-hooks.in
diff -u src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.5 src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.6
--- src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.5	Thu Apr  2 12:41:48 2020
+++ src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in	Sun May 31 12:52:11 2020
@@ -211,7 +211,7 @@ valid_domainname_list()
 }
 
 # With the advent of alternative init systems, it's possible to have
-# more than one installed. So we need to try and guess what one we're
+# more than one installed. So we need to try to guess what one we're
 # using unless overridden by configure.
 detect_init()
 {

Index: src/external/bsd/dhcpcd/dist/src/bpf.c
diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.14 src/external/bsd/dhcpcd/dist/src/bpf.c:1.15
--- src/external/bsd/dhcpcd/dist/src/bpf.c:1.14	Thu Apr  2 12:41:48 2020
+++ src/external/bsd/dhcpcd/dist/src/bpf.c	Sun May 31 12:52:11 2020
@@ -57,8 +57,6 @@
 #include "if.h"
 #include "logerr.h"
 
-#define	ARP_ADDRS_MAX	3
-
 /* BPF helper macros */
 #ifdef __linux__
 #define	BPF_WHOLEPACKET		0x7fff /* work around buggy LPF filters */
@@ -85,7 +83,7 @@ size_t
 bpf_frame_header_len(const struct interface *ifp)
 {
 
-	switch (ifp->family) {
+	switch (ifp->hwtype) {
 	case ARPHRD_ETHER:
 		return sizeof(struct ether_header);
 	default:
@@ -98,7 +96,7 @@ bpf_frame_header_src(const struct interf
 {
 	uint8_t *f = fh;
 
-	switch (ifp->family) {
+	switch (ifp->hwtype) {
 	case ARPHRD_ETHER:
 		*len = sizeof(((struct ether_header *)0)->ether_shost);
 		return f + offsetof(struct ether_header, ether_shost);
@@ -114,7 +112,7 @@ bpf_frame_header_dst(const struct interf
 {
 	uint8_t *f = fh;
 
-	switch (ifp->family) {
+	switch (ifp->hwtype) {
 	case ARPHRD_ETHER:
 		*len = sizeof(((struct ether_header *)0)->ether_dhost);
 		return f + offsetof(struct ether_header, ether_dhost);
@@ -129,12 +127,12 @@ static const uint8_t etherbcastaddr[] =
 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 
 int
-bpf_frame_bcast(const struct interface *ifp, const char *frame)
+bpf_frame_bcast(const struct interface *ifp, const void *frame)
 {
 
-	switch (ifp->family) {
+	switch (ifp->hwtype) {
 	case ARPHRD_ETHER:
-		return memcmp(frame +
+		return memcmp((const char *)frame +
 		offsetof(struct ether_header, ether_dhost),
 		etherbcastaddr, sizeof(etherbcastaddr));
 	default:
@@ -148,15 +146,15 @@ bpf_frame_bcast(const struct interface *
 
 const char *bpf_name = "Berkley Packet Filter";
 
-int
-bpf_open(struct interface *ifp, int (*filter)(struct interface *, int))
-{
-	struct ipv4_state *state;
-	int fd = -1;
-	struct ifreq ifr;
+struct bpf *
+bpf_open(const struct interface *ifp,
+int (*filter)(const struct bpf *, const struct in_addr *),
+const struct in_addr *ia)
+{
+	struct bpf *bpf;
+	struct bpf_version pv = { .bv_major = 0, .bv_minor = 0 };
+	struct ifreq ifr = { .ifr_flags = 0 };
 	int ibuf_len = 0;
-	size_t buf_len;
-	struct bpf_version pv;
 #ifdef BIOCIMMEDIATE
 	unsigned int flags;
 #endif
@@ -164,8 +162,13 @@ bpf_open(struct interface *ifp, int (*fi
 	int fd_opts;
 #endif
 
+	bpf = calloc(1, sizeof(*bpf));
+	if (bpf == NULL)
+		return NULL;
+	bpf->bpf_ifp = ifp;
+
 #ifdef _PATH_BPF
-	fd = open(_PATH_BPF, O_RDWR | O_NONBLOCK
+	bpf->bpf_fd = open(_PATH_BPF, O_RDWR | O_NONBLOCK
 #ifdef O_CLOEXEC
 		| O_CLOEXEC
 #endif
@@ -176,27 +179,24 @@ bpf_open(struct interface *ifp, int (*fi
 
 	do {
 		snprintf(device, sizeof(device), "/dev/bpf%d", n++);
-		fd = open(device, O_RDWR | O_NONBLOCK
+	

CVS commit: src/external/bsd/dhcpcd/dist/src

2020-05-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 10 17:58:16 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcpcd.c

Log Message:
Add SIGPIPE to the list of dhcpcd affected signals since we sigignore it.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/external/bsd/dhcpcd/dist/src/dhcpcd.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/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.35 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.36
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.35	Tue Apr 21 05:55:33 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Sun May 10 13:58:16 2020
@@ -80,6 +80,7 @@ const int dhcpcd_signals[] = {
 	SIGTERM,
 	SIGINT,
 	SIGALRM,
+	SIGPIPE,
 	SIGHUP,
 	SIGUSR1,
 	SIGUSR2,



CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2020-05-02 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Sat May  2 19:35:03 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
external/bsd/dhcpcd: Suppress -Werror=sign-conversion error.

Add -Wno-error=sign-conversion to prevent build failure, when run with 
MKLIBCSANITIZER=yes.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.

Reviewed by: kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.51 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.52
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.51	Thu Apr  2 12:56:01 2020
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Sat May  2 19:35:03 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.51 2020/04/02 12:56:01 roy Exp $
+# $NetBSD: Makefile,v 1.52 2020/05/02 19:35:03 fox Exp $
 #
 
 WARNS?=		6
@@ -32,6 +32,13 @@ SRCS+=		auth.c
 CPPFLAGS+=	-DINET
 SRCS+=		bpf.c dhcp.c ipv4.c
 SRCS+=		privsep-bpf.c
+
+.if (${MKLIBCSANITIZER:Uno} == "yes")
+.if (${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} == 8)
+COPTS.dhcp.c+=	-Wno-error=sign-conversion
+.endif
+.endif
+
 .if !defined(SMALLPROG)
 CPPFLAGS+=	-DARP
 SRCS+=		arp.c



CVS commit: src/external/bsd/dhcpcd/dist/src

2020-04-21 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Apr 21 09:55:33 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.c if-bsd.c
if-options.c ipv6.c ipv6nd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.17 -r1.18 src/external/bsd/dhcpcd/dist/src/dhcp6.c
cvs rdiff -u -r1.34 -r1.35 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.18 -r1.19 src/external/bsd/dhcpcd/dist/src/if-bsd.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.22 -r1.23 src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/ipv6.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.35 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.36
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.35	Mon Apr 13 15:46:26 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Tue Apr 21 09:55:33 2020
@@ -3494,8 +3494,9 @@ dhcp_packet(struct interface *ifp, uint8
 			__func__, ifp->name);
 			return;
 		}
-		data += fl;
 		len -= fl;
+		/* Move the data to avoid alignment errors. */
+		memmove(data, data + fl, len);
 	}
 
 	/* Validate filter. */
@@ -3608,15 +3609,18 @@ dhcp_readudp(struct dhcpcd_ctx *ctx, str
 		.iov_base = buf,
 		.iov_len = sizeof(buf),
 	};
+	union {
+		struct cmsghdr hdr;
 #ifdef IP_RECVIF
-	unsigned char ctl[CMSG_SPACE(sizeof(struct sockaddr_dl))] = { 0 };
+		uint8_t buf[CMSG_SPACE(sizeof(struct sockaddr_dl))];
 #else
-	unsigned char ctl[CMSG_SPACE(sizeof(struct in_pktinfo))] = { 0 };
+		uint8_t buf[CMSG_SPACE(sizeof(struct in_pktinfo))];
 #endif
+	} cmsgbuf = { .buf = { 0 } };
 	struct msghdr msg = {
 	.msg_name = , .msg_namelen = sizeof(from),
 	.msg_iov = , .msg_iovlen = 1,
-	.msg_control = ctl, .msg_controllen = sizeof(ctl),
+	.msg_control = buf, .msg_controllen = sizeof(cmsgbuf.buf),
 	};
 	int s;
 	ssize_t bytes;

Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.17 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.18
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.17	Mon Apr 13 15:46:26 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c	Tue Apr 21 09:55:33 2020
@@ -1585,6 +1585,7 @@ dhcp6_startdiscover(void *arg)
 {
 	struct interface *ifp;
 	struct dhcp6_state *state;
+	int llevel;
 
 	ifp = arg;
 	state = D6_STATE(ifp);
@@ -1592,7 +1593,11 @@ dhcp6_startdiscover(void *arg)
 	if (state->reason == NULL || strcmp(state->reason, "TIMEOUT6") != 0)
 		dhcp6_delete_delegates(ifp);
 #endif
-	loginfox("%s: soliciting a DHCPv6 lease", ifp->name);
+	if (state->new == NULL && !state->failed)
+		llevel = LOG_INFO;
+	else
+		llevel = LOG_DEBUG;
+	logmessage(llevel, "%s: soliciting a DHCPv6 lease", ifp->name);
 	state->state = DH6S_DISCOVER;
 	state->RTC = 0;
 	state->IMD = SOL_MAX_DELAY;
@@ -1616,11 +1621,15 @@ dhcp6_startinform(void *arg)
 {
 	struct interface *ifp;
 	struct dhcp6_state *state;
+	int llevel;
 
 	ifp = arg;
 	state = D6_STATE(ifp);
-	if (state->new == NULL || ifp->options->options & DHCPCD_DEBUG)
-		loginfox("%s: requesting DHCPv6 information", ifp->name);
+	if (state->new == NULL && !state->failed)
+		llevel = LOG_INFO;
+	else
+		llevel = LOG_DEBUG;
+	logmessage(llevel, "%s: requesting DHCPv6 information", ifp->name);
 	state->state = DH6S_INFORM;
 	state->RTC = 0;
 	state->IMD = INF_MAX_DELAY;
@@ -1677,6 +1686,8 @@ dhcp6_fail(struct interface* ifp)
 {
 	struct dhcp6_state *state = D6_STATE(ifp);
 
+	state->failed = true;
+
 	/* RFC3315 18.1.2 says that prior addresses SHOULD be used on failure.
 	 * RFC2131 3.2.3 says that MAY chose to use the prior address.
 	 * Because dhcpcd was written first for RFC2131, we have the LASTLEASE
@@ -1711,33 +1722,43 @@ dhcp6_fail(struct interface* ifp)
 	}
 }
 
+static int
+dhcp6_failloglevel(struct interface *ifp)
+{
+	const struct dhcp6_state *state = D6_CSTATE(ifp);
+
+	return state->failed ? LOG_DEBUG : LOG_ERR;
+}
+
 static void
 dhcp6_failconfirm(void *arg)
 {
-	struct interface *ifp;
+	struct interface *ifp = arg;
+	int llevel = dhcp6_failloglevel(ifp);
 
-	ifp = arg;
-	logerrx("%s: failed to confirm prior address", ifp->name);
+	logmessage(llevel, "%s: failed to confirm prior DHCPv6 address",
+	ifp->name);
 	dhcp6_fail(ifp);
 }
 
 static void
 dhcp6_failrequest(void *arg)
 {
-	struct interface *ifp;
+	struct interface *ifp = arg;
+	int llevel = dhcp6_failloglevel(ifp);
 
-	ifp = arg;
-	logerrx("%s: failed to request address", ifp->name);
+	logmessage(llevel, "%s: failed to request DHCPv6 address", ifp->name);
 	dhcp6_fail(ifp);
 }
 
 static void
 dhcp6_failinform(void *arg)
 {
-	struct interface *ifp;
+	struct interface *ifp = arg;
+	int llevel = dhcp6_failloglevel(ifp);
 
-	ifp = arg;
-	logerrx("%s: failed to request 

CVS commit: src/external/bsd/dhcpcd/dist/src

2020-04-15 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Apr 15 15:55:24 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: privsep.c

Log Message:
privsep: Redirect to /dev/null unless test or quiet and not debug

Keeps the rtsol like behaviour the same.

Fixes PR bin/55170


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 src/external/bsd/dhcpcd/dist/src/privsep.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/src/privsep.c
diff -u src/external/bsd/dhcpcd/dist/src/privsep.c:1.1.1.2 src/external/bsd/dhcpcd/dist/src/privsep.c:1.2
--- src/external/bsd/dhcpcd/dist/src/privsep.c:1.1.1.2	Mon Apr 13 15:42:21 2020
+++ src/external/bsd/dhcpcd/dist/src/privsep.c	Wed Apr 15 15:55:24 2020
@@ -243,7 +243,9 @@ ps_dostart(struct dhcpcd_ctx *ctx,
 	if (callback(recv_ctx) == -1)
 		goto errexit;
 
-	if (!(ctx->options & (DHCPCD_TEST | DHCPCD_DEBUG))) {
+	if (!(ctx->options & DHCPCD_DEBUG) &&
+	   (!(ctx->options & DHCPCD_TEST) || loggetopts() & LOGERR_QUIET))
+	{
 		freopen(_PATH_DEVNULL, "w", stdout);
 		freopen(_PATH_DEVNULL, "w", stderr);
 	}



CVS commit: src/external/bsd/dhcpcd/dist/src

2020-04-15 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Apr 15 15:54:18 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcpcd.c

Log Message:
dhcpcd: Don't open a control socket in test mode

Fixes PR bin/55170


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/external/bsd/dhcpcd/dist/src/dhcpcd.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/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.33 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.34
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.33	Mon Apr 13 15:46:26 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Wed Apr 15 15:54:18 2020
@@ -2207,7 +2207,8 @@ printpidfile:
 		goto run_loop;
 #endif
 
-	if (control_start(,
+	if (!(ctx.options & DHCPCD_TEST) &&
+	control_start(,
 	ctx.options & DHCPCD_MASTER ? NULL : argv[optind]) == -1)
 	{
 		logerr("%s: control_start", __func__);



CVS commit: src/external/bsd/dhcpcd/dist

2020-04-13 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Apr 13 15:46:26 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.c if-bsd.c
if-options.c ipv6.c ipv6.h ipv6nd.c script.c
Removed Files:
src/external/bsd/dhcpcd/dist/hooks: 00-linux 02-dump

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/dhcpcd/dist/hooks/00-linux \
src/external/bsd/dhcpcd/dist/hooks/02-dump
cvs rdiff -u -r1.34 -r1.35 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.16 -r1.17 src/external/bsd/dhcpcd/dist/src/dhcp6.c
cvs rdiff -u -r1.32 -r1.33 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.17 -r1.18 src/external/bsd/dhcpcd/dist/src/if-bsd.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.21 -r1.22 src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/ipv6.c \
src/external/bsd/dhcpcd/dist/src/ipv6.h
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/src/script.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.34 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.35
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.34	Thu Apr  2 12:41:48 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Mon Apr 13 15:46:26 2020
@@ -2301,7 +2301,7 @@ dhcp_bind(struct interface *ifp)
 	if (!state->lease.frominfo &&
 	!(ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC)))
 		if (write_lease(ifp, state->new, state->new_len) == -1)
-			logerr(__func__);
+			logerr("write_lease: %s", state->leasefile);
 
 	/* Close the BPF filter as we can now receive DHCP messages
 	 * on a UDP socket. */
@@ -3370,7 +3370,7 @@ is_packet_udp_bootp(void *packet, size_t
 	memcpy(, (char *)ip + ip_hlen, sizeof(udp));
 	if (ntohs(udp.uh_ulen) < sizeof(udp))
 		return false;
-	if (ip_hlen + (size_t)ntohs(udp.uh_ulen) > plen)
+	if (ip_hlen + ntohs(udp.uh_ulen) > plen)
 		return false;
 
 	/* Check it's to and from the right ports. */

Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.16 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.17
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.16	Thu Apr  2 12:41:48 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c	Mon Apr 13 15:46:26 2020
@@ -2503,10 +2503,8 @@ dhcp6_writelease(const struct interface 
 	logdebugx("%s: writing lease `%s'", ifp->name, state->leasefile);
 
 	fd = open(state->leasefile, O_WRONLY | O_CREAT | O_TRUNC, 0644);
-	if (fd == -1) {
-		logerr(__func__);
+	if (fd == -1)
 		return -1;
-	}
 	bytes = write(fd, state->new, state->new_len);
 	close(fd);
 	return bytes;
@@ -2710,7 +2708,7 @@ dhcp6_ifdelegateaddr(struct interface *i
 		vl |= sla->suffix;
 		be64enc(daddr.s6_addr + 8, vl);
 	} else {
-		dadcounter = ipv6_makeaddr(, ifp, , pfxlen);
+		dadcounter = ipv6_makeaddr(, ifp, , pfxlen, 0);
 		if (dadcounter == -1) {
 			logerrx("%s: error adding slaac to prefix_len %d",
 			ifp->name, pfxlen);
@@ -3162,7 +3160,8 @@ dhcp6_bind(struct interface *ifp, const 
 			ifp->name, state->expire);
 		rt_build(ifp->ctx, AF_INET6);
 		if (!confirmed && !timedout)
-			dhcp6_writelease(ifp);
+			if (dhcp6_writelease(ifp) == -1)
+logerr("dhcp6_writelease: %s",state->leasefile);
 #ifndef SMALL
 		dhcp6_delegate_prefix(ifp);
 #endif

Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.32 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.33
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.32	Thu Apr  2 12:41:48 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Mon Apr 13 15:46:26 2020
@@ -781,8 +781,10 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *
 			 * maybe on a new network. */
 			ipv6nd_startexpire(ifp);
 #endif
+#ifdef IPV6_MANAGETEMPADDR
 			/* RFC4941 Section 3.5 */
-			ipv6_gentempifid(ifp);
+			ipv6_regentempaddrs(ifp);
+#endif
 #endif
 			dhcpcd_startinterface(ifp);
 		}
@@ -1552,26 +1554,39 @@ dhcpcd_handleargs(struct dhcpcd_ctx *ctx
 		ctx->options |= DHCPCD_DUMPLEASE;
 		size_t nifaces = 0;
 
-		for (oi = optind; oi < argc; oi++) {
-			if ((ifp = if_find(ctx->ifaces, argv[oi])) == NULL)
-continue;
+		TAILQ_FOREACH(ifp, ctx->ifaces, next) {
 			if (!ifp->active)
 continue;
-			opt = send_interface(NULL, ifp, af);
-			if (opt != -1)
+			for (oi = optind; oi < argc; oi++) {
+if (strcmp(ifp->name, argv[oi]) == 0)
+	break;
+			}
+			if (optind == argc || oi < argc) {
+opt = send_interface(NULL, ifp, af);
+if (opt == -1)
+	goto dumperr;
 nifaces += (size_t)opt;
+			}
 		}
 		if (write(fd->fd, , sizeof(nifaces)) != sizeof(nifaces))
-			return -1;
-		for (oi = optind; oi < argc; oi++) {
-			if ((ifp = if_find(ctx->ifaces, argv[oi])) == NULL)
-continue;
+			goto dumperr;
+		TAILQ_FOREACH(ifp, ctx->ifaces, next) {
 			if 

CVS commit: src/external/bsd/dhcpcd/dist/src

2020-04-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr  5 15:41:45 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: script.c

Log Message:
Don't block signals when running hooks. Here ctx->sigset == defsigs ==
0x60006003, which blocks SIGTERM by default, so running something simple
from a hook, like /etc/rc.d/racoon restart does not work. The script
is then stuck waiting for the daemon to die, which it won't since it will
never receive the signal, and the hook never terminates.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcpcd/dist/src/script.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/src/script.c
diff -u src/external/bsd/dhcpcd/dist/src/script.c:1.3 src/external/bsd/dhcpcd/dist/src/script.c:1.4
--- src/external/bsd/dhcpcd/dist/src/script.c:1.3	Thu Apr  2 08:41:48 2020
+++ src/external/bsd/dhcpcd/dist/src/script.c	Sun Apr  5 11:41:45 2020
@@ -108,7 +108,8 @@ script_exec(const struct dhcpcd_ctx *ctx
 	for (i = 0; i < dhcpcd_signals_len; i++)
 		sigaddset(, dhcpcd_signals[i]);
 	posix_spawnattr_setsigdefault(, );
-	posix_spawnattr_setsigmask(, >sigset);
+	sigemptyset();
+	posix_spawnattr_setsigmask(, );
 #endif
 	errno = 0;
 	r = posix_spawn(, argv[0], NULL, , argv, env);



CVS commit: src/external/bsd/dhcpcd/libexec/dhcpcd-hooks

2020-04-03 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr  3 15:02:11 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/libexec/dhcpcd-hooks: Makefile

Log Message:
Try a better syntax for building 30-hostname


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile

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/libexec/dhcpcd-hooks/Makefile
diff -u src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile:1.4 src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile:1.5
--- src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile:1.4	Thu Apr  2 14:05:28 2020
+++ src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile	Fri Apr  3 15:02:11 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2020/04/02 14:05:28 roy Exp $
+# $NetBSD: Makefile,v 1.5 2020/04/03 15:02:11 roy Exp $
 #
 
 .include 
@@ -10,15 +10,14 @@ HOOKSRC=	${DIST}/hooks
 FILES=		01-test 02-dump 20-resolv.conf 30-hostname
 FILES+=		50-ntp.conf
 
-FILESBUILD_30-hostname=   YES
-
 FILESDIR=	/libexec/dhcpcd-hooks
 
+FILESBUILD_30-hostname=   YES
 CLEANFILES=	30-hostname
 
-.for f in ${FILES}
-${f}:	../../Makefile.inc ${f}.in
-	${TOOL_SED} ${SED_SYS} ${HOOKSRC}/${f}.in > $@
-.endfor
+.SUFFIXES:	.in
+
+.in:	../../Makefile.inc
+	${TOOL_SED} ${SED_SYS} $< > $@
 
 .include 



CVS commit: src/external/bsd/dhcpcd/libexec/dhcpcd-hooks

2020-04-02 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Apr  2 14:05:28 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/libexec/dhcpcd-hooks: Makefile

Log Message:
Fix the build by building 30-hostname


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile

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/libexec/dhcpcd-hooks/Makefile
diff -u src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile:1.3 src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile:1.4
--- src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile:1.3	Sun Apr  2 20:18:38 2017
+++ src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile	Thu Apr  2 14:05:28 2020
@@ -1,15 +1,24 @@
-# $NetBSD: Makefile,v 1.3 2017/04/02 20:18:38 roy Exp $
+# $NetBSD: Makefile,v 1.4 2020/04/02 14:05:28 roy Exp $
 #
 
 .include 
 
 .include "../../Makefile.inc"
+HOOKSRC=	${DIST}/hooks
+.PATH:		${HOOKSRC}
 
-.PATH:			${DIST}/hooks
+FILES=		01-test 02-dump 20-resolv.conf 30-hostname
+FILES+=		50-ntp.conf
 
-FILES=			01-test 02-dump 20-resolv.conf 30-hostname
-FILES+=			50-ntp.conf
+FILESBUILD_30-hostname=   YES
 
-FILESDIR=		/libexec/dhcpcd-hooks
+FILESDIR=	/libexec/dhcpcd-hooks
+
+CLEANFILES=	30-hostname
+
+.for f in ${FILES}
+${f}:	../../Makefile.inc ${f}.in
+	${TOOL_SED} ${SED_SYS} ${HOOKSRC}/${f}.in > $@
+.endfor
 
 .include 



CVS commit: src/external/bsd/dhcpcd

2020-04-02 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Apr  2 12:56:01 UTC 2020

Modified Files:
src/external/bsd/dhcpcd: Makefile.inc
src/external/bsd/dhcpcd/include: config.h
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
Build dhcpcd with privsep support.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcpcd/Makefile.inc
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/include/config.h
cvs rdiff -u -r1.50 -r1.51 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/Makefile.inc
diff -u src/external/bsd/dhcpcd/Makefile.inc:1.3 src/external/bsd/dhcpcd/Makefile.inc:1.4
--- src/external/bsd/dhcpcd/Makefile.inc:1.3	Thu Jul  5 05:41:17 2018
+++ src/external/bsd/dhcpcd/Makefile.inc	Thu Apr  2 12:56:01 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.3 2018/07/05 05:41:17 triaxx Exp $
+# $NetBSD: Makefile.inc,v 1.4 2020/04/02 12:56:01 roy Exp $
 
 SRCDIR=		${NETBSDSRCDIR}/external/bsd/dhcpcd
 DIST=		${SRCDIR}/dist
@@ -7,10 +7,11 @@ SED_SYS=	-e 's:@SYSCONFDIR@:/etc:g' \
 		-e 's:@DATADIR@:/usr/share/examples:g' \
 		-e 's:@DBDIR@:/var/db/dhcpcd:g' \
 		-e 's:@LIBDIR@:/lib:g' \
-		-e 's:@RUNDIR@:/var/run:g' \
+		-e 's:@RUNDIR@:/var/run/dhcpcd:g' \
 		-e 's:@HOOKDIR@:/libexec/dhcpcd-hooks:g' \
 		-e 's:@SCRIPT@:/libexec/dhcpcd-run-hooks:g' \
 		-e 's:@SERVICEEXISTS@::g' \
 		-e 's:@SERVICECMD@::g' \
 		-e 's:@SERVICESTATUS@::g' \
-		-e 's:@STATUSARG@::g'
+		-e 's:@STATUSARG@::g' \
+		-e 's:@DEFAULT_HOSTNAME@::g'

Index: src/external/bsd/dhcpcd/include/config.h
diff -u src/external/bsd/dhcpcd/include/config.h:1.4 src/external/bsd/dhcpcd/include/config.h:1.5
--- src/external/bsd/dhcpcd/include/config.h:1.4	Wed Jul 24 09:59:28 2019
+++ src/external/bsd/dhcpcd/include/config.h	Thu Apr  2 12:56:01 2020
@@ -1,16 +1,20 @@
 /* netbsd */
+#ifndef	SYSCONFDIR
 #define	SYSCONFDIR		"/etc"
 #define	SBINDIR			"/sbin"
 #define	LIBDIR			"/lib"
 #define	LIBEXECDIR		"/libexec"
 #define	DBDIR			"/var/db/dhcpcd"
-#define	RUNDIR			"/var/run"
+#define	RUNDIR			"/var/run/dhcpcd"
+#endif
+#ifndef PRIVSEP_USER
+#define PRIVSEP_USER		 "_dhcpcd"
+#endif
 #define	HAVE_IFAM_PID
 #define	HAVE_IFAM_ADDRFLAGS
 #define	HAVE_IFADDRS_ADDRFLAGS
 #define	HAVE_OPEN_MEMSTREAM
 #define	HAVE_UTIL_H
-#define	HAVE_SETPROCTITLE
 #define	HAVE_SYS_QUEUE_H
 #define	HAVE_SYS_RBTREE_H
 #define	HAVE_REALLOCARRAY

Index: src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.50 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.51
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.50	Wed Jan 29 23:42:57 2020
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Thu Apr  2 12:56:01 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.50 2020/01/29 23:42:57 christos Exp $
+# $NetBSD: Makefile,v 1.51 2020/04/02 12:56:01 roy Exp $
 #
 
 WARNS?=		6
@@ -13,6 +13,10 @@ SRCS+=		if.c if-options.c route.c sa.c s
 SRCS+=		dhcp-common.c dhcpcd-embedded.c
 SRCS+=		if-bsd.c
 
+CPPFLAGS+=	-DPRIVSEP -DPRIVSEP_USER=\"_dhcpcd\"
+SRCS+=		privsep.c privsep-root.c privsep-inet.c
+SRCS+=		privsep-bsd.c
+
 CPPFLAGS+=	-DHAVE_CONFIG_H -D_OPENBSD_SOURCE
 
 USE_INET?=	yes
@@ -27,6 +31,7 @@ SRCS+=		auth.c
 .if (${USE_INET} != "no")
 CPPFLAGS+=	-DINET
 SRCS+=		bpf.c dhcp.c ipv4.c
+SRCS+=		privsep-bpf.c
 .if !defined(SMALLPROG)
 CPPFLAGS+=	-DARP
 SRCS+=		arp.c



CVS commit: src/external/bsd/dhcpcd/dist/src

2020-02-08 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Sat Feb  8 12:17:16 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c

Log Message:
external/bsd/dhcpcd: Fix a -Wconversion warning.

Type cast uint16_t to size_t to prevent implicit type conversion.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.
gcc version 8.3.0

Reviewed by: roy@, kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/external/bsd/dhcpcd/dist/src/dhcp.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.32 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.33
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.32	Mon Jan 27 20:42:56 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Sat Feb  8 12:17:16 2020
@@ -3307,7 +3307,7 @@ is_packet_udp_bootp(void *packet, size_t
 	memcpy(, (char *)ip + ip_hlen, sizeof(udp));
 	if (ntohs(udp.uh_ulen) < sizeof(udp))
 		return false;
-	if (ip_hlen + ntohs(udp.uh_ulen) > plen)
+	if (ip_hlen + (size_t)ntohs(udp.uh_ulen) > plen)
 		return false;
 
 	/* Check it's to and from the right ports. */



CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2020-01-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 29 23:42:58 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
Hack for clang/powerpc


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.49 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.50
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.49	Fri Sep 13 07:58:32 2019
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Wed Jan 29 18:42:57 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.49 2019/09/13 11:58:32 roy Exp $
+# $NetBSD: Makefile,v 1.50 2020/01/29 23:42:57 christos Exp $
 #
 
 WARNS?=		6
@@ -59,6 +59,9 @@ FILESMODE_dhcpcd.conf=		644	# -rw-r--r--
 MAN=			dhcpcd.conf.5 dhcpcd.8 
 CLEANFILES=		dhcpcd.conf.5 dhcpcd.8 
 
+COPTS.logerr.c+=${${ACTIVE_CC} == "clang" && ${MACHINE_ARCH} == "powerpc":? -O0 :}
+
+
 .for f in dhcpcd.conf.5 dhcpcd.8
 ${f}:	${f}.in
 	${TOOL_SED} ${SED_SYS} ${DIST}/src/${f}.in > $@



CVS commit: src/external/bsd/dhcpcd/dist/src

2020-01-27 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Jan 27 20:42:57 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c if-bsd.c ipv6.c ipv6.h
ipv6nd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/src/if-bsd.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/ipv6.c \
src/external/bsd/dhcpcd/dist/src/ipv6.h

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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.31 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.32
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.31	Fri Dec 20 12:01:35 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Mon Jan 27 20:42:56 2020
@@ -2335,9 +2335,10 @@ dhcp_message_new(struct bootp **bootp,
 static void
 dhcp_arp_defend_failed(struct arp_state *astate)
 {
+	struct interface *ifp = astate->iface;
 
-	dhcp_drop(astate->iface, "EXPIRED");
-	dhcp_start1(astate->iface);
+	dhcp_drop(ifp, "EXPIRED");
+	dhcp_start1(ifp);
 }
 #endif
 

Index: src/external/bsd/dhcpcd/dist/src/if-bsd.c
diff -u src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.15 src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.16
--- src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.15	Wed Nov 13 10:50:22 2019
+++ src/external/bsd/dhcpcd/dist/src/if-bsd.c	Mon Jan 27 20:42:56 2020
@@ -860,8 +860,6 @@ if_address(unsigned char cmd, const stru
 	return r;
 }
 
-
-
 #if !(defined(HAVE_IFADDRS_ADDRFLAGS) && defined(HAVE_IFAM_ADDRFLAGS))
 int
 if_addrflags(const struct interface *ifp, const struct in_addr *addr,
@@ -1194,7 +1192,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const str
 {
 	struct interface *ifp;
 	const struct sockaddr *rti_info[RTAX_MAX];
-	int addrflags;
+	int flags;
 	pid_t pid;
 
 	if (ifam->ifam_msglen < sizeof(*ifam)) {
@@ -1216,9 +1214,6 @@ if_ifa(struct dhcpcd_ctx *ctx, const str
 	pid = 0;
 #endif
 
-#ifdef HAVE_IFAM_ADDRFLAGS
-	addrflags = ifam->ifam_addrflags;
-#endif
 	switch (rti_info[RTAX_IFA]->sa_family) {
 	case AF_LINK:
 	{
@@ -1252,78 +1247,70 @@ if_ifa(struct dhcpcd_ctx *ctx, const str
 		bcast.s_addr = sin != NULL && sin->sin_family == AF_INET ?
 		sin->sin_addr.s_addr : INADDR_ANY;
 
-#if defined(__NetBSD_Version__) && __NetBSD_Version__ < 8
 		/*
 		 * NetBSD-7 and older send an invalid broadcast address.
 		 * So we need to query the actual address to get
 		 * the right one.
+		 * We can also use this to test if the address
+		 * has really been added or deleted.
 		 */
-		{
-#else
-		/*
-		 * If the address was deleted, lets check if it's
-		 * a late message and it still exists (maybe modified).
-		 * If so, ignore it as deleting an address causes
-		 * dhcpcd to drop any lease to which it belongs.
-		 */
-		if (ifam->ifam_type == RTM_DELADDR) {
-#endif
 #ifdef SIOCGIFALIAS
-			struct in_aliasreq ifra;
+		struct in_aliasreq ifra;
 
-			memset(, 0, sizeof(ifra));
-			strlcpy(ifra.ifra_name, ifp->name,
-			sizeof(ifra.ifra_name));
-			ifra.ifra_addr.sin_family = AF_INET;
-			ifra.ifra_addr.sin_len = sizeof(ifra.ifra_addr);
-			ifra.ifra_addr.sin_addr = addr;
-			if (ioctl(ctx->pf_inet_fd, SIOCGIFALIAS, ) == -1) {
-if (errno != ENXIO && errno != EADDRNOTAVAIL)
-	logerr("%s: SIOCGIFALIAS", __func__);
-if (ifam->ifam_type != RTM_DELADDR)
-	break;
-			}
+		memset(, 0, sizeof(ifra));
+		strlcpy(ifra.ifra_name, ifp->name, sizeof(ifra.ifra_name));
+		ifra.ifra_addr.sin_family = AF_INET;
+		ifra.ifra_addr.sin_len = sizeof(ifra.ifra_addr);
+		ifra.ifra_addr.sin_addr = addr;
+		if (ioctl(ctx->pf_inet_fd, SIOCGIFALIAS, ) == -1) {
+			if (errno != ENXIO && errno != EADDRNOTAVAIL)
+logerr("%s: SIOCGIFALIAS", __func__);
+			if (ifam->ifam_type != RTM_DELADDR)
+break;
+		} else {
+			if (ifam->ifam_type == RTM_DELADDR)
+break;
 #if defined(__NetBSD_Version__) && __NetBSD_Version__ < 8
-			else
-bcast = ifra.ifra_broadaddr.sin_addr;
+			bcast = ifra.ifra_broadaddr.sin_addr;
 #endif
+		}
 #else
 #warning No SIOCGIFALIAS support
-			/*
-			 * No SIOCGIFALIAS? That sucks!
-			 * This makes this call very heavy weight, but we
-			 * really need to know if the message is late or not.
-			 */
-			const struct sockaddr *sa;
-			struct ifaddrs *ifaddrs = NULL, *ifa;
-
-			sa = rti_info[RTAX_IFA];
-			getifaddrs();
-			for (ifa = ifaddrs; ifa; ifa = ifa->ifa_next) {
-if (ifa->ifa_addr == NULL)
-	continue;
-if (sa_cmp(ifa->ifa_addr, sa) == 0 &&
-strcmp(ifa->ifa_name, ifp->name) == 0)
-	break;
-			}
-			freeifaddrs(ifaddrs);
+		/*
+		 * No SIOCGIFALIAS? That sucks!
+		 * This makes this call very heavy weight, but we
+		 * really need to know if the message is late or not.
+		 */
+		const struct sockaddr *sa;
+		struct ifaddrs *ifaddrs = NULL, *ifa;
+
+		sa = 

CVS commit: src/external/bsd/dhcpcd/dist/src

2020-01-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 26 22:57:52 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: script.c

Log Message:
prevent coredump when state == NULL


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.12 -r1.2 src/external/bsd/dhcpcd/dist/src/script.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/src/script.c
diff -u src/external/bsd/dhcpcd/dist/src/script.c:1.1.1.12 src/external/bsd/dhcpcd/dist/src/script.c:1.2
--- src/external/bsd/dhcpcd/dist/src/script.c:1.1.1.12	Wed Nov 13 05:49:20 2019
+++ src/external/bsd/dhcpcd/dist/src/script.c	Sun Jan 26 17:57:52 2020
@@ -453,7 +453,7 @@ make_env(const struct interface *ifp, co
 dumplease:
 #ifdef INET
 #ifdef IPV4LL
-	if (protocol == PROTO_IPV4LL) {
+	if (protocol == PROTO_IPV4LL && istate) {
 		if (ipv4ll_env(fp, istate->down ? "old" : "new", ifp) == -1)
 			goto eexit;
 	}



CVS commit: src/external/bsd/dhcpcd/dist/src

2020-01-03 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Jan  3 12:39:19 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcpcd.c if-options.c ipv6nd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.19 -r1.20 src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/dhcpcd/dist/src/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/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.30 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.31
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.30	Fri Dec 20 12:01:35 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Fri Jan  3 12:39:18 2020
@@ -467,25 +467,11 @@ configure_interface1(struct interface *i
 		if (!(ifo->options & (DHCPCD_INFORM | DHCPCD_WANTDHCP)))
 			ifo->options |= DHCPCD_STATIC;
 	}
-	if (!(ifo->options & DHCPCD_ARP) ||
-	ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC))
-		ifo->options &= ~DHCPCD_IPV4LL;
 
 	if (ifo->metric != -1)
 		ifp->metric = (unsigned int)ifo->metric;
 
-	if (!(ifo->options & DHCPCD_IPV4))
-		ifo->options &= ~(DHCPCD_DHCP | DHCPCD_IPV4LL | DHCPCD_WAITIP4);
-
 #ifdef INET6
-	if (!(ifo->options & DHCPCD_IPV6))
-		ifo->options &=
-		~(DHCPCD_IPV6RS | DHCPCD_DHCP6 | DHCPCD_WAITIP6);
-
-	if (!(ifo->options & DHCPCD_IPV6RS))
-		ifo->options &=
-		~(DHCPCD_IPV6RA_AUTOCONF | DHCPCD_IPV6RA_REQRDNSS);
-
 	/* We want to setup INET6 on the interface as soon as possible. */
 	if (ifp->active == IF_ACTIVE_USER &&
 	ifo->options & DHCPCD_IPV6 &&

Index: src/external/bsd/dhcpcd/dist/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.19 src/external/bsd/dhcpcd/dist/src/if-options.c:1.20
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.19	Fri Dec 20 22:24:59 2019
+++ src/external/bsd/dhcpcd/dist/src/if-options.c	Fri Jan  3 12:39:18 2020
@@ -2231,6 +2231,21 @@ finish_config(struct if_options *ifo)
 		 * guard should suffice */
 		ifo->options |= DHCPCD_VENDORRAW;
 	}
+
+	if (!(ifo->options & DHCPCD_ARP) ||
+	ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC))
+		ifo->options &= ~DHCPCD_IPV4LL;
+
+	if (!(ifo->options & DHCPCD_IPV4))
+		ifo->options &= ~(DHCPCD_DHCP | DHCPCD_IPV4LL | DHCPCD_WAITIP4);
+
+	if (!(ifo->options & DHCPCD_IPV6))
+		ifo->options &=
+		~(DHCPCD_IPV6RS | DHCPCD_DHCP6 | DHCPCD_WAITIP6);
+
+	if (!(ifo->options & DHCPCD_IPV6RS))
+		ifo->options &=
+		~(DHCPCD_IPV6RA_AUTOCONF | DHCPCD_IPV6RA_REQRDNSS);
 }
 
 /* Handy routine to read very long lines in text files.

Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.14 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.15
--- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.14	Fri Dec 20 12:01:36 2019
+++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c	Fri Jan  3 12:39:18 2020
@@ -622,7 +622,7 @@ ipv6nd_applyra(struct dhcpcd_ctx *ctx, s
 		return;
 
 	state->retrans = rap->retrans;
-	if (if_applyra(rap) == -1)
+	if (if_applyra(rap) == -1 && errno != ENOENT)
 		logerr(__func__);
 }
 



CVS commit: src/external/bsd/dhcpcd/dist/src

2019-12-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Dec 20 22:24:59 UTC 2019

Modified Files:
src/external/bsd/dhcpcd/dist/src: if-options.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/external/bsd/dhcpcd/dist/src/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/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.18 src/external/bsd/dhcpcd/dist/src/if-options.c:1.19
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.18	Fri Oct 11 11:03:59 2019
+++ src/external/bsd/dhcpcd/dist/src/if-options.c	Fri Dec 20 22:24:59 2019
@@ -393,8 +393,16 @@ parse_str(char *sbuf, size_t slen, const
 			str++;
 		}
 	}
-	if (flags == PARSE_STRING_NULL && sbuf)
-		*sbuf = '\0';
+	if (flags == PARSE_STRING_NULL) {
+		l++;
+		if (sbuf != NULL) {
+			if (l > slen) {
+errno = ENOBUFS;
+return -1;
+			}
+			*sbuf = '\0';
+		}
+	}
 	return (ssize_t)l;
 }
 



CVS commit: src/external/bsd/dhcpcd/dist

2019-12-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Dec 20 12:01:36 UTC 2019

Modified Files:
src/external/bsd/dhcpcd/dist/hooks: dhcpcd-run-hooks.in
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.c ipv6.c ipv6.h
ipv6nd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in
cvs rdiff -u -r1.30 -r1.31 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/dhcpcd/dist/src/dhcp6.c
cvs rdiff -u -r1.29 -r1.30 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/ipv6.c \
src/external/bsd/dhcpcd/dist/src/ipv6.h
cvs rdiff -u -r1.13 -r1.14 src/external/bsd/dhcpcd/dist/src/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/hooks/dhcpcd-run-hooks.in
diff -u src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.3 src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.4
--- src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.3	Thu Feb  7 21:37:36 2019
+++ src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in	Fri Dec 20 12:01:35 2019
@@ -212,7 +212,7 @@ valid_domainname_list()
 
 # With the advent of alternative init systems, it's possible to have
 # more than one installed. So we need to try and guess what one we're
-# using unless overriden by configure.
+# using unless overridden by configure.
 detect_init()
 {
 	_service_exists="@SERVICEEXISTS@"

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.30 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.31
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.30	Wed Nov 13 10:50:22 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Fri Dec 20 12:01:35 2019
@@ -176,6 +176,11 @@ get_option(struct dhcpcd_ctx *ctx,
 	const uint8_t *op;
 	size_t bl;
 
+	if (bootp == NULL || bootp_len < DHCP_MIN_LEN) {
+		errno = EINVAL;
+		return NULL;
+	}
+
 	/* Check we have the magic cookie */
 	if (!IS_DHCP(bootp)) {
 		errno = ENOTSUP;
@@ -484,7 +489,7 @@ print_rfc3361(FILE *fp, const uint8_t *d
 			return -1;
 		break;
 	case 1:
-		if (dl == 0 || dl % 4 != 0) {
+		if (dl % 4 != 0) {
 			errno = EINVAL;
 			break;
 		}
@@ -1179,7 +1184,7 @@ read_lease(struct interface *ifp, struct
 	 * (it should be more, and our read packet enforces this so this
 	 * code should not be needed, but of course people could
 	 * scribble whatever in the stored lease file. */
-	if (bytes < offsetof(struct bootp, vend) + 4) {
+	if (bytes < DHCP_MIN_LEN) {
 		free(lease);
 		logerrx("%s: %s: truncated lease", ifp->name, __func__);
 		return 0;
@@ -1540,7 +1545,7 @@ dhcp_close(struct interface *ifp)
 }
 
 static int
-dhcp_openudp(struct interface *ifp)
+dhcp_openudp(struct in_addr *ia)
 {
 	int s;
 	struct sockaddr_in sin;
@@ -1551,29 +1556,25 @@ dhcp_openudp(struct interface *ifp)
 
 	n = 1;
 	if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, , sizeof(n)) == -1)
-		goto eexit;
+		goto errexit;
 #ifdef IP_RECVIF
 	if (setsockopt(s, IPPROTO_IP, IP_RECVIF, , sizeof(n)) == -1)
-		goto eexit;
+		goto errexit;
 #else
 	if (setsockopt(s, IPPROTO_IP, IP_RECVPKTINFO, , sizeof(n)) == -1)
-		goto eexit;
+		goto errexit;
 #endif
 	memset(, 0, sizeof(sin));
 	sin.sin_family = AF_INET;
 	sin.sin_port = htons(BOOTPC);
-	if (ifp) {
-		const struct dhcp_state *state = D_CSTATE(ifp);
-
-		if (state->addr)
-			sin.sin_addr.s_addr = state->addr->addr.s_addr;
-	}
+	if (ia != NULL)
+		sin.sin_addr = *ia;
 	if (bind(s, (struct sockaddr *), sizeof(sin)) == -1)
-		goto eexit;
+		goto errexit;
 
 	return s;
 
-eexit:
+errexit:
 	close(s);
 	return -1;
 }
@@ -1675,7 +1676,7 @@ dhcp_sendudp(struct interface *ifp, stru
 
 	fd = state->udp_fd;
 	if (fd == -1) {
-		fd = dhcp_openudp(ifp);
+		fd = dhcp_openudp(state->addr != NULL ?>addr->addr:NULL);
 		if (fd == -1)
 			return -1;
 	}
@@ -1734,7 +1735,9 @@ send_message(struct interface *ifp, uint
 		goto fail;
 	len = (size_t)r;
 
-	if (ipv4_iffindaddr(ifp, >lease.addr, NULL) != NULL)
+	if (!(state->added & STATE_FAKE) &&
+	state->addr != NULL &&
+	ipv4_iffindaddr(ifp, >lease.addr, NULL) != NULL)
 		from.s_addr = state->lease.addr.s_addr;
 	else
 		from.s_addr = INADDR_ANY;
@@ -1751,7 +1754,7 @@ send_message(struct interface *ifp, uint
 	 * even if they are setup to send them.
 	 * Broadcasting from UDP is only an optimisation for rebinding
 	 * and on BSD, at least, is reliant on the subnet route being
-	 * correctly configured to recieve the unicast reply.
+	 * correctly configured to receive the unicast reply.
 	 * As such, we always broadcast and receive the reply to it via BPF.
 	 * This also guarantees we have a DHCP server attached to the
 	 * interface we want to configure because we can't dictate the
@@ -2266,10 +2269,11 @@ dhcp_bind(struct interface *ifp)
 		return;
 	dhcp_close(ifp);
 
+
 	/* If not in 

CVS commit: src/external/bsd/dhcpcd/dist/src

2019-05-04 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat May  4 09:42:16 UTC 2019

Modified Files:
src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcp6.c dhcpcd.c
if-bsd.c if-options.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/bpf.c
cvs rdiff -u -r1.18 -r1.19 src/external/bsd/dhcpcd/dist/src/dhcp.c \
src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/dhcp6.c \
src/external/bsd/dhcpcd/dist/src/if-bsd.c
cvs rdiff -u -r1.13 -r1.14 src/external/bsd/dhcpcd/dist/src/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/src/bpf.c
diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.8 src/external/bsd/dhcpcd/dist/src/bpf.c:1.9
--- src/external/bsd/dhcpcd/dist/src/bpf.c:1.8	Tue Jan 22 15:20:21 2019
+++ src/external/bsd/dhcpcd/dist/src/bpf.c	Sat May  4 09:42:15 2019
@@ -301,6 +301,7 @@ bpf_close(struct interface *ifp, int fd)
 /* Normally this is needed by bootp.
  * Once that uses this again, the ARP guard here can be removed. */
 #ifdef ARP
+#define BPF_CMP_HWADDR_LEN	HWADDR_LEN / 4) + 2) * 2) + 1)
 static unsigned int
 bpf_cmp_hwaddr(struct bpf_insn *bpf, size_t bpf_len, size_t off,
 bool equal, uint8_t *hwaddr, size_t hwaddr_len)
@@ -414,7 +415,7 @@ static const struct bpf_insn bpf_arp_eth
 	 sizeof(((struct ether_arp *)0)->arp_sha), 1, 0),
 	BPF_STMT(BPF_RET + BPF_K, 0),
 };
-#define bpf_arp_ether_len	__arraycount(bpf_arp_ether)
+#define BPF_ARP_ETHER_LEN	__arraycount(bpf_arp_ether)
 
 static const struct bpf_insn bpf_arp_filter [] = {
 	/* Make sure this is for IP. */
@@ -425,21 +426,25 @@ static const struct bpf_insn bpf_arp_fil
 	BPF_STMT(BPF_LD + BPF_H + BPF_IND, offsetof(struct arphdr, ar_op)),
 	BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ARPOP_REQUEST, 2, 0),
 	/* or ARP REPLY. */
-	BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ARPOP_REPLY, 1, 1),
+	BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ARPOP_REPLY, 1, 0),
 	BPF_STMT(BPF_RET + BPF_K, 0),
 	/* Make sure the protocol length matches. */
 	BPF_STMT(BPF_LD + BPF_B + BPF_IND, offsetof(struct arphdr, ar_pln)),
 	BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, sizeof(in_addr_t), 1, 0),
 	BPF_STMT(BPF_RET + BPF_K, 0),
 };
-#define bpf_arp_filter_len	__arraycount(bpf_arp_filter)
-#define bpf_arp_extra		ARP_ADDRS_MAX + 1) * 2) * 2) + 2)
-#define bpf_arp_hw		HWADDR_LEN / 4) + 2) * 2) + 1)
+#define BPF_ARP_FILTER_LEN	__arraycount(bpf_arp_filter)
+
+#define BPF_ARP_ADDRS_LEN	1 + (ARP_ADDRS_MAX * 2) + 3 + \
+(ARP_ADDRS_MAX * 2) + 1
+
+#define BPF_ARP_LEN		BPF_ARP_ETHER_LEN + BPF_ARP_FILTER_LEN + \
+BPF_CMP_HWADDR_LEN + BPF_ARP_ADDRS_LEN
 
 int
 bpf_arp(struct interface *ifp, int fd)
 {
-	struct bpf_insn bpf[3+ bpf_arp_filter_len + bpf_arp_hw + bpf_arp_extra];
+	struct bpf_insn bpf[BPF_ARP_LEN];
 	struct bpf_insn *bp;
 	struct iarp_state *state;
 	uint16_t arp_len;
@@ -452,7 +457,7 @@ bpf_arp(struct interface *ifp, int fd)
 	switch(ifp->family) {
 	case ARPHRD_ETHER:
 		memcpy(bp, bpf_arp_ether, sizeof(bpf_arp_ether));
-		bp += bpf_arp_ether_len;
+		bp += BPF_ARP_ETHER_LEN;
 		arp_len = sizeof(struct ether_header)+sizeof(struct ether_arp);
 		break;
 	default:
@@ -462,10 +467,10 @@ bpf_arp(struct interface *ifp, int fd)
 
 	/* Copy in the main filter. */
 	memcpy(bp, bpf_arp_filter, sizeof(bpf_arp_filter));
-	bp += bpf_arp_filter_len;
+	bp += BPF_ARP_FILTER_LEN;
 
 	/* Ensure it's not from us. */
-	bp += bpf_cmp_hwaddr(bp, bpf_arp_hw, sizeof(struct arphdr),
+	bp += bpf_cmp_hwaddr(bp, BPF_CMP_HWADDR_LEN, sizeof(struct arphdr),
 	 false, ifp->hwaddr, ifp->hwlen);
 
 	state = ARP_STATE(ifp);

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.18 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.19
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.18	Fri Apr 26 14:34:10 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Sat May  4 09:42:15 2019
@@ -3499,9 +3499,14 @@ dhcp_readudp(struct dhcpcd_ctx *ctx, str
 			logerr(__func__);
 			return;
 		}
+		if (D_CSTATE(ifp) == NULL) {
+			logdebugx("%s: received BOOTP for inactive interface",
+			ifp->name);
+			return;
+		}
 	}
 
-	dhcp_handlebootp(ifp, (struct bootp *)buf, (size_t)bytes,
+	dhcp_handlebootp(ifp, (struct bootp *)(void *)buf, (size_t)bytes,
 	_addr);
 #endif
 }
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.18 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.19
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.18	Wed Apr 17 23:35:34 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Sat May  4 09:42:15 2019
@@ -84,6 +84,9 @@ const int dhcpcd_signals[] = {
 const size_t dhcpcd_signals_len = __arraycount(dhcpcd_signals);
 #endif
 
+#define IF_UPANDRUNNING(a) \
+	(((a)->flags & (IFF_UP | IFF_RUNNING)) == (IFF_UP | IFF_RUNNING))
+
 static void
 

CVS commit: src/external/bsd/dhcpcd/dist/src

2019-04-26 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 26 14:34:10 UTC 2019

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c if-bsd.c ipv6nd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcpcd/dist/src/dhcp6.c \
src/external/bsd/dhcpcd/dist/src/if-bsd.c \
src/external/bsd/dhcpcd/dist/src/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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.17 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.18
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.17	Wed Apr 17 23:35:34 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Fri Apr 26 14:34:10 2019
@@ -215,6 +215,12 @@ get_option(struct dhcpcd_ctx *ctx,
 		}
 		l = *p++;
 
+		/* Check we can read the option data, if present */
+		if (p + l > e) {
+			errno = EINVAL;
+			return NULL;
+		}
+
 		if (o == DHO_OPTSOVERLOADED) {
 			/* Ensure we only get this option once by setting
 			 * the last bit as well as the value.
@@ -249,10 +255,6 @@ get_option(struct dhcpcd_ctx *ctx,
 bp += ol;
 			}
 			ol = l;
-			if (p + ol >= e) {
-errno = EINVAL;
-return NULL;
-			}
 			op = p;
 			bl += ol;
 		}
@@ -2075,7 +2077,7 @@ dhcp_arp_probed(struct arp_state *astate
 	ifp->name, inet_ntoa(astate->addr));
 	if (!(ifo->options & DHCPCD_INFORM))
 		dhcp_bind(ifp);
-#ifndef IN_IFF_TENTATIVE
+#ifndef IN_IFF_DUPLICATED
 	else {
 		struct bootp *bootp;
 		size_t len;
@@ -2429,7 +2431,7 @@ dhcp_arp_address(struct interface *ifp)
 	if (astate == NULL)
 		return -1;
 
-#ifdef IN_IFF_TENTATIVE
+#ifdef IN_IFF_NOTUSEABLE
 	if (ia == NULL || ia->addr_flags & IN_IFF_NOTUSEABLE) {
 		state->state = DHS_PROBE;
 		if (ia == NULL) {

Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.5 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.6
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.5	Wed Apr 17 23:35:34 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c	Fri Apr 26 14:34:10 2019
@@ -2029,12 +2029,12 @@ dhcp6_findna(struct interface *ifp, uint
 		nd = o + ol;
 		l -= (size_t)(nd - d);
 		d = nd;
-		if (ol < 24) {
+		if (ol < sizeof(ia)) {
 			errno = EINVAL;
 			logerrx("%s: IA Address option truncated", ifp->name);
 			continue;
 		}
-		memcpy(, o, ol);
+		memcpy(, o, sizeof(ia));
 		ia.pltime = ntohl(ia.pltime);
 		ia.vltime = ntohl(ia.vltime);
 		/* RFC 3315 22.6 */
@@ -3035,7 +3035,7 @@ dhcp6_bind(struct interface *ifp, const 
  * unless those values in those fields are 0.
  */
 logwarnx("%s: ignoring T1 %"PRIu32
-" to due address expiry",
+" due to address expiry",
 ifp->name, state->renew);
 state->renew = state->rebind = 0;
 			}
Index: src/external/bsd/dhcpcd/dist/src/if-bsd.c
diff -u src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.5 src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.6
--- src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.5	Wed Apr 17 23:35:34 2019
+++ src/external/bsd/dhcpcd/dist/src/if-bsd.c	Fri Apr 26 14:34:10 2019
@@ -943,10 +943,15 @@ if_getlifetime6(struct ipv6_addr *ia)
 	priv = (struct priv *)ia->iface->ctx->priv;
 	if (ioctl(priv->pf_inet6_fd, SIOCGIFALIFETIME_IN6, ) == -1)
 		return -1;
+	clock_gettime(CLOCK_MONOTONIC, >created);
 
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+	t = ia->created.tv_sec;
+#else
 	t = time(NULL);
-	lifetime = _ifru.ifru_lifetime;
+#endif
 
+	lifetime = _ifru.ifru_lifetime;
 	if (lifetime->ia6t_preferred)
 		ia->prefix_pltime = (uint32_t)(lifetime->ia6t_preferred -
 		MIN(t, lifetime->ia6t_preferred));
@@ -956,7 +961,6 @@ if_getlifetime6(struct ipv6_addr *ia)
 		ia->prefix_vltime = (uint32_t)(lifetime->ia6t_expire -
 		MIN(t, lifetime->ia6t_expire));
 		/* Calculate the created time */
-		clock_gettime(CLOCK_MONOTONIC, >created);
 		ia->created.tv_sec -= lifetime->ia6t_vltime - ia->prefix_vltime;
 	} else
 		ia->prefix_vltime = ND6_INFINITE_LIFETIME;
Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.5 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.6
--- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.5	Wed Apr 17 23:35:35 2019
+++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c	Fri Apr 26 14:34:10 2019
@@ -190,54 +190,106 @@ ipv6nd_printoptions(const struct dhcpcd_
 }
 
 static int
-ipv6nd_open(struct dhcpcd_ctx *ctx)
+ipv6nd_open0(void)
 {
-	int on;
+	int s, on;
 	struct icmp6_filter filt;
 
-	if (ctx->nd_fd != -1)
-		return ctx->nd_fd;
 #define SOCK_FLAGS	SOCK_CLOEXEC | SOCK_NONBLOCK
-	ctx->nd_fd = xsocket(PF_INET6, SOCK_RAW | SOCK_FLAGS, IPPROTO_ICMPV6);
+	s = xsocket(PF_INET6, SOCK_RAW | SOCK_FLAGS, IPPROTO_ICMPV6);
 #undef SOCK_FLAGS
-	if (ctx->nd_fd == -1)
+	if (s == -1)
 		return -1;
 
 	/* RFC4861 4.1 */
 	on = 255;
-	if (setsockopt(ctx->nd_fd, IPPROTO_IPV6, 

CVS commit: src/external/bsd/dhcpcd/dist

2019-04-17 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Apr 17 23:36:30 UTC 2019

Removed Files:
src/external/bsd/dhcpcd/dist: .arcconfig

Log Message:
Remove non distributed file.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/dhcpcd/dist/.arcconfig

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/dhcpcd/dist/src

2019-04-17 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Apr 17 23:35:35 UTC 2019

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.c if-bsd.c
if-options.c ipv6nd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/src/dhcp6.c \
src/external/bsd/dhcpcd/dist/src/if-bsd.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.17 -r1.18 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/src/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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.16 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.17
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.16	Thu Feb  7 21:37:36 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Wed Apr 17 23:35:34 2019
@@ -86,9 +86,9 @@
 #define IPDEFTTL 64 /* RFC1340 */
 #endif
 
-/* NetBSD-7 has an incomplete IP_PKTINFO implementation. */
-#if defined(__NetBSD_Version__) && __NetBSD_Version__ < 8
-#undef IP_PKTINFO
+/* Support older systems with different defines */
+#if !defined(IP_RECVPKTINFO) && defined(IP_PKTINFO)
+#define IP_RECVPKTINFO IP_PKTINFO
 #endif
 
 /* Assert the correct structure size for on wire */
@@ -129,6 +129,9 @@ static void dhcp_arp_conflicted(struct a
 #endif
 static void dhcp_handledhcp(struct interface *, struct bootp *, size_t,
 const struct in_addr *);
+#ifdef IP_PKTINFO
+static void dhcp_handleifudp(void *);
+#endif
 static int dhcp_initstate(struct interface *);
 
 void
@@ -447,7 +450,7 @@ decode_rfc3442_rt(struct rt_head *routes
 		memcpy(_addr, p, 4);
 		p += 4;
 
-		/* A host route is normally set by having the
+		/* An on-link host route is normally set by having the
 		 * gateway match the destination or assigned address */
 		if (gateway.s_addr == dest.s_addr ||
 		(gateway.s_addr == bootp->yiaddr ||
@@ -455,17 +458,14 @@ decode_rfc3442_rt(struct rt_head *routes
 		{
 			gateway.s_addr = INADDR_ANY;
 			netmask.s_addr = INADDR_BROADCAST;
-			rt->rt_flags = RTF_HOST;
 		}
+		if (netmask.s_addr == INADDR_BROADCAST)
+			rt->rt_flags = RTF_HOST;
 
 		sa_in_init(>rt_dest, );
 		sa_in_init(>rt_netmask, );
 		sa_in_init(>rt_gateway, );
 
-		/* If CIDR is 32 then it's a host route. */
-		if (cidr == 32)
-			rt->rt_flags = RTF_HOST;
-
 		TAILQ_INSERT_TAIL(routes, rt, rt_next);
 		n++;
 	}
@@ -638,7 +638,7 @@ get_option_routes(struct rt_head *routes
 			if ((rt = rt_new(ifp)) == NULL)
 return -1;
 
-			/* A host route is normally set by having the
+			/* A on-link host route is normally set by having the
 			 * gateway match the destination or assigned address */
 			if (gateway.s_addr == dest.s_addr ||
 			 (gateway.s_addr == bootp->yiaddr ||
@@ -646,12 +646,15 @@ get_option_routes(struct rt_head *routes
 			{
 gateway.s_addr = INADDR_ANY;
 netmask.s_addr = INADDR_BROADCAST;
-rt->rt_flags = RTF_HOST;
 			} else
 netmask.s_addr = route_netmask(dest.s_addr);
+			if (netmask.s_addr == INADDR_BROADCAST)
+rt->rt_flags = RTF_HOST;
+
 			sa_in_init(>rt_dest, );
 			sa_in_init(>rt_netmask, );
 			sa_in_init(>rt_gateway, );
+
 			TAILQ_INSERT_TAIL(routes, rt, rt_next);
 			n++;
 		}
@@ -1587,6 +1590,11 @@ dhcp_close(struct interface *ifp)
 		state->bpf_fd = -1;
 		state->bpf_flags |= BPF_EOF;
 	}
+	if (state->udp_fd != -1) {
+		eloop_event_delete(ifp->ctx->eloop, state->udp_fd);
+		close(state->udp_fd);
+		state->udp_fd = -1;
+	}
 
 	state->interval = 0;
 }
@@ -1604,11 +1612,15 @@ dhcp_openudp(struct interface *ifp)
 	n = 1;
 	if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, , sizeof(n)) == -1)
 		goto eexit;
+#ifdef IP_RECVPKTINFO
+	if (setsockopt(s, IPPROTO_IP, IP_RECVPKTINFO, , sizeof(n)) == -1)
+		goto eexit;
+#endif
 	memset(, 0, sizeof(sin));
 	sin.sin_family = AF_INET;
 	sin.sin_port = htons(BOOTPC);
 	if (ifp) {
-		struct dhcp_state *state = D_STATE(ifp);
+		const struct dhcp_state *state = D_CSTATE(ifp);
 
 		if (state->addr)
 			sin.sin_addr.s_addr = state->addr->addr.s_addr;
@@ -1699,12 +1711,8 @@ dhcp_sendudp(struct interface *ifp, stru
 	struct msghdr msg;
 	struct sockaddr_in sin;
 	struct iovec iov[1];
+	struct dhcp_state *state = D_STATE(ifp);
 	ssize_t r;
-#ifdef IP_PKTINFO
-	uint8_t cmsg[CMSG_SPACE(sizeof(struct in_pktinfo))];
-	struct cmsghdr *cm;
-	struct in_pktinfo ipi;
-#endif
 
 	iov[0].iov_base = data;
 	iov[0].iov_len = len;
@@ -1723,29 +1731,15 @@ dhcp_sendudp(struct interface *ifp, stru
 	msg.msg_iov = iov;
 	msg.msg_iovlen = 1;
 
-#ifdef IP_PKTINFO
-	/* Set the outbound interface */
-	msg.msg_control = cmsg;
-	msg.msg_controllen = sizeof(cmsg);
-
-	memset(, 0, sizeof(ipi));
-	ipi.ipi_ifindex = ifp->index;
-	cm = CMSG_FIRSTHDR();
-	if (cm == NULL) {
-		errno = ESRCH;
-		return -1;
+	s = state->udp_fd;

CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2019-02-07 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Feb  7 21:38:53 UTC 2019

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
dhcpcd now builds without these warnings disabled.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.44 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.45
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.44	Mon Feb  4 04:05:15 2019
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Thu Feb  7 21:38:53 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.44 2019/02/04 04:05:15 mrg Exp $
+# $NetBSD: Makefile,v 1.45 2019/02/07 21:38:53 roy Exp $
 #
 
 WARNS?=		6
@@ -74,15 +74,4 @@ ${f}:	${f}.in
 	${TOOL_SED} ${SED_SYS} ${DIST}/src/${f}.in > $@
 .endfor
 
-.if defined(HAVE_GCC) && ${ACTIVE_CC} == "gcc"
-. if ${HAVE_GCC} >= 6
-COPTS.if-bsd.c+=	-Wno-error=sign-conversion
-. endif
-. if ${HAVE_GCC} >= 7
-COPTS.dhcp6.c+=		-Wno-error=implicit-fallthrough
-COPTS.if-options.c+=	-Wno-error=implicit-fallthrough
-COPTS.if.c+=		-Wno-error=implicit-fallthrough
-. endif
-.endif
-
 .include 



CVS commit: src/external/bsd/dhcpcd/dist

2019-02-07 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Feb  7 21:37:36 UTC 2019

Modified Files:
src/external/bsd/dhcpcd/dist/hooks: dhcpcd-run-hooks.in
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.c if-bsd.c
if-options.c ipv6nd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcpcd/dist/src/dhcp6.c \
src/external/bsd/dhcpcd/dist/src/if-bsd.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.16 -r1.17 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/src/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/hooks/dhcpcd-run-hooks.in
diff -u src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.2 src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.3
--- src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.2	Sat Sep 22 13:17:46 2018
+++ src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in	Thu Feb  7 21:37:36 2019
@@ -239,8 +239,9 @@ detect_init()
 		_service_exists="/usr/bin/systemctl --quiet is-enabled \$1.service"
 		_service_status="/usr/bin/systemctl --quiet is-active \$1.service"
 		_service_cmd="/usr/bin/systemctl \$2 \$1.service"
-	elif [ -x /sbin/rc-service ] && [ -s /libexec/rc/init.d/softlevel ] ||
-	 [ -s /run/openrc/softlevel ]
+	elif [ -x /sbin/rc-service ] &&
+	 { [ -s /libexec/rc/init.d/softlevel ] ||
+	 [ -s /run/openrc/softlevel ]; }
 	then
 		_service_exists="/sbin/rc-service -e \$1"
 		_service_cmd="/sbin/rc-service \$1 -- -D \$2"

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.15 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.16
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.15	Tue Jan 22 15:20:21 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Thu Feb  7 21:37:36 2019
@@ -1764,7 +1764,7 @@ send_message(struct interface *ifp, uint
 
 	if (!callback) {
 		/* No carrier? Don't bother sending the packet. */
-		if (ifp->carrier == LINK_DOWN)
+		if (ifp->carrier <= LINK_DOWN)
 			return;
 		logdebugx("%s: sending %s with xid 0x%x",
 		ifp->name,
@@ -1784,7 +1784,7 @@ send_message(struct interface *ifp, uint
 		timespecnorm();
 		/* No carrier? Don't bother sending the packet.
 		 * However, we do need to advance the timeout. */
-		if (ifp->carrier == LINK_DOWN)
+		if (ifp->carrier <= LINK_DOWN)
 			goto fail;
 		logdebugx("%s: sending %s (xid 0x%x), next in %0.1f seconds",
 		ifp->name,
@@ -1965,7 +1965,7 @@ dhcp_expire1(struct interface *ifp)
 	dhcp_drop(ifp, "EXPIRE");
 	unlink(state->leasefile);
 	state->interval = 0;
-	if (!(ifp->options->options & DHCPCD_LINK) || ifp->carrier != LINK_DOWN)
+	if (!(ifp->options->options & DHCPCD_LINK) || ifp->carrier > LINK_DOWN)
 		dhcp_discover(ifp);
 }
 
@@ -2601,7 +2601,7 @@ dhcp_reboot(struct interface *ifp)
 	state->state = DHS_REBOOT;
 	state->interval = 0;
 
-	if (ifo->options & DHCPCD_LINK && ifp->carrier == LINK_DOWN) {
+	if (ifo->options & DHCPCD_LINK && ifp->carrier <= LINK_DOWN) {
 		loginfox("%s: waiting for carrier", ifp->name);
 		return;
 	}
@@ -2691,7 +2691,7 @@ dhcp_drop(struct interface *ifp, const c
 		state->state = DHS_RELEASE;
 
 		unlink(state->leasefile);
-		if (ifp->carrier != LINK_DOWN &&
+		if (ifp->carrier > LINK_DOWN &&
 		state->new != NULL &&
 		state->lease.server.s_addr != INADDR_ANY)
 		{

Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.3 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.4
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.3	Tue Jan 22 15:20:21 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c	Thu Feb  7 21:37:36 2019
@@ -1169,7 +1169,7 @@ dhcp6_sendmessage(struct interface *ifp,
 	struct ipv6_addr *lla;
 	int s;
 
-	if (!callback && ifp->carrier == LINK_DOWN)
+	if (!callback && ifp->carrier <= LINK_DOWN)
 		return 0;
 
 	memset(, 0, sizeof(dst));
@@ -1262,7 +1262,7 @@ dhcp6_sendmessage(struct interface *ifp,
 		}
 
 logsend:
-		if (ifp->carrier != LINK_DOWN)
+		if (ifp->carrier > LINK_DOWN)
 			logdebugx("%s: %s %s (xid 0x%02x%02x%02x),"
 			" next in %0.1f seconds",
 			ifp->name,
@@ -1286,7 +1286,7 @@ logsend:
 		}
 	}
 
-	if (ifp->carrier == LINK_DOWN)
+	if (ifp->carrier <= LINK_DOWN)
 		return 0;
 
 	/* Update the elapsed time */
@@ -3416,6 +3416,8 @@ dhcp6_recvif(struct interface *ifp, stru
 			break;
 		}
 		return;
+#else
+		break;
 #endif
 	default:
 		logerrx("%s: invalid DHCP6 type %s (%d)",
Index: src/external/bsd/dhcpcd/dist/src/if-bsd.c
diff -u src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.3 src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.4
--- src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.3	Tue Jan 22 15:20:21 2019
+++ 

CVS commit: src/external/bsd/dhcpcd/dist/src

2019-01-22 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 22 21:38:08 UTC 2019

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcpcd.c

Log Message:
Fix SMALLPROG build.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/src/dhcpcd.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/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.15 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.16
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.15	Tue Jan 22 15:20:21 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Tue Jan 22 21:38:08 2019
@@ -765,7 +765,9 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *
 #ifdef NOCARRIER_PRESERVE_IP
 	dhcpcd_drop(ifp, 0);
 #endif
+#ifdef IPV4LL
 	ipv4ll_reset(ifp);
+#endif
 }
 			}
 			dhcpcd_initstate(ifp, 0);



CVS commit: src/external/bsd/dhcpcd/dist/src

2019-01-22 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 22 15:20:21 UTC 2019

Modified Files:
src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcp6.c dhcpcd.c
if-bsd.c if-options.c ipv6nd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/bpf.c
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/dhcpcd/dist/src/dhcp.c \
src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/dhcpcd/dist/src/dhcp6.c \
src/external/bsd/dhcpcd/dist/src/if-bsd.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/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/src/bpf.c
diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.7 src/external/bsd/dhcpcd/dist/src/bpf.c:1.8
--- src/external/bsd/dhcpcd/dist/src/bpf.c:1.7	Sat Jun  2 09:44:27 2018
+++ src/external/bsd/dhcpcd/dist/src/bpf.c	Tue Jan 22 15:20:21 2019
@@ -1,6 +1,6 @@
 /*
  * dhcpcd: BPF arp and bootp filtering
- * Copyright (c) 2006-2018 Roy Marples 
+ * Copyright (c) 2006-2019 Roy Marples 
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.14 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.15
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.14	Sun Nov  4 16:30:28 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Tue Jan 22 15:20:21 2019
@@ -1,6 +1,6 @@
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2018 Roy Marples 
+ * Copyright (c) 2006-2019 Roy Marples 
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -1604,11 +1604,6 @@ dhcp_openudp(struct interface *ifp)
 	n = 1;
 	if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, , sizeof(n)) == -1)
 		goto eexit;
-#ifdef SO_RERROR
-	n = 1;
-	if (setsockopt(s, SOL_SOCKET, SO_RERROR, , sizeof(n)) == -1)
-		goto eexit;
-#endif
 	memset(, 0, sizeof(sin));
 	sin.sin_family = AF_INET;
 	sin.sin_port = htons(BOOTPC);
@@ -2636,6 +2631,7 @@ dhcp_reboot(struct interface *ifp)
 	 * interface gets the reply. */
 	ia = ipv4_iffindaddr(ifp, >lease.addr, NULL);
 	if (ia != NULL &&
+	!(ifp->ctx->options & DHCPCD_TEST) &&
 #ifdef IN_IFF_NOTUSEABLE
 	!(ia->addr_flags & IN_IFF_NOTUSEABLE) &&
 #endif
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.14 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.15
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.14	Mon Aug 27 13:43:05 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Tue Jan 22 15:20:21 2019
@@ -1,6 +1,6 @@
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2018 Roy Marples 
+ * Copyright (c) 2006-2019 Roy Marples 
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 
-const char dhcpcd_copyright[] = "Copyright (c) 2006-2018 Roy Marples";
+const char dhcpcd_copyright[] = "Copyright (c) 2006-2019 Roy Marples";
 
 #include 
 #include 
@@ -314,13 +314,6 @@ dhcpcd_daemonise(struct dhcpcd_ctx *ctx)
 		return 0;
 	}
 
-	/* Store the pid and routing message seq number so we can identify
-	 * the last message successfully sent to the kernel.
-	 * This allows us to ignore all messages we sent after forking
-	 * and detaching. */
-	ctx->ppid = getpid();
-	ctx->pseq = ctx->sseq;
-
 	switch (pid = fork()) {
 	case -1:
 		logerr("%s: fork", __func__);
@@ -451,6 +444,10 @@ configure_interface1(struct interface *i
 		ifo->options &=
 		~(DHCPCD_IPV6RS | DHCPCD_DHCP6 | DHCPCD_WAITIP6);
 
+	if (!(ifo->options & DHCPCD_IPV6RS))
+		ifo->options &=
+		~(DHCPCD_IPV6RA_AUTOCONF | DHCPCD_IPV6RA_REQRDNSS);
+
 	/* We want to setup INET6 on the interface as soon as possible. */
 	if (ifp->active == IF_ACTIVE_USER &&
 	ifo->options & DHCPCD_IPV6 &&
@@ -738,6 +735,7 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *
 #endif
 			dhcp_abort(ifp);
 			ipv6nd_expire(ifp, 0);
+			dhcp6_abort(ifp);
 #else
 			dhcpcd_drop(ifp, 0);
 #endif
@@ -754,19 +752,21 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *
 #endif
 			if (ifp->wireless) {
 uint8_t ossid[IF_SSIDLEN];
-#ifdef NOCARRIER_PRESERVE_IP
 size_t olen;
 
 olen = ifp->ssid_len;
-#endif
 memcpy(ossid, ifp->ssid, ifp->ssid_len);
 if_getssid(ifp);
-#ifdef NOCARRIER_PRESERVE_IP
+
 /* If we changed SSID network, drop leases */
 if (ifp->ssid_len != olen ||
 memcmp(ifp->ssid, ossid, ifp->ssid_len))
+{
+#ifdef NOCARRIER_PRESERVE_IP
 	dhcpcd_drop(ifp, 0);
 #endif
+	ipv4ll_reset(ifp);
+}
 			}
 			dhcpcd_initstate(ifp, 0);
 			script_runreason(ifp, "CARRIER");

Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.2 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.3

CVS commit: src/external/bsd/dhcpcd/dist/hooks

2018-09-22 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Sep 22 13:17:46 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/dist/hooks: 20-resolv.conf 29-lookup-hostname
30-hostname 50-ntp.conf 50-yp.conf 50-ypbind.in dhcpcd-run-hooks.in

Log Message:
PR install/53622  (probably)

When used as part of a network based install kernel, the SMALL "test" (aka [)
does not support -a or -o, so rewrite these scripts to avoid using that.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf \
src/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname \
src/external/bsd/dhcpcd/dist/hooks/30-hostname \
src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf \
src/external/bsd/dhcpcd/dist/hooks/50-yp.conf \
src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in
cvs rdiff -u -r1.1.1.4 -r1.2 \
src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in

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/hooks/20-resolv.conf
diff -u src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.1.1.2 src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.2
--- src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.1.1.2	Mon Jan 29 11:11:23 2018
+++ src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf	Sat Sep 22 13:17:46 2018
@@ -77,19 +77,19 @@ build_resolv_conf()
 eval_nd_dns()
 {
 	eval ltime=\$nd${i}_rdnss${j}_lifetime
-	if [ -z "$ltime" -o "$ltime" = 0 ]; then
+	if [ -z "$ltime" ] || [ "$ltime" = 0 ]; then
 		rdnss=
 	else
 		eval rdnss=\$nd${i}_rdnss${j}_servers
 	fi
 	eval ltime=\$nd${i}_dnssl${j}_lifetime
-	if [ -z "$ltime" -o "$ltime" = 0 ]; then
+	if [ -z "$ltime" ] || [ "$ltime" = 0 ]; then
 		dnssl=
 	else
 		eval dnssl=\$nd${i}_dnssl${j}_search
 	fi
 
-	[ -z "$rdnss" -a -z "$dnssl" ] && return 1
+	[ -z "${rdnss}${dnssl}" ] && return 1
 
 	[ -n "$rdnss" ] && new_rdnss="$new_rdnss${new_rdnss:+ }$rdnss"
 	[ -n "$dnssl" ] && new_dnssl="$new_dnssl${new_dnssl:+ }$dnssl"
@@ -130,9 +130,9 @@ add_resolv_conf()
 	fi
 
 	# If we don't have any configuration, remove it
-	if [ -z "$new_domain_name_servers" -a \
-		-z "$new_domain_name" -a \
-		-z "$new_domain_search" ]; then
+	if [ -z "$new_domain_name_servers" ] &&
+	   [ -z "$new_domain_name" ] &&
+	   [ -z "$new_domain_search" ]; then
 		remove_resolv_conf
 		return $?
 	fi
Index: src/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname
diff -u src/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname:1.1.1.2 src/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname:1.2
--- src/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname:1.1.1.2	Mon Jan 29 11:11:23 2018
+++ src/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname	Sat Sep 22 13:17:46 2018
@@ -29,7 +29,7 @@ lookup_hostname()
 
 set_hostname()
 {
-	if [ -z "$new_host_name" -a -z "$new_fqdn_name" ]; then
+	if [ -z "${new_host_name}${new_fqdn_name}" ]; then
 		export new_host_name="$(lookup_hostname)"
 	fi
 }
Index: src/external/bsd/dhcpcd/dist/hooks/30-hostname
diff -u src/external/bsd/dhcpcd/dist/hooks/30-hostname:1.1.1.2 src/external/bsd/dhcpcd/dist/hooks/30-hostname:1.2
--- src/external/bsd/dhcpcd/dist/hooks/30-hostname:1.1.1.2	Mon Jan 29 11:11:23 2018
+++ src/external/bsd/dhcpcd/dist/hooks/30-hostname	Sat Sep 22 13:17:46 2018
@@ -87,8 +87,8 @@ need_hostname()
 		fi
 	elif [ -n "$old_host_name" ]; then
 		if ${hfqdn}; then
-			if [ -n "$old_domain_name" -a \
-			"$old_host_name" = "${old_host_name#*.}" ]
+			if [ -n "$old_domain_name" ] &&
+			   [ "$old_host_name" = "${old_host_name#*.}" ]
 			then
 [ "$hostname" = \
 "$old_host_name.$old_domain_name" ]
@@ -131,8 +131,8 @@ set_hostname()
 		fi
 	elif [ -n "$new_host_name" ]; then
 		if ${hfqdn}; then
-			if [ -n "$new_domain_name" -a \
-			"$new_host_name" = "${new_host_name#*.}" ]
+			if [ -n "$new_domain_name" ] &&
+			   [ "$new_host_name" = "${new_host_name#*.}" ]
 			then
 try_hostname "$new_host_name.$new_domain_name"
 			else
Index: src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf
diff -u src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf:1.1.1.2 src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf:1.2
--- src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf:1.1.1.2	Mon Jan 29 11:11:23 2018
+++ src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf	Sat Sep 22 13:17:46 2018
@@ -96,7 +96,7 @@ build_ntp_conf()
 		printf %s "$servers" >> "$cf"
 		echo "$signature_base_end${header:+ $from }$header" >> "$cf"
 	else
-		[ -e "$ntp_conf" -a -e "$cf" ] || return
+		[ -e "$ntp_conf" ] && [ -e "$cf" ] || return
 	fi
 
 	# If we changed anything, restart ntpd
Index: src/external/bsd/dhcpcd/dist/hooks/50-yp.conf
diff -u src/external/bsd/dhcpcd/dist/hooks/50-yp.conf:1.1.1.2 src/external/bsd/dhcpcd/dist/hooks/50-yp.conf:1.2
--- src/external/bsd/dhcpcd/dist/hooks/50-yp.conf:1.1.1.2	Mon Jan 29 11:11:23 2018
+++ src/external/bsd/dhcpcd/dist/hooks/50-yp.conf	Sat Sep 22 13:17:46 2018
@@ -8,7 +8,7 @@ ypbind_pid()
 

CVS commit: src/external/bsd/dhcpcd/dist/src

2018-08-27 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon Aug 27 13:43:05 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcpcd.c

Log Message:
Update usage() to include documented flags


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/external/bsd/dhcpcd/dist/src/dhcpcd.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/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.13 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.14
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.13	Thu Jun 21 11:58:23 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Mon Aug 27 13:43:05 2018
@@ -86,19 +86,22 @@ static void
 usage(void)
 {
 
-printf("usage: "PACKAGE"\t[-46ABbDdEGgHJKkLnPpqTVw]\n"
+printf("usage: "PACKAGE"\t[-146ABbDdEGgHJKLMNPpqTV]\n"
 	"\t\t[-C, --nohook hook] [-c, --script script]\n"
 	"\t\t[-e, --env value] [-F, --fqdn FQDN] [-f, --config file]\n"
 	"\t\t[-h, --hostname hostname] [-I, --clientid clientid]\n"
-	"\t\t[-i, --vendorclassid vendorclassid] [-l, --leasetime seconds]\n"
-	"\t\t[-m, --metric metric] [-O, --nooption option]\n"
-	"\t\t[-o, --option option] [-Q, --require option]\n"
-	"\t\t[-r, --request address] [-S, --static value]\n"
-	"\t\t[-s, --inform address[/cidr]] [-t, --timeout seconds]\n"
-	"\t\t[-u, --userclass class] [-v, --vendor code, value]\n"
-	"\t\t[-W, --whitelist address[/cidr]] [-y, --reboot seconds]\n"
+	"\t\t[-i, --vendorclassid vendorclassid] [-j, --logfile logfile]\n" 
+	"\t\t[-l, --leasetime seconds] [-m, --metric metric]\n"
+	"\t\t[-O, --nooption option] [-o, --option option]\n"
+	"\t\t[-Q, --require option] [-r, --request address]\n"
+	"\t\t[-S, --static value]\n"
+	"\t\t[-s, --inform address[/cidr[/broadcast_address]]]\n [--inform6]"
+	"\t\t[-t, --timeout seconds] [-u, --userclass class]\n"
+	"\t\t[-v, --vendor code, value] [-W, --whitelist address[/cidr]] [-w]\n"
+	"\t\t[--waitip [4 | 6]] [-y, --reboot seconds]\n"
 	"\t\t[-X, --blacklist address[/cidr]] [-Z, --denyinterfaces pattern]\n"
-	"\t\t[-z, --allowinterfaces pattern] [interface] [...]\n"
+	"\t\t[-z, --allowinterfaces pattern] [--inactive] [interface] [...]\n"
+	"   "PACKAGE"\t-n, --rebind [interface]\n"
 	"   "PACKAGE"\t-k, --release [interface]\n"
 	"   "PACKAGE"\t-U, --dumplease interface\n"
 	"   "PACKAGE"\t--version\n"



CVS commit: src/external/bsd/dhcpcd/dist/src

2018-08-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Aug 20 10:55:59 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/src/dhcp.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.12 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.13
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.12	Fri Aug  3 02:17:33 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Mon Aug 20 10:55:59 2018
@@ -86,6 +86,11 @@
 #define IPDEFTTL 64 /* RFC1340 */
 #endif
 
+/* NetBSD-7 has an incomplete IP_PKTINFO implementation. */
+#if defined(__NetBSD_Version__) && __NetBSD_Version__ < 8
+#undef IP_PKTINFO
+#endif
+
 /* Assert the correct structure size for on wire */
 __CTASSERT(sizeof(struct ip)		== 20);
 __CTASSERT(sizeof(struct udphdr)	== 8);



CVS commit: src/external/bsd/dhcpcd/dist/src

2018-08-02 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Aug  3 02:17:33 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c

Log Message:
Fix build failure in dhcpcd under uUBSan

GCC with -fsanitize=undefiend detects a potential overflow in the code.
Cast the return value of ntohs(3) to size_t.

Fix merged upstream by .


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/src/dhcp.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.11 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.12
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.11	Mon Jun  4 16:45:52 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Fri Aug  3 02:17:33 2018
@@ -3267,7 +3267,7 @@ get_udp_data(void *udp, size_t *len)
 	struct bootp_pkt *p;
 
 	p = (struct bootp_pkt *)udp;
-	*len = ntohs(p->ip.ip_len) - sizeof(p->ip) - sizeof(p->udp);
+	*len = (size_t)ntohs(p->ip.ip_len) - sizeof(p->ip) - sizeof(p->udp);
 	return (char *)udp + offsetof(struct bootp_pkt, bootp);
 }
 



CVS commit: src/external/bsd/dhcpcd

2018-07-04 Thread Frédéric Fauberteau
Module Name:src
Committed By:   triaxx
Date:   Thu Jul  5 05:41:17 UTC 2018

Modified Files:
src/external/bsd/dhcpcd: Makefile.inc

Log Message:
Fix an inconsistency that showed /var/db/duid in the man page while the
binary opened /var/db/dhcpcd/duid.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/dhcpcd/Makefile.inc

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/Makefile.inc
diff -u src/external/bsd/dhcpcd/Makefile.inc:1.2 src/external/bsd/dhcpcd/Makefile.inc:1.3
--- src/external/bsd/dhcpcd/Makefile.inc:1.2	Mon Jun 12 14:50:38 2017
+++ src/external/bsd/dhcpcd/Makefile.inc	Thu Jul  5 05:41:17 2018
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile.inc,v 1.2 2017/06/12 14:50:38 roy Exp $
+# $NetBSD: Makefile.inc,v 1.3 2018/07/05 05:41:17 triaxx Exp $
 
 SRCDIR=		${NETBSDSRCDIR}/external/bsd/dhcpcd
 DIST=		${SRCDIR}/dist
 
 SED_SYS=	-e 's:@SYSCONFDIR@:/etc:g' \
 		-e 's:@DATADIR@:/usr/share/examples:g' \
-		-e 's:@DBDIR@:/var/db:g' \
+		-e 's:@DBDIR@:/var/db/dhcpcd:g' \
 		-e 's:@LIBDIR@:/lib:g' \
 		-e 's:@RUNDIR@:/var/run:g' \
 		-e 's:@HOOKDIR@:/libexec/dhcpcd-hooks:g' \



CVS commit: src/external/bsd/dhcpcd/dist/src

2018-06-21 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Jun 21 11:58:23 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcpcd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/src/dhcpcd.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/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.12 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.13
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.12	Mon Jun  4 09:56:16 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Thu Jun 21 11:58:23 2018
@@ -373,7 +373,7 @@ dhcpcd_drop(struct interface *ifp, int s
 #ifdef IPV4LL
 	ipv4ll_drop(ifp);
 #endif
-#ifdef DHCP
+#ifdef INET
 	dhcp_drop(ifp, stop ? "STOP" : "EXPIRE");
 #endif
 #ifdef ARP



CVS commit: src/external/bsd/dhcpcd/dist/src

2018-06-04 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Jun  4 16:45:52 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/dhcp.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.10 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.11
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.10	Sat Jun  2 09:44:27 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Mon Jun  4 16:45:52 2018
@@ -2101,8 +2101,10 @@ dhcp_arp_probed(struct arp_state *astate
 	if (ifp->ctx->options & DHCPCD_FORKED)
 		return;
 
+#ifdef IPV4LL
 	/* Stop IPv4LL now we have a working DHCP address */
 	ipv4ll_drop(ifp);
+#endif
 
 	if (ifo->options & DHCPCD_INFORM)
 		dhcp_inform(ifp);



CVS commit: src/external/bsd/dhcpcd/dist/src

2018-06-04 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Jun  4 09:56:16 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcpcd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/src/dhcpcd.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/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.11 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.12
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.11	Sat Jun  2 09:44:27 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Mon Jun  4 09:56:16 2018
@@ -363,14 +363,25 @@ static void
 dhcpcd_drop(struct interface *ifp, int stop)
 {
 
+#ifdef DHCP6
 	dhcp6_drop(ifp, stop ? NULL : "EXPIRE6");
+#endif
+#ifdef INET6
 	ipv6nd_drop(ifp);
 	ipv6_drop(ifp);
+#endif
+#ifdef IPV4LL
 	ipv4ll_drop(ifp);
+#endif
+#ifdef DHCP
 	dhcp_drop(ifp, stop ? "STOP" : "EXPIRE");
+#endif
 #ifdef ARP
 	arp_drop(ifp);
 #endif
+#if !defined(DHCP6) && !defined(DHCP)
+	UNUSED(stop);
+#endif
 }
 
 static void
@@ -773,8 +784,10 @@ static void
 warn_iaid_conflict(struct interface *ifp, uint16_t ia_type, uint8_t *iaid)
 {
 	struct interface *ifn;
+#ifdef INET6
 	size_t i;
 	struct if_ia *ia;
+#endif
 
 	TAILQ_FOREACH(ifn, ifp->ctx->ifaces, next) {
 		if (ifn == ifp || !ifn->active)
@@ -783,12 +796,14 @@ warn_iaid_conflict(struct interface *ifp
 		memcmp(ifn->options->iaid, iaid,
 		sizeof(ifn->options->iaid)) == 0)
 			break;
+#ifdef INET6
 		for (i = 0; i < ifn->options->ia_len; i++) {
 			ia = >options->ia[i];
 			if (ia->ia_type == ia_type &&
 			memcmp(ia->iaid, iaid, sizeof(ia->iaid)) == 0)
 break;
 		}
+#endif
 	}
 
 	/* This is only a problem if the interfaces are on the same network. */
@@ -802,7 +817,6 @@ dhcpcd_startinterface(void *arg)
 {
 	struct interface *ifp = arg;
 	struct if_options *ifo = ifp->options;
-	size_t i;
 	char buf[DUID_LEN * 3];
 	int carrier;
 	struct timespec tv;
@@ -842,13 +856,17 @@ dhcpcd_startinterface(void *arg)
 	}
 
 	if (ifo->options & (DHCPCD_DUID | DHCPCD_IPV6)) {
+#ifdef INET6
+		size_t i;
 		struct if_ia *ia;
+#endif
 
 		/* Report IAIDs */
 		loginfox("%s: IAID %s", ifp->name,
 		hwaddr_ntoa(ifo->iaid, sizeof(ifo->iaid),
 		buf, sizeof(buf)));
 		warn_iaid_conflict(ifp, 0, ifo->iaid);
+#ifdef INET6
 		for (i = 0; i < ifo->ia_len; i++) {
 			ia = >ia[i];
 			if (memcmp(ifo->iaid, ia->iaid, sizeof(ifo->iaid))) {
@@ -859,6 +877,7 @@ dhcpcd_startinterface(void *arg)
 warn_iaid_conflict(ifp, ia->ia_type, ia->iaid);
 			}
 		}
+#endif
 	}
 
 	if (ifo->options & DHCPCD_IPV6 && ipv6_start(ifp) == -1) {



CVS commit: src/external/bsd/dhcpcd/dist/src

2018-06-02 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Jun  2 09:44:27 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcpcd.c if-options.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/bpf.c
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/dhcp.c \
src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/dhcpcd.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/src/bpf.c
diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.6 src/external/bsd/dhcpcd/dist/src/bpf.c:1.7
--- src/external/bsd/dhcpcd/dist/src/bpf.c:1.6	Mon Jan  1 11:50:56 2018
+++ src/external/bsd/dhcpcd/dist/src/bpf.c	Sat Jun  2 09:44:27 2018
@@ -108,7 +108,7 @@ bpf_open(struct interface *ifp, int (*fi
 	size_t buf_len;
 	struct bpf_version pv;
 #ifdef BIOCIMMEDIATE
-	int flags;
+	unsigned int flags;
 #endif
 #ifndef O_CLOEXEC
 	int fd_opts;
@@ -411,7 +411,7 @@ static const struct bpf_insn bpf_arp_eth
 	/* Make sure the hardware length matches. */
 	BPF_STMT(BPF_LD + BPF_B + BPF_IND, offsetof(struct arphdr, ar_hln)),
 	BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K,
-	 sizeof((struct ether_arp *)0)->arp_sha, 1, 0),
+	 sizeof(((struct ether_arp *)0)->arp_sha), 1, 0),
 	BPF_STMT(BPF_RET + BPF_K, 0),
 };
 #define bpf_arp_ether_len	__arraycount(bpf_arp_ether)
@@ -540,7 +540,7 @@ static const struct bpf_insn bpf_bootp_e
 #define BPF_BOOTP_ETHER_LEN	__arraycount(bpf_bootp_ether)
 
 static const struct bpf_insn bpf_bootp_filter[] = {
-	/* Make sure it's an IPv4 packet. */
+	/* Make sure it's an optionless IPv4 packet. */
 	BPF_STMT(BPF_LD + BPF_B + BPF_IND, 0),
 	BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0x45, 1, 0),
 	BPF_STMT(BPF_RET + BPF_K, 0),

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.9 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.10
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.9	Tue Mar 27 06:16:34 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Sat Jun  2 09:44:27 2018
@@ -3276,7 +3276,7 @@ valid_udp_packet(void *data, size_t data
 	struct bootp_pkt *p;
 	uint16_t bytes;
 
-	if (data_len < sizeof(p->ip) + sizeof(p->udp)) {
+	if (data_len < sizeof(p->ip)) {
 		if (from)
 			from->s_addr = INADDR_ANY;
 		errno = ERANGE;
@@ -3291,6 +3291,12 @@ valid_udp_packet(void *data, size_t data
 	}
 
 	bytes = ntohs(p->ip.ip_len);
+	/* Check we have a payload */
+	if (bytes <= sizeof(p->ip) + sizeof(p->udp)) {
+		errno = ERANGE;
+		return -1;
+	}
+	/* Check we don't go beyond the payload */
 	if (bytes > data_len) {
 		errno = ENOBUFS;
 		return -1;
@@ -3334,7 +3340,7 @@ dhcp_handlepacket(struct interface *ifp,
 			 state->bpf_flags & RAW_PARTIALCSUM) == -1)
 	{
 		if (errno == EINVAL)
-			logerrx("%s: UDP checksum failure from %s",
+			logerrx("%s: checksum failure from %s",
 			  ifp->name, inet_ntoa(from));
 		else
 			logerr("%s: invalid UDP packet from %s",
Index: src/external/bsd/dhcpcd/dist/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.9 src/external/bsd/dhcpcd/dist/src/if-options.c:1.10
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.9	Wed May  2 22:08:45 2018
+++ src/external/bsd/dhcpcd/dist/src/if-options.c	Sat Jun  2 09:44:27 2018
@@ -1360,6 +1360,7 @@ parse_option(struct dhcpcd_ctx *ctx, con
 		for (sl = 0; sl < ifo->ia_len; sl++) {
 			if ((arg == NULL && !ifo->ia[sl].iaid_set) ||
 			(arg != NULL && ifo->ia[sl].iaid_set &&
+			ifo->ia[sl].ia_type == (uint16_t)i &&
 			ifo->ia[sl].iaid[0] == iaid[0] &&
 			ifo->ia[sl].iaid[1] == iaid[1] &&
 			ifo->ia[sl].iaid[2] == iaid[2] &&
@@ -1369,10 +1370,6 @@ parse_option(struct dhcpcd_ctx *ctx, con
 break;
 			}
 		}
-		if (ia && ia->ia_type != (uint16_t)i) {
-			logerrx("Cannot mix IA for the same IAID");
-			break;
-		}
 		if (ia == NULL) {
 			ia = reallocarray(ifo->ia,
 			ifo->ia_len + 1, sizeof(*ifo->ia));

Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.10 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.11
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.10	Fri Apr  6 10:47:47 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Sat Jun  2 09:44:27 2018
@@ -770,20 +770,23 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *
 }
 
 static void
-warn_iaid_conflict(struct interface *ifp, uint8_t *iaid)
+warn_iaid_conflict(struct interface *ifp, uint16_t ia_type, uint8_t *iaid)
 {
 	struct interface *ifn;
 	size_t i;
+	struct if_ia *ia;
 
 	TAILQ_FOREACH(ifn, ifp->ctx->ifaces, next) {
 		if (ifn == ifp || !ifn->active)
 			continue;
-		if (memcmp(ifn->options->iaid, iaid,
+		if (ia_type == 0 &&
+		memcmp(ifn->options->iaid, iaid,
 		sizeof(ifn->options->iaid)) == 0)
 			break;
 		for (i = 0; i < ifn->options->ia_len; i++) {
-			if (memcmp(>options->ia[i].iaid, 

CVS commit: src/external/bsd/dhcpcd/dist/src

2018-05-02 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed May  2 22:08:45 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/dist/src: if-options.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/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/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.8 src/external/bsd/dhcpcd/dist/src/if-options.c:1.9
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.8	Fri Apr  6 10:47:47 2018
+++ src/external/bsd/dhcpcd/dist/src/if-options.c	Wed May  2 22:08:45 2018
@@ -1850,6 +1850,7 @@ err_sla:
 			logerrx("invalid code: %s", arg);
 			return -1;
 		}
+		fp = strskipwhite(fp);
 		if (fp) {
 			s = parse_string(NULL, 0, fp);
 			if (s == -1) {
@@ -1912,12 +1913,32 @@ err_sla:
 		}
 		if (fp)
 			*fp++ = '\0';
-		if (strcasecmp(arg, "hmacmd5") == 0 ||
-		strcasecmp(arg, "hmac-md5") == 0)
-			ifo->auth.algorithm = AUTH_ALG_HMAC_MD5;
-		else {
-			logerrx("%s: unsupported algorithm", arg);
-			return 1;
+		if (ifo->auth.protocol == AUTH_PROTO_TOKEN) {
+			np = strchr(arg, '/');
+			if (np) {
+if (fp == NULL || np < fp)
+	*np++ = '\0';
+else
+	np = NULL;
+			}
+			if (parse_uint32(>auth.token_snd_secretid,
+			arg) == -1)
+logerrx("%s: not a number", arg);
+			else
+ifo->auth.token_rcv_secretid =
+ifo->auth.token_snd_secretid;
+			if (np &&
+			parse_uint32(>auth.token_rcv_secretid,
+			np) == -1)
+logerrx("%s: not a number", arg);
+		} else {
+			if (strcasecmp(arg, "hmacmd5") == 0 ||
+			strcasecmp(arg, "hmac-md5") == 0)
+ifo->auth.algorithm = AUTH_ALG_HMAC_MD5;
+			else {
+logerrx("%s: unsupported algorithm", arg);
+return 1;
+			}
 		}
 		arg = fp;
 		if (arg == NULL) {



CVS commit: src/external/bsd/dhcpcd/dist/src

2018-04-06 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr  6 10:47:47 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcpcd.c if-options.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/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/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.9 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.10
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.9	Tue Mar 27 06:16:34 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Fri Apr  6 10:47:47 2018
@@ -577,7 +577,7 @@ dhcpcd_selectprofile(struct interface *i
 	} else
 		*ifp->profile = '\0';
 
-	free_options(ifp->options);
+	free_options(ifp->ctx, ifp->options);
 	ifp->options = ifo;
 	if (profile) {
 		add_options(ifp->ctx, ifp->name, ifp->options,
@@ -995,6 +995,7 @@ dhcpcd_handleinterface(void *arg, int ac
 	}
 	/* Check if we already have the interface */
 	iff = if_find(ctx->ifaces, ifp->name);
+
 	if (iff != NULL) {
 		if (iff->active)
 			logdebugx("%s: interface updated", iff->name);
@@ -1013,9 +1014,12 @@ dhcpcd_handleinterface(void *arg, int ac
 		}
 		iff = ifp;
 	}
-	if_learnaddrs(ctx, ifs, );
-	if (action > 0 && iff->active)
-		dhcpcd_prestartinterface(iff);
+
+	if (action > 0) {
+		if_learnaddrs(ctx, ifs, );
+		if (iff->active)
+			dhcpcd_prestartinterface(iff);
+	}
 
 	/* Free our discovered list */
 	while ((ifp = TAILQ_FIRST(ifs))) {
@@ -1161,7 +1165,7 @@ reload_config(struct dhcpcd_ctx *ctx)
 	if (ctx->options & DHCPCD_DAEMONISED)
 		ifo->options |= DHCPCD_DAEMONISED;
 	ctx->options = ifo->options;
-	free_options(ifo);
+	free_options(ctx, ifo);
 }
 
 static void
@@ -1519,6 +1523,8 @@ main(int argc, char **argv)
 #ifdef INET
 	ctx.udp_fd = -1;
 #endif
+	rt_init();
+
 	logopts = LOGERR_ERR|LOGERR_LOG|LOGERR_LOG_DATE|LOGERR_LOG_PID;
 	i = 0;
 	while ((opt = getopt_long(argc, argv,
@@ -1613,7 +1619,7 @@ main(int argc, char **argv)
 	if (i == 2) {
 		printf("Interface options:\n");
 		if (optind == argc - 1) {
-			free_options(ifo);
+			free_options(, ifo);
 			ifo = read_config(, argv[optind], NULL, NULL);
 			if (ifo == NULL)
 goto exit_failure;
@@ -1929,8 +1935,6 @@ printpidfile:
 		}
 	}
 
-	rt_init();
-
 	TAILQ_FOREACH(ifp, ctx.ifaces, next) {
 		if (ifp->active)
 			dhcpcd_initstate1(ifp, argc, argv, 0);
@@ -1981,7 +1985,7 @@ printpidfile:
 			handle_exit_timeout, );
 		}
 	}
-	free_options(ifo);
+	free_options(, ifo);
 	ifo = NULL;
 
 	if_sortinterfaces();
@@ -2018,6 +2022,7 @@ exit1:
 		}
 		free(ctx.ifaces);
 	}
+	free_options(, ifo);
 	rt_dispose();
 	free(ctx.duid);
 	if (ctx.link_fd != -1) {
@@ -2025,7 +2030,6 @@ exit1:
 		close(ctx.link_fd);
 	}
 	if_closesockets();
-	free_options(ifo);
 	free_globals();
 	ipv6_ctxfree();
 	dev_stop();

Index: src/external/bsd/dhcpcd/dist/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.7 src/external/bsd/dhcpcd/dist/src/if-options.c:1.8
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.7	Mon Jan 29 11:13:06 2018
+++ src/external/bsd/dhcpcd/dist/src/if-options.c	Fri Apr  6 10:47:47 2018
@@ -1086,14 +1086,8 @@ parse_option(struct dhcpcd_ctx *ctx, con
 		strncmp(arg, "ms_classless_static_routes=",
 		strlen("ms_classless_static_routes=")) == 0)
 		{
-			struct interface *ifp;
 			struct in_addr addr3;
 
-			ifp = if_find(ctx->ifaces, ifname);
-			if (ifp == NULL) {
-logerrx("static routes require an interface");
-return -1;
-			}
 			fp = np = strwhite(p);
 			if (np == NULL) {
 logerrx("all routes need a gateway");
@@ -1107,7 +1101,7 @@ parse_option(struct dhcpcd_ctx *ctx, con
 *fp = ' ';
 return -1;
 			}
-			if ((rt = rt_new(ifp)) == NULL) {
+			if ((rt = rt_new0(ctx)) == NULL) {
 *fp = ' ';
 return -1;
 			}
@@ -1117,16 +,9 @@ parse_option(struct dhcpcd_ctx *ctx, con
 			TAILQ_INSERT_TAIL(>routes, rt, rt_next);
 			*fp = ' ';
 		} else if (strncmp(arg, "routers=", strlen("routers=")) == 0) {
-			struct interface *ifp;
-
-			ifp = if_find(ctx->ifaces, ifname);
-			if (ifp == NULL) {
-logerrx("static routes require an interface");
-return -1;
-			}
 			if (parse_addr(, NULL, p) == -1)
 return -1;
-			if ((rt = rt_new(ifp)) == NULL)
+			if ((rt = rt_new0(ctx)) == NULL)
 return -1;
 			addr2.s_addr = INADDR_ANY;
 			sa_in_init(>rt_dest, );
@@ -2367,7 +2354,7 @@ read_config(struct dhcpcd_ctx *ctx,
 		buf = malloc(buflen);
 		if (buf == NULL) {
 			logerr(__func__);
-			free_options(ifo);
+			free_options(ctx, ifo);
 			return NULL;
 		}
 		ldop = edop = NULL;
@@ -2381,7 +2368,7 @@ read_config(struct dhcpcd_ctx *ctx,
 if (nbuf == NULL) {
 	logerr(__func__);
 	free(buf);
-	free_options(ifo);
+	free_options(ctx, ifo);
 	return NULL;
 }
 buf = nbuf;
@@ 

CVS commit: src/external/bsd/dhcpcd/include

2018-03-27 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Mar 27 06:18:40 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/include: config.h

Log Message:
Add support for setproctitle(3)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/dhcpcd/include/config.h

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/include/config.h
diff -u src/external/bsd/dhcpcd/include/config.h:1.2 src/external/bsd/dhcpcd/include/config.h:1.3
--- src/external/bsd/dhcpcd/include/config.h:1.2	Sat Oct  7 14:11:07 2017
+++ src/external/bsd/dhcpcd/include/config.h	Tue Mar 27 06:18:40 2018
@@ -9,6 +9,7 @@
 #define HAVE_IFAM_ADDRFLAGS
 #define HAVE_IFADDRS_ADDRFLAGS
 #define HAVE_UTIL_H
+#define HAVE_SETPROCTITLE
 #define HAVE_SYS_QUEUE_H
 #define HAVE_REALLOCARRAY
 #define HAVE_KQUEUE



CVS commit: src/external/bsd/dhcpcd/dist/src

2018-03-27 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Mar 27 06:16:34 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcpcd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/dhcp.c \
src/external/bsd/dhcpcd/dist/src/dhcpcd.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.8 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.9
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.8	Mon Jan 29 11:13:06 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Tue Mar 27 06:16:34 2018
@@ -3653,6 +3653,7 @@ dhcp_start1(void *arg)
 
 	state = D_STATE(ifp);
 	clock_gettime(CLOCK_MONOTONIC, >started);
+	state->interval = 0;
 	free(state->offer);
 	state->offer = NULL;
 	state->offer_len = 0;
@@ -3891,7 +3892,7 @@ dhcp_abort(struct interface *ifp)
 }
 
 void
-dhcp_handleifa(int cmd, struct ipv4_addr *ia)
+dhcp_handleifa(int cmd, struct ipv4_addr *ia, pid_t pid)
 {
 	struct interface *ifp;
 	struct dhcp_state *state;
@@ -3905,12 +3906,13 @@ dhcp_handleifa(int cmd, struct ipv4_addr
 
 	if (cmd == RTM_DELADDR) {
 		if (state->addr == ia) {
-			loginfox("%s: deleted IP address %s",
-			ifp->name, ia->saddr);
+			loginfox("%s: pid %d deleted IP address %s",
+			ifp->name, pid, ia->saddr);
 			state->addr = NULL;
 			/* Don't clear the added state as we need
 			 * to drop the lease. */
 			dhcp_drop(ifp, "EXPIRE");
+			dhcp_start1(ifp);
 		}
 		return;
 	}
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.8 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.9
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.8	Mon Jan 29 11:13:06 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Tue Mar 27 06:16:34 2018
@@ -437,19 +437,15 @@ configure_interface1(struct interface *i
 		ifo->options &=
 		~(DHCPCD_IPV6RS | DHCPCD_DHCP6 | DHCPCD_WAITIP6);
 
-	/* We want to disable kernel interface RA as early as possible. */
+	/* We want to setup INET6 on the interface as soon as possible. */
 	if (ifp->active == IF_ACTIVE_USER &&
-	!(ifp->ctx->options & DHCPCD_DUMPLEASE))
+	ifo->options & DHCPCD_IPV6 &&
+	!(ifp->ctx->options & (DHCPCD_DUMPLEASE | DHCPCD_TEST)))
 	{
-		int ra_global, ra_iface;
-
 		/* If not doing any DHCP, disable the RDNSS requirement. */
 		if (!(ifo->options & (DHCPCD_DHCP | DHCPCD_DHCP6)))
 			ifo->options &= ~DHCPCD_IPV6RA_REQRDNSS;
-		ra_global = if_checkipv6(ifp->ctx, NULL);
-		ra_iface = if_checkipv6(ifp->ctx, ifp);
-		if (ra_global == -1 || ra_iface == -1)
-			ifo->options &= ~DHCPCD_IPV6RS;
+		if_setup_inet6(ifp);
 	}
 #endif
 
@@ -959,20 +955,6 @@ dhcpcd_activateinterface(struct interfac
 	}
 }
 
-static void
-dhcpcd_handlelink(void *arg)
-{
-	struct dhcpcd_ctx *ctx;
-
-	ctx = arg;
-	if (if_handlelink(ctx) == -1) {
-		logerr(__func__);
-		eloop_event_delete(ctx->eloop, ctx->link_fd);
-		close(ctx->link_fd);
-		ctx->link_fd = -1;
-	}
-}
-
 int
 dhcpcd_handleinterface(void *arg, int action, const char *ifname)
 {
@@ -1045,6 +1027,83 @@ dhcpcd_handleinterface(void *arg, int ac
 	return 1;
 }
 
+static void
+dhcpcd_handlelink(void *arg)
+{
+	struct dhcpcd_ctx *ctx = arg;
+
+	if (if_handlelink(ctx) == -1) {
+		if (errno == ENOBUFS || errno == ENOMEM) {
+			dhcpcd_linkoverflow(ctx);
+			return;
+		}
+		logerr(__func__);
+	}
+}
+
+static void
+dhcpcd_checkcarrier(void *arg)
+{
+	struct interface *ifp = arg;
+
+	dhcpcd_handlecarrier(ifp->ctx, LINK_UNKNOWN, ifp->flags, ifp->name);
+}
+
+void
+dhcpcd_linkoverflow(struct dhcpcd_ctx *ctx)
+{
+	struct if_head *ifaces;
+	struct ifaddrs *ifaddrs;
+	struct interface *ifp, *ifn, *ifp1;
+
+	logerrx("route socket overflowed - learning interface state");
+
+	/* Close the existing socket and open a new one.
+	 * This is easier than draining the kernel buffer of an
+	 * in-determinate size. */
+	eloop_event_delete(ctx->eloop, ctx->link_fd);
+	close(ctx->link_fd);
+	if_closesockets_os(ctx);
+	if (if_opensockets_os(ctx) == -1) {
+		logerr("%s: if_opensockets", __func__);
+		eloop_exit(ctx->eloop, EXIT_FAILURE);
+		return;
+	}
+	eloop_event_add(ctx->eloop, ctx->link_fd, dhcpcd_handlelink, ctx);
+
+	/* Work out the current interfaces. */
+	ifaces = if_discover(ctx, , ctx->ifc, ctx->ifv);
+
+	/* Punt departed interfaces */
+	TAILQ_FOREACH_SAFE(ifp, ctx->ifaces, next, ifn) {
+		if (if_find(ifaces, ifp->name) != NULL)
+			continue;
+		dhcpcd_handleinterface(ctx, -1, ifp->name);
+	}
+
+	/* Add new interfaces */
+	TAILQ_FOREACH_SAFE(ifp, ifaces, next, ifn) {
+		ifp1 = if_find(ctx->ifaces, ifp->name);
+		if (ifp1 != NULL) {
+			/* If the interface already exists,
+			 * check carrier state. */
+			eloop_timeout_add_sec(ctx->eloop, 0,
+			dhcpcd_checkcarrier, ifp1);
+			continue;
+		}
+		TAILQ_REMOVE(ifaces, ifp, next);
+		TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next);
+		

CVS commit: src/external/bsd/dhcpcd/dist/src

2018-01-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Jan 29 11:13:06 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcpcd.c if-options.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/dhcp.c \
src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.7 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.8
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.7	Mon Jan  1 11:50:56 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Mon Jan 29 11:13:06 2018
@@ -1462,8 +1462,11 @@ get_lease(struct interface *ifp,
 	if (ifp->options->options & (DHCPCD_STATIC | DHCPCD_INFORM)) {
 		if (ifp->options->req_addr.s_addr != INADDR_ANY) {
 			lease->mask = ifp->options->req_mask;
-			lease->brd.s_addr =
-			lease->addr.s_addr | ~lease->mask.s_addr;
+			if (ifp->options->req_brd.s_addr != INADDR_ANY)
+lease->brd = ifp->options->req_brd;
+			else
+lease->brd.s_addr =
+lease->addr.s_addr | ~lease->mask.s_addr;
 		} else {
 			const struct ipv4_addr *ia;
 
@@ -2076,7 +2079,7 @@ dhcp_arp_probed(struct arp_state *astate
 
 	logdebugx("%s: DAD completed for %s",
 	ifp->name, inet_ntoa(astate->addr));
-	if (state->state != DHS_INFORM)
+	if (!(ifo->options & DHCPCD_INFORM))
 		dhcp_bind(ifp);
 #ifndef IN_IFF_TENTATIVE
 	else {
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.7 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.8
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.7	Mon Jan  1 11:50:56 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Mon Jan 29 11:13:06 2018
@@ -712,8 +712,10 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *
 	eloop_timeout_delete(ifp->ctx->eloop, dhcpcd_pollup, ifp);
 
 	if (carrier == LINK_UNKNOWN) {
-		if (errno != ENOTTY) /* For example a PPP link on BSD */
+		if (errno != ENOTTY && errno != ENXIO) {
+			/* Don't log an error if interface departed */
 			logerr("%s: %s", ifp->name, __func__);
+		}
 	} else if (carrier == LINK_DOWN || (ifp->flags & IFF_UP) == 0) {
 		if (ifp->carrier != LINK_DOWN) {
 			if (ifp->carrier == LINK_UP)
@@ -977,9 +979,8 @@ dhcpcd_handleinterface(void *arg, int ac
 	struct dhcpcd_ctx *ctx;
 	struct ifaddrs *ifaddrs;
 	struct if_head *ifs;
-	struct interface *ifp, *iff, *ifn;
+	struct interface *ifp, *iff;
 	const char * const argv[] = { ifname };
-	int i;
 
 	ctx = arg;
 	if (action == -1) {
@@ -998,62 +999,41 @@ dhcpcd_handleinterface(void *arg, int ac
 		return 0;
 	}
 
-	i = -1;
 	ifs = if_discover(ctx, , -1, UNCONST(argv));
 	if (ifs == NULL) {
 		logerr(__func__);
 		return -1;
 	}
-	TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) {
-		if (strcmp(ifp->name, ifname) != 0)
-			continue;
-
-		/* If running off an interface list, check it's in it. */
-		if (ctx->ifc || ctx->options & DHCPCD_INACTIVE) {
-			for (i = 0; i < ctx->ifc; i++)
-if (strcmp(ctx->ifv[i], ifname) == 0)
-	break;
-			if (i >= ctx->ifc) {
-ifp->active = IF_INACTIVE;
-ifp->carrier = LINK_UNKNOWN;
-			}
-		}
-
-		i = 0;
-		/* Check if we already have the interface */
-		iff = if_find(ctx->ifaces, ifp->name);
-		if (iff) {
-			if (iff->active)
-logdebugx("%s: interface updated", iff->name);
-			/* The flags and hwaddr could have changed */
-			iff->flags = ifp->flags;
-			iff->hwlen = ifp->hwlen;
-			if (ifp->hwlen != 0)
-memcpy(iff->hwaddr, ifp->hwaddr, iff->hwlen);
-		} else {
-			TAILQ_REMOVE(ifs, ifp, next);
-			TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next);
-			if (!ifp->active)
-continue;
+	ifp = if_find(ifs, ifname);
+	if (ifp == NULL) {
+		/* This can happen if an interface is quickly added
+		 * and then removed. */
+		errno = ENOENT;
+		return -1;
+	}
+	/* Check if we already have the interface */
+	iff = if_find(ctx->ifaces, ifp->name);
+	if (iff != NULL) {
+		if (iff->active)
+			logdebugx("%s: interface updated", iff->name);
+		/* The flags and hwaddr could have changed */
+		iff->flags = ifp->flags;
+		iff->hwlen = ifp->hwlen;
+		if (ifp->hwlen != 0)
+			memcpy(iff->hwaddr, ifp->hwaddr, iff->hwlen);
+	} else {
+		TAILQ_REMOVE(ifs, ifp, next);
+		TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next);
+		if (ifp->active) {
 			logdebugx("%s: interface added", ifp->name);
 			dhcpcd_initstate(ifp, 0);
 			run_preinit(ifp);
-			iff = ifp;
 		}
-		if (action > 0 && iff->active)
-			dhcpcd_prestartinterface(iff);
+		iff = ifp;
 	}
-
 	if_learnaddrs(ctx, ifs, );
-
-	/* Now we have learned addresses, start the interface */
-	TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) {
-		if (strcmp(ifp->name, ifname) != 0)
-			continue;
-		iff = if_find(ctx->ifaces, ifp->name);
-		if (action > 0 && iff->active)
-			dhcpcd_prestartinterface(iff);
-	}
+	if (action > 0 && iff->active)
+	

CVS commit: src/external/bsd/dhcpcd/dist/src

2018-01-01 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Jan  1 11:50:56 UTC 2018

Modified Files:
src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcpcd.c if-options.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcpcd/dist/src/bpf.c \
src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/dhcp.c \
src/external/bsd/dhcpcd/dist/src/dhcpcd.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/src/bpf.c
diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.5 src/external/bsd/dhcpcd/dist/src/bpf.c:1.6
--- src/external/bsd/dhcpcd/dist/src/bpf.c:1.5	Wed Dec  6 10:35:05 2017
+++ src/external/bsd/dhcpcd/dist/src/bpf.c	Mon Jan  1 11:50:56 2018
@@ -1,6 +1,6 @@
 /*
  * dhcpcd: BPF arp and bootp filtering
- * Copyright (c) 2006-2017 Roy Marples 
+ * Copyright (c) 2006-2018 Roy Marples 
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
Index: src/external/bsd/dhcpcd/dist/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.5 src/external/bsd/dhcpcd/dist/src/if-options.c:1.6
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.5	Tue Sep 19 19:19:21 2017
+++ src/external/bsd/dhcpcd/dist/src/if-options.c	Mon Jan  1 11:50:56 2018
@@ -1,6 +1,6 @@
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2017 Roy Marples 
+ * Copyright (c) 2006-2018 Roy Marples 
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.6 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.7
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.6	Wed Dec  6 10:35:05 2017
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Mon Jan  1 11:50:56 2018
@@ -1,6 +1,6 @@
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2017 Roy Marples 
+ * Copyright (c) 2006-2018 Roy Marples 
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -777,7 +777,8 @@ make_message(struct bootp **bootpm, cons
 	(type == DHCP_INFORM || type == DHCP_RELEASE ||
 	(type == DHCP_REQUEST &&
 	state->addr->mask.s_addr == lease->mask.s_addr &&
-	(state->new == NULL || IS_DHCP(state->new)
+	(state->new == NULL || IS_DHCP(state->new)) &&
+	!(state->added & STATE_FAKE
 		bootp->ciaddr = state->addr->addr.s_addr;
 
 	bootp->op = BOOTREQUEST;
@@ -845,6 +846,7 @@ make_message(struct bootp **bootpm, cons
 		if (type == DHCP_DECLINE ||
 		(type == DHCP_REQUEST &&
 		(state->addr == NULL ||
+		state->added & STATE_FAKE ||
 		lease->addr.s_addr != state->addr->addr.s_addr)))
 		{
 			PUT_ADDR(DHO_IPADDRESS, >addr);
@@ -1587,10 +1589,6 @@ dhcp_openudp(struct interface *ifp)
 	int s;
 	struct sockaddr_in sin;
 	int n;
-	struct dhcp_state *state;
-#ifdef SO_BINDTODEVICE
-	struct ifreq ifr;
-#endif
 
 	if ((s = xsocket(PF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP)) == -1)
 		return -1;
@@ -1598,20 +1596,12 @@ dhcp_openudp(struct interface *ifp)
 	n = 1;
 	if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, , sizeof(n)) == -1)
 		goto eexit;
-#ifdef SO_BINDTODEVICE
-	if (ifp) {
-		memset(, 0, sizeof(ifr));
-		strlcpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name));
-		if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, ,
-		sizeof(ifr)) == -1)
-		goto eexit;
-	}
-#endif
 	memset(, 0, sizeof(sin));
 	sin.sin_family = AF_INET;
 	sin.sin_port = htons(BOOTPC);
 	if (ifp) {
-		state = D_STATE(ifp);
+		struct dhcp_state *state = D_STATE(ifp);
+
 		if (state->addr)
 			sin.sin_addr.s_addr = state->addr->addr.s_addr;
 	}
@@ -1694,6 +1684,63 @@ dhcp_makeudppacket(size_t *sz, const uin
 	return udpp;
 }
 
+static ssize_t
+dhcp_sendudp(struct interface *ifp, struct in_addr *to, void *data, size_t len)
+{
+	int s;
+	struct msghdr msg;
+	struct sockaddr_in sin;
+	struct iovec iov[1];
+	ssize_t r;
+#ifdef IP_PKTINFO
+	uint8_t cmsg[CMSG_SPACE(sizeof(struct in_pktinfo))];
+	struct cmsghdr *cm;
+	struct in_pktinfo ipi;
+#endif
+
+	iov[0].iov_base = data;
+	iov[0].iov_len = len;
+
+	memset(, 0, sizeof(sin));
+	sin.sin_family = AF_INET;
+	sin.sin_addr = *to;
+	sin.sin_port = htons(BOOTPS);
+#ifdef HAVE_SA_LEN
+	sin.sin_len = sizeof(sin);
+#endif
+
+	memset(, 0, sizeof(msg));
+	msg.msg_name = (void *)
+	msg.msg_namelen = sizeof(sin);
+	msg.msg_iov = iov;
+	msg.msg_iovlen = 1;
+
+#ifdef IP_PKTINFO
+	/* Set the outbound interface */
+	msg.msg_control = cmsg;
+	msg.msg_controllen = sizeof(cmsg);
+
+	memset(, 0, sizeof(ipi));
+	ipi.ipi_ifindex = ifp->index;
+	cm = CMSG_FIRSTHDR();
+	if (cm == NULL) {
+		errno = ESRCH;
+		return -1;
+	}
+	cm->cmsg_level = IPPROTO_IP;
+	cm->cmsg_type = IP_PKTINFO;
+	

CVS commit: src/external/bsd/dhcpcd/dist/src

2017-12-06 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Dec  6 10:35:05 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcpcd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/src/bpf.c
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcpcd/dist/src/dhcp.c \
src/external/bsd/dhcpcd/dist/src/dhcpcd.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/src/bpf.c
diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.4 src/external/bsd/dhcpcd/dist/src/bpf.c:1.5
--- src/external/bsd/dhcpcd/dist/src/bpf.c:1.4	Tue Sep 19 19:19:21 2017
+++ src/external/bsd/dhcpcd/dist/src/bpf.c	Wed Dec  6 10:35:05 2017
@@ -194,7 +194,8 @@ eexit:
 /* BPF requires that we read the entire buffer.
  * So we pass the buffer in the API so we can loop on >1 packet. */
 ssize_t
-bpf_read(struct interface *ifp, int fd, void *data, size_t len, int *flags)
+bpf_read(struct interface *ifp, int fd, void *data, size_t len,
+unsigned int *flags)
 {
 	ssize_t fl = (ssize_t)bpf_frame_header_len(ifp);
 	ssize_t bytes;
@@ -203,7 +204,7 @@ bpf_read(struct interface *ifp, int fd, 
 	struct bpf_hdr packet;
 	const char *payload;
 
-	*flags = 0;
+	*flags &= ~BPF_EOF;
 	for (;;) {
 		if (state->buffer_len == 0) {
 			bytes = read(fd, state->buffer, state->buffer_size);

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.5 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.6
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.5	Sat Oct  7 14:14:40 2017
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Wed Dec  6 10:35:05 2017
@@ -428,7 +428,6 @@ decode_rfc3442_rt(struct rt_head *routes
 
 		if ((rt = rt_new(ifp)) == NULL)
 			return -1;
-		TAILQ_INSERT_TAIL(routes, rt, rt_next);
 
 		/* If we have ocets then we have a destination and netmask */
 		dest.s_addr = 0;
@@ -461,6 +460,8 @@ decode_rfc3442_rt(struct rt_head *routes
 		/* If CIDR is 32 then it's a host route. */
 		if (cidr == 32)
 			rt->rt_flags = RTF_HOST;
+
+		TAILQ_INSERT_TAIL(routes, rt, rt_next);
 		n++;
 	}
 	return n;
@@ -1408,27 +1409,24 @@ dhcp_env(char **env, const char *prefix,
 			continue;
 		if (dhcp_getoverride(ifo, opt->option))
 			continue;
-		if ((p = get_option(ifp->ctx, bootp, bootp_len,
-		opt->option, )))
-		{
-			ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name,
-			opt, dhcp_getoption, p, pl);
-			if (opt->option == DHO_VIVSO &&
-			pl > (int)sizeof(uint32_t))
-			{
-			memcpy(, p, sizeof(en));
-en = ntohl(en);
-vo = vivso_find(en, ifp);
-if (vo) {
-	/* Skip over en + total size */
-	p += sizeof(en) + 1;
-	pl -= sizeof(en) + 1;
-	ep += dhcp_envoption(ifp->ctx,
-	ep, prefix, ifp->name,
-	vo, dhcp_getoption, p, pl);
-}
-			}
-		}
+		p = get_option(ifp->ctx, bootp, bootp_len, opt->option, );
+		if (p == NULL)
+			continue;
+		ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name,
+		opt, dhcp_getoption, p, pl);
+
+		if (opt->option != DHO_VIVSO || pl <= (int)sizeof(uint32_t))
+			continue;
+		memcpy(, p, sizeof(en));
+		en = ntohl(en);
+		vo = vivso_find(en, ifp);
+		if (vo == NULL)
+			continue;
+		/* Skip over en + total size */
+		p += sizeof(en) + 1;
+		pl -= sizeof(en) + 1;
+		ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name,
+		vo, dhcp_getoption, p, pl);
 	}
 
 	for (i = 0, opt = ifo->dhcp_override;
@@ -1437,10 +1435,11 @@ dhcp_env(char **env, const char *prefix,
 	{
 		if (has_option_mask(ifo->nomask, opt->option))
 			continue;
-		if ((p = get_option(ifp->ctx, bootp, bootp_len,
-		opt->option, )))
-			ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name,
-			opt, dhcp_getoption, p, pl);
+		p = get_option(ifp->ctx, bootp, bootp_len, opt->option, );
+		if (p == NULL)
+			continue;
+		ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name,
+		opt, dhcp_getoption, p, pl);
 	}
 
 	return ep - env;
@@ -1519,6 +1518,8 @@ static void
 dhcp_new_xid(struct interface *ifp)
 {
 	struct dhcp_state *state;
+	const struct interface *ifp1;
+	const struct dhcp_state *state1;
 
 	state = D_STATE(ifp);
 	if (ifp->options->options & DHCPCD_XID_HWADDR &&
@@ -1527,8 +1528,30 @@ dhcp_new_xid(struct interface *ifp)
 		memcpy(>xid,
 		(ifp->hwaddr + ifp->hwlen) - sizeof(state->xid),
 		sizeof(state->xid));
-	else
+	else {
+again:
 		state->xid = arc4random();
+	}
+
+	/* Ensure it's unique */
+	TAILQ_FOREACH(ifp1, ifp->ctx->ifaces, next) {
+		if (ifp == ifp1)
+			continue;
+		if ((state1 = D_CSTATE(ifp1)) == NULL)
+			continue;
+		if (state1->xid == state->xid)
+			break;
+	}
+	if (ifp1 != NULL) {
+		if (ifp->options->options & DHCPCD_XID_HWADDR &&
+		ifp->hwlen >= sizeof(state->xid))
+		{
+			logerrx("%s: duplicate xid on %s",
+			ifp->name, ifp1->name);
+			return;
+		}
+		goto again;
+	}
 
 	/* We can't do this when sharing leases across 

CVS commit: src/external/bsd/dhcpcd/dist/src/crypt

2017-10-08 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Oct  8 09:10:11 UTC 2017

Removed Files:
src/external/bsd/dhcpcd/dist/src/crypt: crypt.h hmac_md5.c

Log Message:
Cleanup


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/dhcpcd/dist/src/crypt/crypt.h \
src/external/bsd/dhcpcd/dist/src/crypt/hmac_md5.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/dhcpcd/dist/src

2017-10-07 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Oct  7 14:14:40 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c

Log Message:
Remove mistakenly commited debug.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/src/dhcp.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.4 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.5
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.4	Sat Oct  7 14:11:07 2017
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Sat Oct  7 14:14:40 2017
@@ -1487,7 +1487,6 @@ get_lease(struct interface *ifp,
 	if (get_option_uint32(ctx, >renewaltime,
 	bootp, len, DHO_RENEWALTIME) != 0)
 		lease->renewaltime = 0;
-	lease->renewaltime = 30;
 	if (get_option_uint32(ctx, >rebindtime,
 	bootp, len, DHO_REBINDTIME) != 0)
 		lease->rebindtime = 0;
@@ -2750,18 +2749,10 @@ dhcp_handledhcp(struct interface *ifp, s
 #endif
 
 	if (state->xid != ntohl(bootp->xid)) {
-		if (state->state != DHS_BOUND && state->state != DHS_NONE) {
+		if (state->state != DHS_BOUND && state->state != DHS_NONE)
 			logdebugx("%s: wrong xid 0x%x (expecting 0x%x) from %s",
 			ifp->name, ntohl(bootp->xid), state->xid,
 			inet_ntoa(*from));
-		char old[sizeof(state->leasefile)];
-
-		memcpy(old, state->leasefile, sizeof(old));
-		snprintf(state->leasefile, sizeof(state->leasefile), "/tmp/dhcpcd-wrongxid-0x%x.%d", state->xid, rand());
-		if (write_lease(ifp, bootp, bootp_len) == -1)
-			logerr(__func__);
-		memcpy(state->leasefile, old, sizeof(old));
-		}
 		dhcp_redirect_dhcp(ifp, bootp, bootp_len, from);
 		return;
 	}



CVS commit: src/external/bsd/dhcpcd

2017-10-07 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Oct  7 14:11:07 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c
src/external/bsd/dhcpcd/include: config.h
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
dhcpcd no longer needs hmac_md5.c


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.1 -r1.2 src/external/bsd/dhcpcd/include/config.h
cvs rdiff -u -r1.41 -r1.42 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.3 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.4
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.3	Tue Sep 19 19:19:21 2017
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Sat Oct  7 14:11:07 2017
@@ -1487,6 +1487,7 @@ get_lease(struct interface *ifp,
 	if (get_option_uint32(ctx, >renewaltime,
 	bootp, len, DHO_RENEWALTIME) != 0)
 		lease->renewaltime = 0;
+	lease->renewaltime = 30;
 	if (get_option_uint32(ctx, >rebindtime,
 	bootp, len, DHO_REBINDTIME) != 0)
 		lease->rebindtime = 0;
@@ -2749,10 +2750,18 @@ dhcp_handledhcp(struct interface *ifp, s
 #endif
 
 	if (state->xid != ntohl(bootp->xid)) {
-		if (state->state != DHS_BOUND && state->state != DHS_NONE)
+		if (state->state != DHS_BOUND && state->state != DHS_NONE) {
 			logdebugx("%s: wrong xid 0x%x (expecting 0x%x) from %s",
 			ifp->name, ntohl(bootp->xid), state->xid,
 			inet_ntoa(*from));
+		char old[sizeof(state->leasefile)];
+
+		memcpy(old, state->leasefile, sizeof(old));
+		snprintf(state->leasefile, sizeof(state->leasefile), "/tmp/dhcpcd-wrongxid-0x%x.%d", state->xid, rand());
+		if (write_lease(ifp, bootp, bootp_len) == -1)
+			logerr(__func__);
+		memcpy(state->leasefile, old, sizeof(old));
+		}
 		dhcp_redirect_dhcp(ifp, bootp, bootp_len, from);
 		return;
 	}

Index: src/external/bsd/dhcpcd/include/config.h
diff -u src/external/bsd/dhcpcd/include/config.h:1.1 src/external/bsd/dhcpcd/include/config.h:1.2
--- src/external/bsd/dhcpcd/include/config.h:1.1	Fri Mar 31 21:02:09 2017
+++ src/external/bsd/dhcpcd/include/config.h	Sat Oct  7 14:11:07 2017
@@ -10,7 +10,6 @@
 #define HAVE_IFADDRS_ADDRFLAGS
 #define HAVE_UTIL_H
 #define HAVE_SYS_QUEUE_H
-#define HAVE_SPAWN_H
 #define HAVE_REALLOCARRAY
 #define HAVE_KQUEUE
 #define HAVE_KQUEUE1

Index: src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.41 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.42
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.41	Fri Sep 15 12:02:00 2017
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Sat Oct  7 14:11:07 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.41 2017/09/15 12:02:00 roy Exp $
+# $NetBSD: Makefile,v 1.42 2017/10/07 14:11:07 roy Exp $
 #
 
 WARNS?=		6
@@ -26,7 +26,7 @@ DHCPCD_DEFS=	dhcpcd-definitions-small.co
 .else
 DHCPCD_DEFS=	dhcpcd-definitions.conf
 CPPFLAGS+=	-DAUTH
-SRCS+=		auth.c hmac_md5.c
+SRCS+=		auth.c
 .endif
 
 .if (${USE_INET} != "no")



CVS commit: src/external/bsd/dhcpcd/dist

2017-09-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Sep 19 19:19:21 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist: .gitignore
src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcpcd.c if-options.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcpcd/dist/.gitignore
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcpcd/dist/src/bpf.c
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/src/dhcpcd.c \
src/external/bsd/dhcpcd/dist/src/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/.gitignore
diff -u src/external/bsd/dhcpcd/dist/.gitignore:1.3 src/external/bsd/dhcpcd/dist/.gitignore:1.4
--- src/external/bsd/dhcpcd/dist/.gitignore:1.3	Fri Mar 31 20:53:55 2017
+++ src/external/bsd/dhcpcd/dist/.gitignore	Tue Sep 19 19:19:21 2017
@@ -24,5 +24,8 @@ hooks/50-ypbind
 # Ignore distribution
 dhcpcd*.xz*
 
+# Ignore swap files
+*.swp
+
 # Ignore Coverity
 cov-int

Index: src/external/bsd/dhcpcd/dist/src/bpf.c
diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.3 src/external/bsd/dhcpcd/dist/src/bpf.c:1.4
--- src/external/bsd/dhcpcd/dist/src/bpf.c:1.3	Fri Apr 14 09:56:32 2017
+++ src/external/bsd/dhcpcd/dist/src/bpf.c	Tue Sep 19 19:19:21 2017
@@ -166,7 +166,9 @@ bpf_open(struct interface *ifp, int (*fi
 	if (ioctl(fd, BIOCGBLEN, _len) == -1)
 		goto eexit;
 	buf_len = (size_t)ibuf_len;
-	state = IPV4_STATE(ifp);
+	state = ipv4_getstate(ifp);
+	if (state == NULL)
+		goto eexit;
 	if (state->buffer_size != buf_len) {
 		void *nb;
 
@@ -241,7 +243,7 @@ next:
 			return bytes;
 	}
 
-	return bytes;
+	/* NOTREACHED */
 }
 
 int
@@ -295,6 +297,9 @@ bpf_close(struct interface *ifp, int fd)
 	return close(fd);
 }
 
+/* Normally this is needed by bootp.
+ * Once that uses this again, the ARP guard here can be removed. */
+#ifdef ARP
 static unsigned int
 bpf_cmp_hwaddr(struct bpf_insn *bpf, size_t bpf_len, size_t off,
 bool equal, uint8_t *hwaddr, size_t hwaddr_len)
@@ -378,6 +383,7 @@ bpf_cmp_hwaddr(struct bpf_insn *bpf, siz
 
 	return (unsigned int)(bp - bpf);
 }
+#endif
 
 #ifdef ARP
 
@@ -589,6 +595,7 @@ static const struct bpf_insn bpf_bootp_f
 	BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, BOOTREPLY, 1, 0),
 	BPF_STMT(BPF_RET + BPF_K, 0),
 };
+
 #define BPF_BOOTP_FILTER_LEN	__arraycount(bpf_bootp_filter)
 #define BPF_BOOTP_CHADDR_LEN	((BOOTP_CHADDR_LEN / 4) * 3)
 #define	BPF_BOOTP_XID_LEN	4 /* BOUND check is 4 instructions */
@@ -599,7 +606,9 @@ static const struct bpf_insn bpf_bootp_f
 int
 bpf_bootp(struct interface *ifp, int fd)
 {
+#if 0
 	const struct dhcp_state *state = D_CSTATE(ifp);
+#endif
 	struct bpf_insn bpf[BPF_BOOTP_LEN];
 	struct bpf_insn *bp;
 
@@ -622,6 +631,8 @@ bpf_bootp(struct interface *ifp, int fd)
 	memcpy(bp, bpf_bootp_filter, sizeof(bpf_bootp_filter));
 	bp += BPF_BOOTP_FILTER_LEN;
 
+	/* These checks won't work when same IP exists on other interfaces. */
+#if 0
 	if (ifp->hwlen <= sizeof(((struct bootp *)0)->chaddr))
 		bp += bpf_cmp_hwaddr(bp, BPF_BOOTP_CHADDR_LEN,
 		 offsetof(struct bootp, chaddr),
@@ -654,6 +665,7 @@ bpf_bootp(struct interface *ifp, int fd)
 		BPF_SET_STMT(bp, BPF_RET + BPF_K, 0);
 		bp++;
 	}
+#endif
 
 	/* All passed, return the packet
 	 * (Frame length in M0, IP length in M2). */

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.2 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.3
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.2	Tue Sep  5 11:58:55 2017
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Tue Sep 19 19:19:21 2017
@@ -118,10 +118,13 @@ static const char * const dhcp_params[] 
 	NULL
 };
 
-static int dhcp_open(struct interface *);
+static int dhcp_openbpf(struct interface *);
 #ifdef ARP
 static void dhcp_arp_conflicted(struct arp_state *, const struct arp_msg *);
 #endif
+static void dhcp_handledhcp(struct interface *, struct bootp *, size_t,
+const struct in_addr *);
+static int dhcp_initstate(struct interface *);
 
 void
 dhcp_printoptions(const struct dhcpcd_ctx *ctx,
@@ -483,7 +486,7 @@ decode_rfc3361(const uint8_t *data, size
 	switch (enc) {
 	case 0:
 		if ((r = decode_rfc1035(NULL, 0, data, dl)) > 0) {
-			l = (size_t)r;
+			l = (size_t)r + 1;
 			sip = malloc(l);
 			if (sip == NULL)
 return 0;
@@ -697,7 +700,7 @@ dhcp_get_routes(struct rt_head *routes, 
 {
 	const struct dhcp_state *state;
 
-	if ((state = D_CSTATE(ifp)) == NULL || state->state != DHS_BOUND)
+	if ((state = D_CSTATE(ifp)) == NULL || !(state->added & STATE_ADDED))
 		return 0;
 	return get_option_routes(routes, ifp, state->new, state->new_len);
 }
@@ -1527,11 +1530,14 @@ dhcp_new_xid(struct interface *ifp)
 	else
 		state->xid = arc4random();
 
+	/* We can't do this when sharing leases across interfaes */
+#if 0
 	/* As the XID changes, re-apply the filter. 

CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2017-09-15 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Sep 15 12:02:00 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
build dhcpcd with ARPING support for non small builds.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.40 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.41
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.40	Fri Apr 14 10:00:06 2017
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Fri Sep 15 12:02:00 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.40 2017/04/14 10:00:06 roy Exp $
+# $NetBSD: Makefile,v 1.41 2017/09/15 12:02:00 roy Exp $
 #
 
 WARNS?=		6
@@ -33,7 +33,7 @@ SRCS+=		auth.c hmac_md5.c
 CPPFLAGS+=	-DARP -DINET
 SRCS+=		arp.c bpf.c dhcp.c ipv4.c
 .if !defined(SMALLPROG)
-CPPFLAGS+=	-DIPV4LL
+CPPFLAGS+=	-DIPV4LL -DARPING
 SRCS+=		ipv4ll.c
 .endif
 .endif



CVS commit: src/external/bsd/dhcpcd/dist/src

2017-09-05 Thread Benny Siegert
Module Name:src
Committed By:   bsiegert
Date:   Tue Sep  5 11:58:55 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c

Log Message:
dhcp: Fix classless static routes

Assign the netwask correctly from the message.

Cherry-picked from upstream in
https://dev.marples.name/rDHC510c760cb24ef4b1b16cc14732c5ffe0fbb0d96d.

This fixes route assignments when running on Google Compute Engine,
which uses classless static routes.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.3 -r1.2 src/external/bsd/dhcpcd/dist/src/dhcp.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.1.1.3 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.2
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.1.1.3	Fri Apr 14 09:53:07 2017
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Tue Sep  5 11:58:55 2017
@@ -452,7 +452,7 @@ decode_rfc3442_rt(struct rt_head *routes
 		}
 
 		sa_in_init(>rt_dest, );
-		sa_in_init(>rt_dest, );
+		sa_in_init(>rt_netmask, );
 		sa_in_init(>rt_gateway, );
 
 		/* If CIDR is 32 then it's a host route. */



CVS commit: src/external/bsd/dhcpcd/sbin

2017-06-12 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jun 13 00:28:10 UTC 2017

Added Files:
src/external/bsd/dhcpcd/sbin: Makefile.inc

Log Message:
Restore Makefile.inc so dhcpcd is installed correctly as pointed out by kre@.
This reverts my prior commit.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.5 src/external/bsd/dhcpcd/sbin/Makefile.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/external/bsd/dhcpcd/sbin/Makefile.inc
diff -u /dev/null src/external/bsd/dhcpcd/sbin/Makefile.inc:1.5
--- /dev/null	Tue Jun 13 00:28:10 2017
+++ src/external/bsd/dhcpcd/sbin/Makefile.inc	Tue Jun 13 00:28:10 2017
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile.inc,v 1.5 2017/06/13 00:28:10 roy Exp $
+
+.include 		# for MKDYNAMICROOT definition
+
+WARNS?=		5
+BINDIR=		/sbin
+
+.if (${MKDYNAMICROOT} == "no")
+LDSTATIC?=	-static
+.endif



CVS commit: src/external/bsd/dhcpcd/sbin

2017-06-12 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Jun 12 14:52:02 UTC 2017

Removed Files:
src/external/bsd/dhcpcd/sbin: Makefile.inc

Log Message:
This Makefile fragment is no longer used.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r0 src/external/bsd/dhcpcd/sbin/Makefile.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/dhcpcd

2017-06-12 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Jun 12 14:50:38 UTC 2017

Modified Files:
src/external/bsd/dhcpcd: Makefile.inc

Log Message:
Replace @DATADIR@ with /usr/share/examples as pointed by plunky@


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/bsd/dhcpcd/Makefile.inc

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/Makefile.inc
diff -u src/external/bsd/dhcpcd/Makefile.inc:1.1 src/external/bsd/dhcpcd/Makefile.inc:1.2
--- src/external/bsd/dhcpcd/Makefile.inc:1.1	Fri Mar 31 21:02:08 2017
+++ src/external/bsd/dhcpcd/Makefile.inc	Mon Jun 12 14:50:38 2017
@@ -1,9 +1,10 @@
-# $NetBSD: Makefile.inc,v 1.1 2017/03/31 21:02:08 roy Exp $
+# $NetBSD: Makefile.inc,v 1.2 2017/06/12 14:50:38 roy Exp $
 
 SRCDIR=		${NETBSDSRCDIR}/external/bsd/dhcpcd
 DIST=		${SRCDIR}/dist
 
 SED_SYS=	-e 's:@SYSCONFDIR@:/etc:g' \
+		-e 's:@DATADIR@:/usr/share/examples:g' \
 		-e 's:@DBDIR@:/var/db:g' \
 		-e 's:@LIBDIR@:/lib:g' \
 		-e 's:@RUNDIR@:/var/run:g' \



CVS commit: src/external/bsd/dhcpcd/dist/src

2017-05-10 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed May 10 11:03:44 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcpcd.c if-options.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcpcd/dist/src/dhcpcd.c \
src/external/bsd/dhcpcd/dist/src/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/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.3 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.4
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.3	Fri Apr 14 09:56:32 2017
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Wed May 10 11:03:44 2017
@@ -477,6 +477,10 @@ configure_interface1(struct interface *i
 		 * between reboots without persitent storage,
 		 * generating the IAID from the MAC address is the only
 		 * logical default.
+		 * Saying that, if a VLANID has been specified then we
+		 * can use that. It's possible that different interfaces
+		 * can have the same VLANID, but this is no worse than
+		 * generating the IAID from the duplicate MAC address.
 		 *
 		 * dhclient uses the last 4 bytes of the MAC address.
 		 * dibbler uses an increamenting counter.
@@ -487,11 +491,18 @@ configure_interface1(struct interface *i
 		 * dhcpcd-6.1.0 and earlier used the interface name,
 		 * falling back to interface index if name > 4.
 		 */
-		if (ifp->hwlen >= sizeof(ifo->iaid))
+		if (ifp->vlanid != 0) {
+			uint32_t vlanid;
+
+			/* Maximal VLANID is 4095, so prefix with 0xff
+			 * so we don't conflict with an interface index. */
+			vlanid = htonl(ifp->vlanid | 0xff00);
+			memcpy(ifo->iaid, , sizeof(vlanid));
+		} else if (ifp->hwlen >= sizeof(ifo->iaid)) {
 			memcpy(ifo->iaid,
 			ifp->hwaddr + ifp->hwlen - sizeof(ifo->iaid),
 			sizeof(ifo->iaid));
-		else {
+		} else {
 			uint32_t len;
 
 			len = (uint32_t)strlen(ifp->name);
@@ -503,7 +514,7 @@ configure_interface1(struct interface *i
 			} else {
 /* IAID is the same size as a uint32_t */
 len = htonl(ifp->index);
-memcpy(ifo->iaid, , sizeof(len));
+memcpy(ifo->iaid, , sizeof(ifo->iaid));
 			}
 		}
 		ifo->options |= DHCPCD_IAID;
@@ -775,7 +786,7 @@ warn_iaid_conflict(struct interface *ifp
 
 	/* This is only a problem if the interfaces are on the same network. */
 	if (ifn)
-		logerr("%s: IAID conflicts with one assigned to %s",
+		logerrx("%s: IAID conflicts with one assigned to %s",
 		ifp->name, ifn->name);
 }
 
@@ -1510,6 +1521,7 @@ main(int argc, char **argv)
 #endif
 		case 'P':
 			ctx.options |= DHCPCD_PRINT_PIDFILE;
+			logopts &= ~(LOGERR_LOG | LOGERR_ERR);
 			break;
 		case 'T':
 			i = 1;
@@ -1603,10 +1615,12 @@ printpidfile:
 		 *  instance for that interface. */
 		if (optind == argc - 1 && !(ctx.options & DHCPCD_MASTER)) {
 			const char *per;
+			const char *ifname;
 
-			if (strlen(argv[optind]) > IF_NAMESIZE) {
-logerrx("%s: interface name too long",
-argv[optind]);
+			ifname = *ctx.ifv;
+			if (ifname == NULL || strlen(ifname) > IF_NAMESIZE) {
+errno = ifname == NULL ? EINVAL : E2BIG;
+logerr("%s: ", ifname);
 goto exit_failure;
 			}
 			/* Allow a dhcpcd interface per address family */
@@ -1621,7 +1635,7 @@ printpidfile:
 per = "";
 			}
 			snprintf(ctx.pidfile, sizeof(ctx.pidfile),
-			PIDFILE, "-", argv[optind], per);
+			PIDFILE, "-", ifname, per);
 		} else {
 			snprintf(ctx.pidfile, sizeof(ctx.pidfile),
 			PIDFILE, "", "", "");
@@ -1643,20 +1657,13 @@ printpidfile:
 		goto exit_failure;
 	}
 
-	/* Open our persistent sockets.
-	 * This is needed early for dumping leases on valid interfaces. */
-#ifdef USE_SIGNALS
-	if (sig == 0) {
-#endif
+	if (ctx.options & DHCPCD_DUMPLEASE) {
+		/* Open sockets so we can dump something about
+		 * valid interfaces. */
 		if (if_opensockets() == -1) {
 			logerr("%s: if_opensockets", __func__);
 			goto exit_failure;
 		}
-#ifdef USE_SIGNALS
-	}
-#endif
-
-	if (ctx.options & DHCPCD_DUMPLEASE) {
 		if (optind != argc) {
 			/* We need to try and find the interface so we can load
 			 * the hardware address to compare automated IAID */
@@ -1803,6 +1810,12 @@ printpidfile:
 
 	logdebugx(PACKAGE "-" VERSION " starting");
 	ctx.options |= DHCPCD_STARTED;
+
+	if (if_opensockets() == -1) {
+		logerr("%s: if_opensockets", __func__);
+		goto exit_failure;
+	}
+
 #ifdef USE_SIGNALS
 	if (eloop_signal_set_cb(ctx.eloop,
 	dhcpcd_signals, dhcpcd_signals_len,
Index: src/external/bsd/dhcpcd/dist/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.3 src/external/bsd/dhcpcd/dist/src/if-options.c:1.4
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.3	Fri Apr 14 09:56:32 2017
+++ src/external/bsd/dhcpcd/dist/src/if-options.c	Wed May 10 11:03:44 2017
@@ -93,7 +93,7 @@
 #define O_IPV6			O_BASE + 33
 #define O_CONTROLGRP		O_BASE + 34
 #define O_SLAAC			O_BASE + 35
-// unused			O_BASE + 

CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2017-04-14 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 14 10:00:06 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
Build logerr support.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.39 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.40
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.39	Fri Apr 14 07:55:55 2017
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Fri Apr 14 10:00:06 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.39 2017/04/14 07:55:55 roy Exp $
+# $NetBSD: Makefile,v 1.40 2017/04/14 10:00:06 roy Exp $
 #
 
 WARNS?=		6
@@ -8,7 +8,7 @@ USE_FORT?=	yes	# network client (local s
 .include "../../Makefile.inc"
 
 PROG=		dhcpcd
-SRCS=		common.c control.c dhcpcd.c duid.c eloop.c
+SRCS=		common.c control.c dhcpcd.c duid.c eloop.c logerr.c
 SRCS+=		if.c if-options.c route.c sa.c script.c
 SRCS+=		dhcp-common.c dhcpcd-embedded.c
 SRCS+=		if-bsd.c



CVS commit: src/external/bsd/dhcpcd/dist

2017-04-14 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 14 09:56:32 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist/src: bpf.c dhcpcd.c if-options.c
Removed Files:
src/external/bsd/dhcpcd/dist/test: GNUmakefile Makefile test.c test.h
test_hmac_md5.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/dhcpcd/dist/src/bpf.c \
src/external/bsd/dhcpcd/dist/src/dhcpcd.c \
src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/dhcpcd/dist/test/GNUmakefile \
src/external/bsd/dhcpcd/dist/test/Makefile \
src/external/bsd/dhcpcd/dist/test/test.c \
src/external/bsd/dhcpcd/dist/test/test.h \
src/external/bsd/dhcpcd/dist/test/test_hmac_md5.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/src/bpf.c
diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.2 src/external/bsd/dhcpcd/dist/src/bpf.c:1.3
--- src/external/bsd/dhcpcd/dist/src/bpf.c:1.2	Mon Apr  3 00:42:20 2017
+++ src/external/bsd/dhcpcd/dist/src/bpf.c	Fri Apr 14 09:56:32 2017
@@ -48,13 +48,13 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "common.h"
 #include "arp.h"
 #include "bpf.h"
 #include "dhcp.h"
 #include "if.h"
+#include "logerr.h"
 
 #define	ARP_ADDRS_MAX	3
 
@@ -150,7 +150,7 @@ bpf_open(struct interface *ifp, int (*fi
 		goto eexit;
 	if (pv.bv_major != BPF_MAJOR_VERSION ||
 	pv.bv_minor < BPF_MINOR_VERSION) {
-		syslog(LOG_ERR, "BPF version mismatch - recompile");
+		logerrx("BPF version mismatch - recompile");
 		goto eexit;
 	}
 
@@ -174,7 +174,6 @@ bpf_open(struct interface *ifp, int (*fi
 			goto eexit;
 		state->buffer = nb;
 		state->buffer_size = buf_len;
-		state->buffer_len = state->buffer_pos = 0;
 	}
 
 #ifdef BIOCIMMEDIATE
@@ -222,8 +221,6 @@ bpf_read(struct interface *ifp, int fd, 
 		bytes = -1;
 		memcpy(, state->buffer + state->buffer_pos,
 		sizeof(packet));
-		if (packet.bh_caplen != packet.bh_datalen)
-			goto next; /* Incomplete packet, drop. */
 		if (state->buffer_pos + packet.bh_caplen + packet.bh_hdrlen >
 		state->buffer_len)
 			goto next; /* Packet beyond buffer, drop. */
@@ -288,6 +285,16 @@ bpf_send(const struct interface *ifp, in
 }
 #endif
 
+int
+bpf_close(struct interface *ifp, int fd)
+{
+	struct ipv4_state *state = IPV4_STATE(ifp);
+
+	/* Rewind the buffer on closing. */
+	state->buffer_len = state->buffer_pos = 0;
+	return close(fd);
+}
+
 static unsigned int
 bpf_cmp_hwaddr(struct bpf_insn *bpf, size_t bpf_len, size_t off,
 bool equal, uint8_t *hwaddr, size_t hwaddr_len)
@@ -428,6 +435,7 @@ bpf_arp(struct interface *ifp, int fd)
 	struct bpf_insn bpf[3+ bpf_arp_filter_len + bpf_arp_hw + bpf_arp_extra];
 	struct bpf_insn *bp;
 	struct iarp_state *state;
+	uint16_t arp_len;
 
 	if (fd == -1)
 		return 0;
@@ -438,6 +446,7 @@ bpf_arp(struct interface *ifp, int fd)
 	case ARPHRD_ETHER:
 		memcpy(bp, bpf_arp_ether, sizeof(bpf_arp_ether));
 		bp += bpf_arp_ether_len;
+		arp_len = sizeof(struct ether_header)+sizeof(struct ether_arp);
 		break;
 	default:
 		errno = EINVAL;
@@ -465,13 +474,13 @@ bpf_arp(struct interface *ifp, int fd)
 		TAILQ_FOREACH(astate, >arp_states, next) {
 			if (++naddrs > ARP_ADDRS_MAX) {
 errno = ENOBUFS;
-syslog(LOG_ERR, "%s: %m", __func__);
+logerr(__func__);
 break;
 			}
 			BPF_SET_JUMP(bp, BPF_JMP + BPF_JEQ + BPF_K,
 			 htonl(astate->addr.s_addr), 0, 1);
 			bp++;
-			BPF_SET_STMT(bp, BPF_RET + BPF_K, BPF_WHOLEPACKET);
+			BPF_SET_STMT(bp, BPF_RET + BPF_K, arp_len);
 			bp++;
 		}
 
@@ -496,8 +505,7 @@ bpf_arp(struct interface *ifp, int fd)
 			BPF_SET_JUMP(bp, BPF_JMP + BPF_JEQ + BPF_K,
 			 htonl(astate->addr.s_addr), 0, 1);
 			bp++;
-			BPF_SET_STMT(bp, BPF_RET + BPF_K,
-			 BPF_WHOLEPACKET);
+			BPF_SET_STMT(bp, BPF_RET + BPF_K, arp_len);
 			bp++;
 		}
 
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.2 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.3
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.2	Thu Apr  6 14:00:34 2017
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Fri Apr 14 09:56:32 2017
@@ -44,7 +44,6 @@ const char dhcpcd_copyright[] = "Copyrig
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -63,6 +62,7 @@ const char dhcpcd_copyright[] = "Copyrig
 #include "ipv4ll.h"
 #include "ipv6.h"
 #include "ipv6nd.h"
+#include "logerr.h"
 #include "script.h"
 
 #ifdef HAVE_UTIL_H
@@ -173,7 +173,7 @@ handle_exit_timeout(void *arg)
 	struct dhcpcd_ctx *ctx;
 
 	ctx = arg;
-	syslog(LOG_ERR, "timed out");
+	logerrx("timed out");
 	if (!(ctx->options & DHCPCD_MASTER)) {
 		eloop_exit(ctx->eloop, EXIT_FAILURE);
 		return;
@@ -258,16 +258,14 @@ dhcpcd_ipwaited(struct dhcpcd_ctx *ctx)
 
 	TAILQ_FOREACH(ifp, ctx->ifaces, next) {
 		if ((af = dhcpcd_ifafwaiting(ifp)) != AF_MAX) {
-			

CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2017-04-14 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 14 07:55:55 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
Generate dhcpcd-embedded.c for dependencies too.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.38 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.39
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.38	Thu Apr 13 18:12:32 2017
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Fri Apr 14 07:55:55 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.38 2017/04/13 18:12:32 roy Exp $
+# $NetBSD: Makefile,v 1.39 2017/04/14 07:55:55 roy Exp $
 #
 
 WARNS?=		6
@@ -14,7 +14,7 @@ SRCS+=		dhcp-common.c dhcpcd-embedded.c
 SRCS+=		if-bsd.c
 
 # Need to generate this for dependencies
-DPSRCS+=	dhcpcd-embedded.h
+DPSRCS+=	dhcpcd-embedded.h dhcpcd-embedded.c
 
 CPPFLAGS+=	-DHAVE_CONFIG_H -D_OPENBSD_SOURCE
 



CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2017-04-13 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Apr 13 18:12:32 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
Add dhcpcd-embedded.h to DPSRCS to ensure it exists when generating 
dependencies.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.37 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.38
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.37	Sun Apr  2 20:17:11 2017
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Thu Apr 13 18:12:32 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.37 2017/04/02 20:17:11 roy Exp $
+# $NetBSD: Makefile,v 1.38 2017/04/13 18:12:32 roy Exp $
 #
 
 WARNS?=		6
@@ -13,6 +13,9 @@ SRCS+=		if.c if-options.c route.c sa.c s
 SRCS+=		dhcp-common.c dhcpcd-embedded.c
 SRCS+=		if-bsd.c
 
+# Need to generate this for dependencies
+DPSRCS+=	dhcpcd-embedded.h
+
 CPPFLAGS+=	-DHAVE_CONFIG_H -D_OPENBSD_SOURCE
 
 USE_INET?=	yes
@@ -64,8 +67,6 @@ dhcpcd-embedded.h:	genembedh ${DHCPCD_DE
 dhcpcd-embedded.c:	genembedc ${DHCPCD_DEFS} dhcpcd-embedded.c.in
 	${HOST_SH} ${.ALLSRC} $^ > $@
 
-if-options.c:		dhcpcd-embedded.h
-
 CLEANFILES+=		dhcpcd-embedded.c dhcpcd-embedded.h
 
 .for f in dhcpcd.conf.5 dhcpcd.8



CVS commit: src/external/bsd/dhcpcd/dist/src

2017-04-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr  6 14:01:27 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist/src: if-options.c

Log Message:
The last stderr message felt lonely and committed suicide.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/dhcpcd/dist/src/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/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.1.1.1 src/external/bsd/dhcpcd/dist/src/if-options.c:1.2
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.1.1.1	Fri Mar 31 16:51:16 2017
+++ src/external/bsd/dhcpcd/dist/src/if-options.c	Thu Apr  6 10:01:27 2017
@@ -2138,8 +2138,8 @@ parse_config_line(struct dhcpcd_ctx *ctx
 			continue;
 
 		if (cf_options[i].has_arg == required_argument && !line) {
-			fprintf(stderr,
-			PACKAGE ": option requires an argument -- %s\n",
+			syslog(LOG_ERR,
+			PACKAGE ": option requires an argument -- %s",
 			opt);
 			return -1;
 		}



CVS commit: src/external/bsd/dhcpcd/dist/src

2017-04-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr  6 14:00:34 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcpcd.c

Log Message:
transposition police!


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/dhcpcd/dist/src/dhcpcd.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/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.1.1.1 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.2
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.1.1.1	Fri Mar 31 16:51:15 2017
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Thu Apr  6 10:00:34 2017
@@ -1494,7 +1494,7 @@ main(int argc, char **argv)
 #ifdef USE_SIGNALS
 		case 'k':
 			sig = SIGALRM;
-			siga = "ARLM";
+			siga = "ALRM";
 			break;
 		case 'n':
 			sig = SIGHUP;



CVS commit: src/external/bsd/dhcpcd/dist

2017-04-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr  5 21:26:30 UTC 2017

Removed Files:
src/external/bsd/dhcpcd/dist: auth.c

Log Message:
delete extra file


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r0 src/external/bsd/dhcpcd/dist/auth.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/dhcpcd/dist/src

2017-04-02 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Apr  3 00:42:20 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist/src: bpf.c

Log Message:
Try to fix build of dhcpcd (bpf.c) - violation of stack protector (GCC)

Patch obtained from 


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 src/external/bsd/dhcpcd/dist/src/bpf.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/src/bpf.c
diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.1.1.2 src/external/bsd/dhcpcd/dist/src/bpf.c:1.2
--- src/external/bsd/dhcpcd/dist/src/bpf.c:1.1.1.2	Sun Apr  2 18:54:20 2017
+++ src/external/bsd/dhcpcd/dist/src/bpf.c	Mon Apr  3 00:42:20 2017
@@ -419,13 +419,13 @@ static const struct bpf_insn bpf_arp_fil
 	BPF_STMT(BPF_RET + BPF_K, 0),
 };
 #define bpf_arp_filter_len	__arraycount(bpf_arp_filter)
-#define bpf_arp_extra		(((ARP_ADDRS_MAX + 1) * 2) * 2) + 2
+#define bpf_arp_extra		ARP_ADDRS_MAX + 1) * 2) * 2) + 2)
+#define bpf_arp_hw		HWADDR_LEN / 4) + 2) * 2) + 1)
 
 int
 bpf_arp(struct interface *ifp, int fd)
 {
-	size_t bpf_hw = (((sizeof(ifp->hwaddr) / 4) + 2) * 2) + 1;
-	struct bpf_insn bpf[3 + bpf_arp_filter_len + bpf_hw + bpf_arp_extra];
+	struct bpf_insn bpf[3+ bpf_arp_filter_len + bpf_arp_hw + bpf_arp_extra];
 	struct bpf_insn *bp;
 	struct iarp_state *state;
 
@@ -449,7 +449,7 @@ bpf_arp(struct interface *ifp, int fd)
 	bp += bpf_arp_filter_len;
 
 	/* Ensure it's not from us. */
-	bp += bpf_cmp_hwaddr(bp, bpf_hw, sizeof(struct arphdr),
+	bp += bpf_cmp_hwaddr(bp, bpf_arp_hw, sizeof(struct arphdr),
 	 false, ifp->hwaddr, ifp->hwlen);
 
 	state = ARP_STATE(ifp);



CVS commit: src/external/bsd/dhcpcd

2017-04-02 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Apr  2 20:18:38 UTC 2017

Modified Files:
src/external/bsd/dhcpcd: Makefile
src/external/bsd/dhcpcd/libexec/dhcpcd-hooks: Makefile
Added Files:
src/external/bsd/dhcpcd/examples: Makefile
src/external/bsd/dhcpcd/examples/hooks: Makefile

Log Message:
Let's make things easier and split the example hooks out into
a new Makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/dhcpcd/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/dhcpcd/examples/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/dhcpcd/examples/hooks/Makefile
cvs rdiff -u -r1.2 -r1.3 \
src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile

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/Makefile
diff -u src/external/bsd/dhcpcd/Makefile:1.2 src/external/bsd/dhcpcd/Makefile:1.3
--- src/external/bsd/dhcpcd/Makefile:1.2	Fri Mar 31 21:02:08 2017
+++ src/external/bsd/dhcpcd/Makefile	Sun Apr  2 20:18:37 2017
@@ -1,5 +1,5 @@
-#	$NetBSD: Makefile,v 1.2 2017/03/31 21:02:08 roy Exp $
+#	$NetBSD: Makefile,v 1.3 2017/04/02 20:18:37 roy Exp $
 
-SUBDIR=		sbin libexec
+SUBDIR=		sbin libexec examples
 
 .include 

Index: src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile
diff -u src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile:1.2 src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile:1.3
--- src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile:1.2	Sat Apr  1 19:02:58 2017
+++ src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile	Sun Apr  2 20:18:38 2017
@@ -1,36 +1,15 @@
-# $NetBSD: Makefile,v 1.2 2017/04/01 19:02:58 roy Exp $
+# $NetBSD: Makefile,v 1.3 2017/04/02 20:18:38 roy Exp $
 #
 
 .include 
 
 .include "../../Makefile.inc"
-HOOKSRC=		${DIST}/hooks
-.PATH:			${HOOKSRC} ${OBJDIR}
 
-HOOKS=			01-test 02-dump 20-resolv.conf 30-hostname
-HOOKS+=			50-ntp.conf
+.PATH:			${DIST}/hooks
 
-FILES=			${HOOKS:C,^,${HOOKSRC}/,}
-FILESDIR=		/libexec/dhcpcd-hooks
-
-EGHOOKS=		10-wpa_supplicant 15-timezone 29-lookup-hostname
-MKEGHOOKS=		50-ypbind
-CLEANFILES+=		50-ypbind
-
-.if ${MKSHARE} != "no"
-EGFILES=		${EGHOOKS:C,^,${HOOKSRC}/,}
-EGFILES+=		${MKEGHOOKS:C,^,${.OBJDIR}/,}
-FILES+=			${EGFILES}
-.for f in ${EGFILES}
-FILESDIR_${f}=		/usr/share/examples/dhcpcd/hooks
-.endfor
-.endif
-
-.SUFFIXES:		.in
+FILES=			01-test 02-dump 20-resolv.conf 30-hostname
+FILES+=			50-ntp.conf
 
-all:	${HOOKS} ${EGHOOKS} ${MKEGHOOKS}
-
-.in:	../../Makefile.inc
-	${TOOL_SED} ${SED_SYS} $< > $@
+FILESDIR=		/libexec/dhcpcd-hooks
 
 .include 

Added files:

Index: src/external/bsd/dhcpcd/examples/Makefile
diff -u /dev/null src/external/bsd/dhcpcd/examples/Makefile:1.1
--- /dev/null	Sun Apr  2 20:18:38 2017
+++ src/external/bsd/dhcpcd/examples/Makefile	Sun Apr  2 20:18:37 2017
@@ -0,0 +1,5 @@
+#	$NetBSD: Makefile,v 1.1 2017/04/02 20:18:37 roy Exp $
+
+SUBDIR=		hooks
+
+.include 

Index: src/external/bsd/dhcpcd/examples/hooks/Makefile
diff -u /dev/null src/external/bsd/dhcpcd/examples/hooks/Makefile:1.1
--- /dev/null	Sun Apr  2 20:18:38 2017
+++ src/external/bsd/dhcpcd/examples/hooks/Makefile	Sun Apr  2 20:18:37 2017
@@ -0,0 +1,24 @@
+# $NetBSD: Makefile,v 1.1 2017/04/02 20:18:37 roy Exp $
+#
+
+.include 
+
+.include "../../Makefile.inc"
+.PATH:			${DIST}/hooks
+
+.if ${MKSHARE} != "no"
+FILES=			10-wpa_supplicant 15-timezone 29-lookup-hostname
+FILES+=			50-ypbind
+
+FILESBUILD_50-ypbind=	YES
+CLEANFILES+=		50-ypbind
+
+FILESDIR=		/usr/share/examples/dhcpcd/hooks
+
+.SUFFIXES:		.in
+
+.in:	../../Makefile.inc
+	${TOOL_SED} ${SED_SYS} $< > $@
+.endif
+
+.include 



CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2017-04-02 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Apr  2 20:17:11 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
No more need to disable stack protector


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.36 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.37
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.36	Fri Mar 31 23:50:01 2017
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Sun Apr  2 20:17:11 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.36 2017/03/31 23:50:01 kamil Exp $
+# $NetBSD: Makefile,v 1.37 2017/04/02 20:17:11 roy Exp $
 #
 
 WARNS?=		6
@@ -29,7 +29,6 @@ SRCS+=		auth.c hmac_md5.c
 .if (${USE_INET} != "no")
 CPPFLAGS+=	-DARP -DINET
 SRCS+=		arp.c bpf.c dhcp.c ipv4.c
-COPTS.bpf.c+=	-Wno-stack-protector
 .if !defined(SMALLPROG)
 CPPFLAGS+=	-DIPV4LL
 SRCS+=		ipv4ll.c



CVS commit: src/external/bsd/dhcpcd/libexec/dhcpcd-hooks

2017-04-01 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Apr  1 19:02:58 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/libexec/dhcpcd-hooks: Makefile

Log Message:
Fix building 50-ypbind


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile

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/libexec/dhcpcd-hooks/Makefile
diff -u src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile:1.1 src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile:1.2
--- src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile:1.1	Fri Mar 31 21:02:09 2017
+++ src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile	Sat Apr  1 19:02:58 2017
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile,v 1.1 2017/03/31 21:02:09 roy Exp $
+# $NetBSD: Makefile,v 1.2 2017/04/01 19:02:58 roy Exp $
 #
 
 .include 
 
 .include "../../Makefile.inc"
 HOOKSRC=		${DIST}/hooks
-.PATH:			${HOOKSRC}
+.PATH:			${HOOKSRC} ${OBJDIR}
 
 HOOKS=			01-test 02-dump 20-resolv.conf 30-hostname
 HOOKS+=			50-ntp.conf
@@ -14,14 +14,23 @@ FILES=			${HOOKS:C,^,${HOOKSRC}/,}
 FILESDIR=		/libexec/dhcpcd-hooks
 
 EGHOOKS=		10-wpa_supplicant 15-timezone 29-lookup-hostname
-EGHOOKS+=		50-ypbind
+MKEGHOOKS=		50-ypbind
+CLEANFILES+=		50-ypbind
 
 .if ${MKSHARE} != "no"
 EGFILES=		${EGHOOKS:C,^,${HOOKSRC}/,}
+EGFILES+=		${MKEGHOOKS:C,^,${.OBJDIR}/,}
 FILES+=			${EGFILES}
 .for f in ${EGFILES}
 FILESDIR_${f}=		/usr/share/examples/dhcpcd/hooks
 .endfor
 .endif
 
+.SUFFIXES:		.in
+
+all:	${HOOKS} ${EGHOOKS} ${MKEGHOOKS}
+
+.in:	../../Makefile.inc
+	${TOOL_SED} ${SED_SYS} $< > $@
+
 .include 



CVS commit: src/external/bsd/dhcpcd/libexec

2017-04-01 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Apr  1 10:51:41 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/libexec: Makefile

Log Message:
We should build the hooks as well really.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/bsd/dhcpcd/libexec/Makefile

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/libexec/Makefile
diff -u src/external/bsd/dhcpcd/libexec/Makefile:1.1 src/external/bsd/dhcpcd/libexec/Makefile:1.2
--- src/external/bsd/dhcpcd/libexec/Makefile:1.1	Fri Mar 31 21:02:09 2017
+++ src/external/bsd/dhcpcd/libexec/Makefile	Sat Apr  1 10:51:41 2017
@@ -1,6 +1,5 @@
-#	$NetBSD: Makefile,v 1.1 2017/03/31 21:02:09 roy Exp $
+#	$NetBSD: Makefile,v 1.2 2017/04/01 10:51:41 roy Exp $
 
-SUBDIR=		dhcpcd-hooks
-SUBDIR=		dhcpcd-run-hooks
+SUBDIR=		dhcpcd-run-hooks dhcpcd-hooks
 
 .include 



CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2017-03-31 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Mar 31 23:50:01 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
Disable stack-protector for bpf.c (sbin/dhcpcd)

This is temporary build fix.

Approved by 


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.35 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.36
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.35	Fri Mar 31 21:02:09 2017
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Fri Mar 31 23:50:01 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.35 2017/03/31 21:02:09 roy Exp $
+# $NetBSD: Makefile,v 1.36 2017/03/31 23:50:01 kamil Exp $
 #
 
 WARNS?=		6
@@ -29,6 +29,7 @@ SRCS+=		auth.c hmac_md5.c
 .if (${USE_INET} != "no")
 CPPFLAGS+=	-DARP -DINET
 SRCS+=		arp.c bpf.c dhcp.c ipv4.c
+COPTS.bpf.c+=	-Wno-stack-protector
 .if !defined(SMALLPROG)
 CPPFLAGS+=	-DIPV4LL
 SRCS+=		ipv4ll.c



CVS commit: src/external/bsd/dhcpcd

2017-03-31 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Mar 31 21:02:09 UTC 2017

Modified Files:
src/external/bsd/dhcpcd: Makefile
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile
Added Files:
src/external/bsd/dhcpcd: Makefile.inc
src/external/bsd/dhcpcd/include: config.h
src/external/bsd/dhcpcd/libexec: Makefile
src/external/bsd/dhcpcd/libexec/dhcpcd-hooks: Makefile
src/external/bsd/dhcpcd/libexec/dhcpcd-run-hooks: Makefile

Log Message:
Adjust build glue for dhcpcd-7


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/bsd/dhcpcd/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/dhcpcd/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/external/bsd/dhcpcd/include/config.h
cvs rdiff -u -r0 -r1.1 src/external/bsd/dhcpcd/libexec/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/dhcpcd/libexec/dhcpcd-hooks/Makefile
cvs rdiff -u -r0 -r1.1 \
src/external/bsd/dhcpcd/libexec/dhcpcd-run-hooks/Makefile
cvs rdiff -u -r1.34 -r1.35 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/Makefile
diff -u src/external/bsd/dhcpcd/Makefile:1.1 src/external/bsd/dhcpcd/Makefile:1.2
--- src/external/bsd/dhcpcd/Makefile:1.1	Sun Jul 27 19:31:03 2008
+++ src/external/bsd/dhcpcd/Makefile	Fri Mar 31 21:02:08 2017
@@ -1,5 +1,5 @@
-#	$NetBSD: Makefile,v 1.1 2008/07/27 19:31:03 joerg Exp $
+#	$NetBSD: Makefile,v 1.2 2017/03/31 21:02:08 roy Exp $
 
-SUBDIR=		sbin
+SUBDIR=		sbin libexec
 
 .include 

Index: src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.34 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.35
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.34	Fri Dec  2 02:41:54 2016
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Fri Mar 31 21:02:09 2017
@@ -1,14 +1,15 @@
-# $NetBSD: Makefile,v 1.34 2016/12/02 02:41:54 riastradh Exp $
+# $NetBSD: Makefile,v 1.35 2017/03/31 21:02:09 roy Exp $
 #
 
 WARNS?=		6
 USE_FORT?=	yes	# network client (local server)
 
 .include 
+.include "../../Makefile.inc"
 
 PROG=		dhcpcd
 SRCS=		common.c control.c dhcpcd.c duid.c eloop.c
-SRCS+=		if.c if-options.c script.c
+SRCS+=		if.c if-options.c route.c sa.c script.c
 SRCS+=		dhcp-common.c dhcpcd-embedded.c
 SRCS+=		if-bsd.c
 
@@ -26,8 +27,8 @@ SRCS+=		auth.c hmac_md5.c
 .endif
 
 .if (${USE_INET} != "no")
-CPPFLAGS+=	-DINET
-SRCS+=		arp.c dhcp.c ipv4.c
+CPPFLAGS+=	-DARP -DINET
+SRCS+=		arp.c bpf.c dhcp.c ipv4.c
 .if !defined(SMALLPROG)
 CPPFLAGS+=	-DIPV4LL
 SRCS+=		ipv4ll.c
@@ -43,42 +44,19 @@ CPPFLAGS+=	-DDHCP6
 SRCS+=		dhcp6.c
 .endif
 
-DIST=		${NETBSDSRCDIR}/external/bsd/dhcpcd/dist
-CPPFLAGS+=	-I${DIST} -I${.OBJDIR}
+CPPFLAGS+=	-I${SRCDIR}/include -I${DIST}/src -I${.OBJDIR}
 
 DPADD+=		${LIBUTIL}
 LDADD+=		-lutil
 
-.PATH: ${DIST} ${DIST}/crypt ${LIBC_NET}
-
-SCRIPTS=			dhcpcd-run-hooks
-SCRIPTSDIR_dhcpcd-run-hooks=	/libexec
+.PATH: ${DIST}/src ${DIST}/src/crypt ${LIBC_NET}
 
 CONFIGFILES=			dhcpcd.conf
 FILESDIR_dhcpcd.conf=		/etc
 FILESMODE_dhcpcd.conf=		644	# -rw-r--r--
 
-HOOKS=			01-test 02-dump 20-resolv.conf 30-hostname
-HOOKS+=			50-ntp.conf
-
-FILES=			${HOOKS:C,^,${DIST}/dhcpcd-hooks/,}
-FILESDIR=		/libexec/dhcpcd-hooks
-
-EGHOOKS=		10-wpa_supplicant 15-timezone 29-lookup-hostname
-EGHOOKS+=		50-ypbind
-
-.if ${MKSHARE} != "no"
-EGFILES=		${EGHOOKS:C,^,${DIST}/dhcpcd-hooks/,}
-FILES+=			${EGFILES}
-.for f in ${EGFILES}
-FILESDIR_${f}=		/usr/share/examples/dhcpcd/hooks
-.endfor
-.endif
-
-MAN=			dhcpcd.conf.5 dhcpcd.8 dhcpcd-run-hooks.8
-
-CLEANFILES=		dhcpcd.conf.5 dhcpcd.8 \
-			dhcpcd-run-hooks dhcpcd-run-hooks.8
+MAN=			dhcpcd.conf.5 dhcpcd.8 
+CLEANFILES=		dhcpcd.conf.5 dhcpcd.8 
 
 dhcpcd-embedded.h:	genembedh ${DHCPCD_DEFS} dhcpcd-embedded.h.in
 	${HOST_SH} ${.ALLSRC} $^ > $@
@@ -90,18 +68,9 @@ if-options.c:		dhcpcd-embedded.h
 
 CLEANFILES+=		dhcpcd-embedded.c dhcpcd-embedded.h
 
-.for f in dhcpcd-run-hooks dhcpcd.conf.5 dhcpcd.8 dhcpcd-run-hooks.8
+.for f in dhcpcd.conf.5 dhcpcd.8
 ${f}:	${f}.in
-	${TOOL_SED} -e 's:@SYSCONFDIR@:/etc:g' -e 's:@DBDIR@:/var/db:g' \
-	-e 's:@LIBDIR@:/lib:g' \
-	-e 's:@RUNDIR@:/var/run:g' \
-	-e 's:@HOOKDIR@:/libexec/dhcpcd-hooks:g' \
-	-e 's:@SCRIPT@:/libexec/dhcpcd-run-hooks:g' \
-	-e 's:@SERVICEEXISTS@::g' \
-	-e 's:@SERVICECMD@::g' \
-	-e 's:@SERVICESTATUS@::g' \
-	-e 's:@STATUSARG@::g' \
-	${DIST}/${f}.in > $@
+	${TOOL_SED} ${SED_SYS} ${DIST}/src/${f}.in > $@
 .endfor
 
 # XXXGCC5

Added files:

Index: src/external/bsd/dhcpcd/Makefile.inc
diff -u /dev/null src/external/bsd/dhcpcd/Makefile.inc:1.1
--- /dev/null	Fri Mar 31 21:02:09 2017
+++ src/external/bsd/dhcpcd/Makefile.inc	Fri Mar 31 21:02:08 2017
@@ -0,0 +1,15 @@
+# $NetBSD: Makefile.inc,v 1.1 2017/03/31 21:02:08 roy Exp $
+
+SRCDIR=		${NETBSDSRCDIR}/external/bsd/dhcpcd
+DIST=		${SRCDIR}/dist
+
+SED_SYS=	-e 's:@SYSCONFDIR@:/etc:g' \
+		

CVS commit: src/external/bsd/dhcpcd/dist

2017-03-31 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Mar 31 20:53:56 UTC 2017

Added Files:
src/external/bsd/dhcpcd/dist: .gitignore
Removed Files:
src/external/bsd/dhcpcd/dist: arp.c arp.h auth.h bpf-filter.h common.c
common.h config.h control.c control.h defs.h dev.h dhcp-common.c
dhcp-common.h dhcp.c dhcp.h dhcp6.c dhcp6.h
dhcpcd-definitions-small.conf dhcpcd-definitions.conf
dhcpcd-embedded.c.in dhcpcd-embedded.h.in dhcpcd-run-hooks.8.in
dhcpcd-run-hooks.in dhcpcd.8.in dhcpcd.c dhcpcd.conf
dhcpcd.conf.5.in dhcpcd.h duid.c duid.h eloop.c eloop.h genembedc
genembedh if-bsd.c if-options.c if-options.h if.c if.h ipv4.c
ipv4.h ipv4ll.c ipv4ll.h ipv6.c ipv6.h ipv6nd.c ipv6nd.h script.c
script.h
src/external/bsd/dhcpcd/dist/crypt: crypt.h hmac_md5.c
src/external/bsd/dhcpcd/dist/dhcpcd-hooks: 01-test 02-dump
10-wpa_supplicant 15-timezone 20-resolv.conf 29-lookup-hostname
30-hostname 50-ntp.conf 50-ypbind

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.3 src/external/bsd/dhcpcd/dist/.gitignore
cvs rdiff -u -r1.22 -r0 src/external/bsd/dhcpcd/dist/arp.c \
src/external/bsd/dhcpcd/dist/ipv6.c
cvs rdiff -u -r1.14 -r0 src/external/bsd/dhcpcd/dist/arp.h
cvs rdiff -u -r1.10 -r0 src/external/bsd/dhcpcd/dist/auth.h \
src/external/bsd/dhcpcd/dist/eloop.h
cvs rdiff -u -r1.11 -r0 src/external/bsd/dhcpcd/dist/bpf-filter.h
cvs rdiff -u -r1.21 -r0 src/external/bsd/dhcpcd/dist/common.c \
src/external/bsd/dhcpcd/dist/ipv6.h
cvs rdiff -u -r1.15 -r0 src/external/bsd/dhcpcd/dist/common.h \
src/external/bsd/dhcpcd/dist/eloop.c \
src/external/bsd/dhcpcd/dist/ipv6nd.h
cvs rdiff -u -r1.12 -r0 src/external/bsd/dhcpcd/dist/config.h \
src/external/bsd/dhcpcd/dist/dhcpcd-definitions.conf \
src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in
cvs rdiff -u -r1.13 -r0 src/external/bsd/dhcpcd/dist/control.c \
src/external/bsd/dhcpcd/dist/dhcp-common.h \
src/external/bsd/dhcpcd/dist/duid.c src/external/bsd/dhcpcd/dist/ipv4ll.h
cvs rdiff -u -r1.8 -r0 src/external/bsd/dhcpcd/dist/control.h
cvs rdiff -u -r1.31 -r0 src/external/bsd/dhcpcd/dist/defs.h
cvs rdiff -u -r1.7 -r0 src/external/bsd/dhcpcd/dist/dev.h \
src/external/bsd/dhcpcd/dist/duid.h src/external/bsd/dhcpcd/dist/script.h
cvs rdiff -u -r1.19 -r0 src/external/bsd/dhcpcd/dist/dhcp-common.c \
src/external/bsd/dhcpcd/dist/if.h src/external/bsd/dhcpcd/dist/ipv4ll.c
cvs rdiff -u -r1.47 -r0 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.17 -r0 src/external/bsd/dhcpcd/dist/dhcp.h \
src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in
cvs rdiff -u -r1.26 -r0 src/external/bsd/dhcpcd/dist/dhcp6.c \
src/external/bsd/dhcpcd/dist/ipv4.c
cvs rdiff -u -r1.16 -r0 src/external/bsd/dhcpcd/dist/dhcp6.h
cvs rdiff -u -r1.1.1.1 -r0 \
src/external/bsd/dhcpcd/dist/dhcpcd-definitions-small.conf \
src/external/bsd/dhcpcd/dist/genembedc \
src/external/bsd/dhcpcd/dist/genembedh
cvs rdiff -u -r1.1.1.4 -r0 src/external/bsd/dhcpcd/dist/dhcpcd-embedded.c.in
cvs rdiff -u -r1.1.1.5 -r0 src/external/bsd/dhcpcd/dist/dhcpcd-embedded.h.in
cvs rdiff -u -r1.51 -r0 src/external/bsd/dhcpcd/dist/dhcpcd.8.in
cvs rdiff -u -r1.37 -r0 src/external/bsd/dhcpcd/dist/dhcpcd.c
cvs rdiff -u -r1.18 -r0 src/external/bsd/dhcpcd/dist/dhcpcd.conf
cvs rdiff -u -r1.30 -r0 src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in
cvs rdiff -u -r1.20 -r0 src/external/bsd/dhcpcd/dist/dhcpcd.h \
src/external/bsd/dhcpcd/dist/if-options.h \
src/external/bsd/dhcpcd/dist/ipv4.h
cvs rdiff -u -r1.34 -r0 src/external/bsd/dhcpcd/dist/if-bsd.c \
src/external/bsd/dhcpcd/dist/ipv6nd.c
cvs rdiff -u -r1.36 -r0 src/external/bsd/dhcpcd/dist/if-options.c
cvs rdiff -u -r1.24 -r0 src/external/bsd/dhcpcd/dist/if.c
cvs rdiff -u -r1.28 -r0 src/external/bsd/dhcpcd/dist/script.c
cvs rdiff -u -r1.6 -r0 src/external/bsd/dhcpcd/dist/crypt/crypt.h
cvs rdiff -u -r1.8 -r0 src/external/bsd/dhcpcd/dist/crypt/hmac_md5.c
cvs rdiff -u -r1.8 -r0 src/external/bsd/dhcpcd/dist/dhcpcd-hooks/01-test \
src/external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname
cvs rdiff -u -r1.6 -r0 src/external/bsd/dhcpcd/dist/dhcpcd-hooks/02-dump \
src/external/bsd/dhcpcd/dist/dhcpcd-hooks/10-wpa_supplicant \
src/external/bsd/dhcpcd/dist/dhcpcd-hooks/15-timezone
cvs rdiff -u -r1.10 -r0 \
src/external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf
cvs rdiff -u -r1.7 -r0 \
src/external/bsd/dhcpcd/dist/dhcpcd-hooks/29-lookup-hostname \
src/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf \
src/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ypbind

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/external/bsd/dhcpcd/dist/.gitignore
diff -u /dev/null src/external/bsd/dhcpcd/dist/.gitignore:1.3
--- /dev/null	Fri Mar 31 20:53:56 2017
+++ 

CVS commit: src/external/bsd/dhcpcd/dist

2017-01-23 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Mon Jan 23 11:18:02 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist: dhcpcd-run-hooks.8.in

Log Message:
Fix typo: s/obtaind/obtained


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in

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/dhcpcd-run-hooks.8.in
diff -u src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in:1.16 src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in:1.17
--- src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in:1.16	Fri Jul 29 10:07:57 2016
+++ src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in	Mon Jan 23 11:18:02 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: dhcpcd-run-hooks.8.in,v 1.16 2016/07/29 10:07:57 roy Exp $
+.\" $NetBSD: dhcpcd-run-hooks.8.in,v 1.17 2017/01/23 11:18:02 abhinav Exp $
 .\" Copyright (c) 2006-2015 Roy Marples
 .\" All rights reserved
 .\"
@@ -93,7 +93,7 @@ dhcpcd successfully requested a lease fr
 .It Dv DELEGATED6
 dhcpcd assigned a delegated prefix to the interface.
 .It Dv IPV4LL
-dhcpcd obtaind an IPV4LL address, or one was removed.
+dhcpcd obtained an IPV4LL address, or one was removed.
 .It Dv STATIC
 dhcpcd has been configured with a static configuration which has not been
 obtained from a DHCP server.



CVS commit: src/external/bsd/dhcpcd/dist

2017-01-23 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Mon Jan 23 11:09:14 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist: dhcpcd.conf.5.in

Log Message:
Fix several typos.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in

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/dhcpcd.conf.5.in
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in:1.29 src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in:1.30
--- src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in:1.29	Fri Jul 29 10:07:57 2016
+++ src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in	Mon Jan 23 11:09:14 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: dhcpcd.conf.5.in,v 1.29 2016/07/29 10:07:57 roy Exp $
+.\" $NetBSD: dhcpcd.conf.5.in,v 1.30 2017/01/23 11:09:14 abhinav Exp $
 .\" Copyright (c) 2006-2016 Roy Marples
 .\" All rights reserved
 .\"
@@ -376,7 +376,7 @@ interface eth0
 .It Ic ipv4only
 Only configure IPv4.
 .It Ic ipv6only
-Only confgiure IPv6.
+Only configure IPv6.
 .It Ic fqdn Op disable | ptr | both
 ptr just asks the DHCP server to update the PTR
 record of the host in DNS whereas both also updates the A record.
@@ -482,7 +482,7 @@ See
 .%T "RFC 3927"
 .Re
 .It Ic noipv6
-Don't attmept to configure an IPv6 address.
+Don't attempt to configure an IPv6 address.
 .It Ic noipv6rs
 Disable solicitation and receipt of IPv6 Router Advertisements.
 .It Ic nolink
@@ -676,7 +676,7 @@ If not set then none is sent.
 Some badly configured DHCP servers reject unknown vendorclassids.
 To work around it, try and impersonate Windows by using the MSFT vendorclassid.
 .It Ic vendclass Ar en Ar data
-Add the DHCPv6 Vendor Indetifying Vendor Class with the IANA assigned Enterprise
+Add the DHCPv6 Vendor Identifying Vendor Class with the IANA assigned Enterprise
 Number
 .Ar en
 with the
@@ -752,7 +752,7 @@ with a prefix of
 Defines the Vendor-Identifying Vendor Options.
 The
 .Ar code
-is the IANA Enterprise Number which will unqiuely describe the encapsulated
+is the IANA Enterprise Number which will uniquely describe the encapsulated
 options.
 .Ar type
 is normally
@@ -823,8 +823,8 @@ A byte represented as a string of flags,
 For example, using ABCDEFGH then A would equal 1000, B 0100,
 C 0010, etc.
 If the bit is not set, the flag is not printed.
-A flag of 0 is not printed even if the bit postition is set.
-This is to allow reservation of the first bits while assinging the last bits.
+A flag of 0 is not printed even if the bit position is set.
+This is to allow reservation of the first bits while assigning the last bits.
 .It Ic int16
 A signed 16bit integer, 2 bytes.
 .It Ic uint16
@@ -877,7 +877,7 @@ and
 in it.
 .Nm dhcpcd
 will then look for a non-expired token with a matching realm and secretid.
-This token is used to authenicate all other messages.
+This token is used to authenticate all other messages.
 .It Ic delayed
 Same as above, but without a realm.
 .El



CVS commit: src/external/bsd/dhcpcd/dist

2017-01-23 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Mon Jan 23 10:50:11 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist: dhcpcd.8.in

Log Message:
Fix typo: s/Unpriviledged/Unprivileged


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/external/bsd/dhcpcd/dist/dhcpcd.8.in

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/dhcpcd.8.in
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.50 src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.51
--- src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.50	Mon Aug 15 11:04:53 2016
+++ src/external/bsd/dhcpcd/dist/dhcpcd.8.in	Mon Jan 23 10:50:11 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: dhcpcd.8.in,v 1.50 2016/08/15 11:04:53 roy Exp $
+.\" $NetBSD: dhcpcd.8.in,v 1.51 2017/01/23 10:50:11 abhinav Exp $
 .\" Copyright (c) 2006-2016 Roy Marples
 .\" All rights reserved
 .\"
@@ -790,7 +790,7 @@ running on the
 .It Pa @RUNDIR@/dhcpcd.sock
 Control socket to the master daemon.
 .It Pa @RUNDIR@/dhcpcd.unpriv.sock
-Unpriviledged socket to the master daemon, only allows state retrieval.
+Unprivileged socket to the master daemon, only allows state retrieval.
 .It Pa @RUNDIR@/dhcpcd\- Ns Ar interface Ns .sock
 Control socket to per interface daemon.
 .El



CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2016-12-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  2 02:41:54 UTC 2016

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
Respect MKSHARE=no.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.33 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.34
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.33	Sun Oct  9 09:23:59 2016
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Fri Dec  2 02:41:54 2016
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.33 2016/10/09 09:23:59 roy Exp $
+# $NetBSD: Makefile,v 1.34 2016/12/02 02:41:54 riastradh Exp $
 #
 
 WARNS?=		6
@@ -67,11 +67,13 @@ FILESDIR=		/libexec/dhcpcd-hooks
 EGHOOKS=		10-wpa_supplicant 15-timezone 29-lookup-hostname
 EGHOOKS+=		50-ypbind
 
+.if ${MKSHARE} != "no"
 EGFILES=		${EGHOOKS:C,^,${DIST}/dhcpcd-hooks/,}
 FILES+=			${EGFILES}
 .for f in ${EGFILES}
 FILESDIR_${f}=		/usr/share/examples/dhcpcd/hooks
 .endfor
+.endif
 
 MAN=			dhcpcd.conf.5 dhcpcd.8 dhcpcd-run-hooks.8
 



CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2016-10-09 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Oct  9 09:23:59 UTC 2016

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
If SMALLPROG is defined, use a minimal dhcpcd-definitons.conf
and compile out IPv4LL and DHCP authentication.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.32 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.33
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.32	Sun Sep 18 15:37:23 2016
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Sun Oct  9 09:23:59 2016
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.32 2016/09/18 15:37:23 christos Exp $
+# $NetBSD: Makefile,v 1.33 2016/10/09 09:23:59 roy Exp $
 #
 
 WARNS?=		6
@@ -14,25 +14,37 @@ SRCS+=		if-bsd.c
 
 CPPFLAGS+=	-DHAVE_CONFIG_H -D_OPENBSD_SOURCE
 
+USE_INET?=	yes
+
 .if defined(SMALLPROG)
-CPPFLAGS+=	-DNO_AUTH
+CPPFLAGS+=	-DSMALL
+DHCPCD_DEFS=	dhcpcd-definitions-small.conf
 .else
+DHCPCD_DEFS=	dhcpcd-definitions.conf
+CPPFLAGS+=	-DAUTH
 SRCS+=		auth.c hmac_md5.c
 .endif
 
-USE_INET?=	yes
 .if (${USE_INET} != "no")
 CPPFLAGS+=	-DINET
-SRCS+=		arp.c dhcp.c ipv4.c ipv4ll.c
+SRCS+=		arp.c dhcp.c ipv4.c
+.if !defined(SMALLPROG)
+CPPFLAGS+=	-DIPV4LL
+SRCS+=		ipv4ll.c
+.endif
 .endif
 
 .if (${USE_INET6} != "no")
 CPPFLAGS+=	-DINET6
-SRCS+=		ipv6.c ipv6nd.c dhcp6.c
+SRCS+=		ipv6.c ipv6nd.c
+# -DSMALL already strips out prefix delegation
+# A network could be IPv6 only and require DHCPv6
+CPPFLAGS+=	-DDHCP6
+SRCS+=		dhcp6.c
 .endif
 
 DIST=		${NETBSDSRCDIR}/external/bsd/dhcpcd/dist
-CPPFLAGS+=	-I${DIST}
+CPPFLAGS+=	-I${DIST} -I${.OBJDIR}
 
 DPADD+=		${LIBUTIL}
 LDADD+=		-lutil
@@ -66,6 +78,16 @@ MAN=			dhcpcd.conf.5 dhcpcd.8 dhcpcd-run
 CLEANFILES=		dhcpcd.conf.5 dhcpcd.8 \
 			dhcpcd-run-hooks dhcpcd-run-hooks.8
 
+dhcpcd-embedded.h:	genembedh ${DHCPCD_DEFS} dhcpcd-embedded.h.in
+	${HOST_SH} ${.ALLSRC} $^ > $@
+
+dhcpcd-embedded.c:	genembedc ${DHCPCD_DEFS} dhcpcd-embedded.c.in
+	${HOST_SH} ${.ALLSRC} $^ > $@
+
+if-options.c:		dhcpcd-embedded.h
+
+CLEANFILES+=		dhcpcd-embedded.c dhcpcd-embedded.h
+
 .for f in dhcpcd-run-hooks dhcpcd.conf.5 dhcpcd.8 dhcpcd-run-hooks.8
 ${f}:	${f}.in
 	${TOOL_SED} -e 's:@SYSCONFDIR@:/etc:g' -e 's:@DBDIR@:/var/db:g' \



CVS commit: src/external/bsd/dhcpcd/dist

2016-10-09 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Oct  9 09:18:26 UTC 2016

Modified Files:
src/external/bsd/dhcpcd/dist: arp.c auth.h common.c common.h config.h
defs.h dhcp.c dhcp6.c dhcp6.h dhcpcd.c dhcpcd.h if-bsd.c
if-options.c if.c if.h ipv4.c ipv4.h ipv4ll.c ipv4ll.h ipv6.c
ipv6.h ipv6nd.c script.c
Removed Files:
src/external/bsd/dhcpcd/dist: dhcpcd-embedded.c dhcpcd-embedded.h

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/external/bsd/dhcpcd/dist/arp.c \
src/external/bsd/dhcpcd/dist/ipv6.c
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/auth.h
cvs rdiff -u -r1.20 -r1.21 src/external/bsd/dhcpcd/dist/common.c \
src/external/bsd/dhcpcd/dist/ipv6.h
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/dhcpcd/dist/common.h
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/config.h
cvs rdiff -u -r1.30 -r1.31 src/external/bsd/dhcpcd/dist/defs.h
cvs rdiff -u -r1.46 -r1.47 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.25 -r1.26 src/external/bsd/dhcpcd/dist/dhcp6.c \
src/external/bsd/dhcpcd/dist/ipv4.c
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/dhcp6.h
cvs rdiff -u -r1.13 -r0 src/external/bsd/dhcpcd/dist/dhcpcd-embedded.c
cvs rdiff -u -r1.10 -r0 src/external/bsd/dhcpcd/dist/dhcpcd-embedded.h
cvs rdiff -u -r1.36 -r1.37 src/external/bsd/dhcpcd/dist/dhcpcd.c
cvs rdiff -u -r1.19 -r1.20 src/external/bsd/dhcpcd/dist/dhcpcd.h \
src/external/bsd/dhcpcd/dist/ipv4.h
cvs rdiff -u -r1.33 -r1.34 src/external/bsd/dhcpcd/dist/if-bsd.c
cvs rdiff -u -r1.35 -r1.36 src/external/bsd/dhcpcd/dist/if-options.c
cvs rdiff -u -r1.23 -r1.24 src/external/bsd/dhcpcd/dist/if.c
cvs rdiff -u -r1.18 -r1.19 src/external/bsd/dhcpcd/dist/if.h \
src/external/bsd/dhcpcd/dist/ipv4ll.c
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/ipv4ll.h
cvs rdiff -u -r1.32 -r1.33 src/external/bsd/dhcpcd/dist/ipv6nd.c
cvs rdiff -u -r1.27 -r1.28 src/external/bsd/dhcpcd/dist/script.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.21 src/external/bsd/dhcpcd/dist/arp.c:1.22
--- src/external/bsd/dhcpcd/dist/arp.c:1.21	Fri Jul 29 10:07:57 2016
+++ src/external/bsd/dhcpcd/dist/arp.c	Sun Oct  9 09:18:26 2016
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: arp.c,v 1.21 2016/07/29 10:07:57 roy Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.22 2016/10/09 09:18:26 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -448,6 +448,8 @@ arp_handleifa(int cmd, struct ipv4_addr 
 	struct iarp_state *state;
 	struct arp_state *astate, *asn;
 
+	/* If the address is deleted, the ARP state should be freed by the
+	 * state owner, such as DHCP or IPv4LL. */
 	if (cmd != RTM_NEWADDR || (state = ARP_STATE(addr->iface)) == NULL)
 		return;
 
Index: src/external/bsd/dhcpcd/dist/ipv6.c
diff -u src/external/bsd/dhcpcd/dist/ipv6.c:1.21 src/external/bsd/dhcpcd/dist/ipv6.c:1.22
--- src/external/bsd/dhcpcd/dist/ipv6.c:1.21	Mon Aug 15 11:04:53 2016
+++ src/external/bsd/dhcpcd/dist/ipv6.c	Sun Oct  9 09:18:26 2016
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: ipv6.c,v 1.21 2016/08/15 11:04:53 roy Exp $");
+ __RCSID("$NetBSD: ipv6.c,v 1.22 2016/10/09 09:18:26 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -104,20 +104,22 @@
 
 #if defined(HAVE_IN6_ADDR_GEN_MODE_NONE) || defined(ND6_IFF_AUTO_LINKLOCAL) || \
 defined(IFF_NOLINKLOCAL)
-/* If we're using a private SLAAC address on wireless,
- * don't add it until we have associated as we randomise
- * it based on the SSID. */
-#define CAN_ADD_LLADDR(ifp) \
-	(!((ifp)->options->options & DHCPCD_SLAACPRIVATE) || \
-	(ifp)->carrier != LINK_DOWN)
-#elif __NetBSD__
-/* Earlier versions of NetBSD don't add duplicate LLADDR's if the interface
- * is brought up and one already exists. */
-#define CAN_ADD_LLADDR(ifp) (1)
+/* Only add the LL address if we have a carrier, so DaD works. */
+#define	CAN_ADD_LLADDR(ifp) \
+(!((ifp)->options->options & DHCPCD_LINK) || (ifp)->carrier != LINK_DOWN)
+#ifdef __sun
+/* Although we can add our own LL address, we cannot drop it
+ * without unplumbing the if which is a lot of code.
+ * So just keep it for the time being. */
+#define	CAN_DROP_LLADDR(ifp)	(0)
+#else
+#define	CAN_DROP_LLADDR(ifp)	(1)
+#endif
 #else
 /* We have no control over the OS adding the LLADDR, so just let it do it
  * as we cannot force our own view on it. */
-#define CAN_ADD_LLADDR(ifp) (0)
+#define	CAN_ADD_LLADDR(ifp)	(0)
+#define	CAN_DROP_LLADDR(ifp)	(0)
 #endif
 
 #ifdef IPV6_MANAGETEMPADDR
@@ -163,13 +165,11 @@ ipv6_init(struct dhcpcd_ctx *dhcpcd_ctx)
 	ctx->sndhdr.msg_controllen = sizeof(ctx->sndbuf);
 	ctx->rcvhdr.msg_name = >from;
 	ctx->rcvhdr.msg_namelen = sizeof(ctx->from);
-	ctx->rcvhdr.msg_iov = ctx->rcviov;
+	ctx->rcvhdr.msg_iov = dhcpcd_ctx->iov;
 	ctx->rcvhdr.msg_iovlen = 1;
-	ctx->rcvhdr.msg_control = 

CVS commit: src/external/bsd/dhcpcd/dist/crypt

2016-10-07 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Oct  7 09:38:11 UTC 2016

Removed Files:
src/external/bsd/dhcpcd/dist/crypt: arp.h auth.c auth.h common.h
config.h control.h defs.h dhcp-common.h dhcp.h dhcp6.h dhcpcd.h
if-options.h if.h ipv4.h ipv6.h

Log Message:
Remove files from botched import


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/dhcpcd/dist/crypt/arp.h \
src/external/bsd/dhcpcd/dist/crypt/auth.c \
src/external/bsd/dhcpcd/dist/crypt/auth.h \
src/external/bsd/dhcpcd/dist/crypt/common.h \
src/external/bsd/dhcpcd/dist/crypt/config.h \
src/external/bsd/dhcpcd/dist/crypt/control.h \
src/external/bsd/dhcpcd/dist/crypt/defs.h \
src/external/bsd/dhcpcd/dist/crypt/dhcp-common.h \
src/external/bsd/dhcpcd/dist/crypt/dhcp.h \
src/external/bsd/dhcpcd/dist/crypt/dhcp6.h \
src/external/bsd/dhcpcd/dist/crypt/dhcpcd.h \
src/external/bsd/dhcpcd/dist/crypt/if-options.h \
src/external/bsd/dhcpcd/dist/crypt/if.h \
src/external/bsd/dhcpcd/dist/crypt/ipv4.h \
src/external/bsd/dhcpcd/dist/crypt/ipv6.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/dhcpcd

2016-09-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Sep 18 15:37:23 UTC 2016

Modified Files:
src/external/bsd/dhcpcd/dist: dhcp.c dhcp6.c
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
provide a NO_AUTH option to strip auth for boot media; saves around 40K.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.24 -r1.25 src/external/bsd/dhcpcd/dist/dhcp6.c
cvs rdiff -u -r1.31 -r1.32 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/dhcp.c:1.45 src/external/bsd/dhcpcd/dist/dhcp.c:1.46
--- src/external/bsd/dhcpcd/dist/dhcp.c:1.45	Mon Aug 15 07:04:53 2016
+++ src/external/bsd/dhcpcd/dist/dhcp.c	Sun Sep 18 11:37:23 2016
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: dhcp.c,v 1.45 2016/08/15 11:04:53 roy Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.46 2016/09/18 15:37:23 christos Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -729,8 +729,8 @@ static ssize_t
 make_message(struct bootp **bootpm, const struct interface *ifp, uint8_t type)
 {
 	struct bootp *bootp;
-	uint8_t *lp, *p, *e, *auth;
-	uint8_t *n_params = NULL, auth_len;
+	uint8_t *lp, *p, *e;
+	uint8_t *n_params = NULL;
 	uint32_t ul;
 	uint16_t sz;
 	size_t len, i;
@@ -742,6 +742,9 @@ make_message(struct bootp **bootpm, cons
 	const char *hostname;
 	const struct vivco *vivco;
 	int mtu;
+#ifndef NO_AUTH
+	uint8_t *auth, auth_len;
+#endif
 
 	if ((mtu = if_getmtu(ifp)) == -1)
 		logger(ifp->ctx, LOG_ERR,
@@ -1056,6 +1059,7 @@ make_message(struct bootp **bootpm, cons
 		*n_params = (uint8_t)(p - n_params - 1);
 	}
 
+#ifndef NO_AUTH
 	/* silence GCC */
 	auth_len = 0;
 	auth = NULL;
@@ -1080,7 +1084,7 @@ make_message(struct bootp **bootpm, cons
 			p += auth_len;
 		}
 	}
-
+#endif
 	*p++ = DHO_END;
 	len = (size_t)(p - (uint8_t *)bootp);
 
@@ -1093,10 +1097,11 @@ make_message(struct bootp **bootpm, cons
 		*p++ = DHO_PAD;
 		len++;
 	}
-
+#ifndef NO_AUTH
 	if (ifo->auth.options & DHCPCD_AUTH_SEND && auth_len != 0)
 		dhcp_auth_encode(>auth, state->auth.token,
 		(uint8_t *)bootp, len, 4, type, auth, auth_len);
+#endif
 
 	return (ssize_t)len;
 
@@ -1132,9 +1137,11 @@ read_lease(struct interface *ifp, struct
 	struct dhcp_state *state = D_STATE(ifp);
 	uint8_t *lease;
 	size_t bytes;
-	const uint8_t *auth;
 	uint8_t type;
+#ifndef NO_AUTH
 	size_t auth_len;
+	const uint8_t *auth;
+#endif
 
 	/* Safety */
 	*bootp = NULL;
@@ -1187,6 +1194,7 @@ read_lease(struct interface *ifp, struct
 	DHO_MESSAGETYPE) == -1)
 		type = 0;
 
+#ifndef NO_AUTH
 	/* Authenticate the message */
 	auth = get_option(ifp->ctx, (struct bootp *)lease, bytes,
 	DHO_AUTHENTICATION, _len);
@@ -1214,7 +1222,7 @@ read_lease(struct interface *ifp, struct
 		free(lease);
 		return 0;
 	}
-
+#endif
 out:
 	*bootp = (struct bootp *)lease;
 	return bytes;
@@ -2563,7 +2571,9 @@ dhcp_drop(struct interface *ifp, const c
 	}
 
 	eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
+#ifndef NO_AUTH
 	dhcp_auth_reset(>auth);
+#endif
 	dhcp_close(ifp);
 
 	free(state->offer);
@@ -2684,15 +2694,17 @@ dhcp_handledhcp(struct interface *ifp, s
 	struct if_options *ifo = ifp->options;
 	struct dhcp_lease *lease = >lease;
 	uint8_t type, tmp;
-	const uint8_t *auth;
 	struct in_addr addr;
 	unsigned int i;
-	size_t auth_len;
 	char *msg;
 	bool bootp_copied;
 #ifdef IN_IFF_DUPLICATED
 	struct ipv4_addr *ia;
 #endif
+#ifndef NO_AUTH
+	const uint8_t *auth;
+	size_t auth_len;
+#endif
 
 #define LOGDHCP0(l, m) \
 	log_dhcp((l), (m), ifp, bootp, bootp_len, from, 0)
@@ -2730,6 +2742,7 @@ dhcp_handledhcp(struct interface *ifp, s
 	}
 
 	/* Authenticate the message */
+#ifndef NO_AUTH
 	auth = get_option(ifp->ctx, bootp, bootp_len,
 	DHO_AUTHENTICATION, _len);
 	if (auth) {
@@ -2756,7 +2769,7 @@ dhcp_handledhcp(struct interface *ifp, s
 		}
 		LOGDHCP0(LOG_WARNING, "no authentication");
 	}
-
+#endif
 	/* RFC 3203 */
 	if (type == DHCP_FORCERENEW) {
 		if (from->s_addr == INADDR_ANY ||
@@ -2765,11 +2778,13 @@ dhcp_handledhcp(struct interface *ifp, s
 			LOGDHCP(LOG_ERR, "discarding Force Renew");
 			return;
 		}
+#ifndef NO_AUTH
 		if (auth == NULL) {
 			LOGDHCP(LOG_ERR, "unauthenticated Force Renew");
 			if (ifo->auth.options & DHCPCD_AUTH_REQUIRE)
 return;
 		}
+#endif
 		if (state->state != DHS_BOUND && state->state != DHS_INFORM) {
 			LOGDHCP(LOG_DEBUG, "not bound, ignoring Force Renew");
 			return;

Index: src/external/bsd/dhcpcd/dist/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/dhcp6.c:1.24 src/external/bsd/dhcpcd/dist/dhcp6.c:1.25
--- src/external/bsd/dhcpcd/dist/dhcp6.c:1.24	Mon Aug 15 07:04:53 2016
+++ src/external/bsd/dhcpcd/dist/dhcp6.c	Sun Sep 18 11:37:23 2016
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: dhcp6.c,v 1.24 2016/08/15 11:04:53 roy Exp $");
+ __RCSID("$NetBSD: 

CVS commit: src/external/bsd/dhcpcd/dist

2016-08-15 Thread Roy Marples
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 
- __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(, 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, ,
 		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, >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 
- __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)
+

CVS commit: src/external/bsd/dhcpcd/dist

2016-07-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Jul 29 10:07:58 UTC 2016

Modified Files:
src/external/bsd/dhcpcd/dist: arp.c defs.h dhcp-common.c dhcp.c dhcp6.c
dhcp6.h dhcpcd-run-hooks.8.in dhcpcd.8.in dhcpcd.c dhcpcd.conf.5.in
dhcpcd.h duid.c if-bsd.c if-options.c if-options.h if.c if.h ipv4.c
ipv4.h ipv4ll.c ipv6.c ipv6.h ipv6nd.c ipv6nd.h
src/external/bsd/dhcpcd/dist/dhcpcd-hooks: 20-resolv.conf

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/external/bsd/dhcpcd/dist/arp.c
cvs rdiff -u -r1.28 -r1.29 src/external/bsd/dhcpcd/dist/defs.h \
src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in
cvs rdiff -u -r1.18 -r1.19 src/external/bsd/dhcpcd/dist/dhcp-common.c \
src/external/bsd/dhcpcd/dist/dhcpcd.h src/external/bsd/dhcpcd/dist/ipv4.h
cvs rdiff -u -r1.43 -r1.44 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.22 -r1.23 src/external/bsd/dhcpcd/dist/dhcp6.c \
src/external/bsd/dhcpcd/dist/if.c
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/dhcpcd/dist/dhcp6.h \
src/external/bsd/dhcpcd/dist/ipv6nd.h
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in
cvs rdiff -u -r1.48 -r1.49 src/external/bsd/dhcpcd/dist/dhcpcd.8.in
cvs rdiff -u -r1.35 -r1.36 src/external/bsd/dhcpcd/dist/dhcpcd.c
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/duid.c
cvs rdiff -u -r1.31 -r1.32 src/external/bsd/dhcpcd/dist/if-bsd.c
cvs rdiff -u -r1.34 -r1.35 src/external/bsd/dhcpcd/dist/if-options.c
cvs rdiff -u -r1.19 -r1.20 src/external/bsd/dhcpcd/dist/if-options.h \
src/external/bsd/dhcpcd/dist/ipv6.c src/external/bsd/dhcpcd/dist/ipv6.h
cvs rdiff -u -r1.17 -r1.18 src/external/bsd/dhcpcd/dist/if.h \
src/external/bsd/dhcpcd/dist/ipv4ll.c
cvs rdiff -u -r1.23 -r1.24 src/external/bsd/dhcpcd/dist/ipv4.c
cvs rdiff -u -r1.30 -r1.31 src/external/bsd/dhcpcd/dist/ipv6nd.c
cvs rdiff -u -r1.9 -r1.10 \
src/external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf

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.20 src/external/bsd/dhcpcd/dist/arp.c:1.21
--- src/external/bsd/dhcpcd/dist/arp.c:1.20	Fri Jun 17 19:42:31 2016
+++ src/external/bsd/dhcpcd/dist/arp.c	Fri Jul 29 10:07:57 2016
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: arp.c,v 1.20 2016/06/17 19:42:31 roy Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.21 2016/07/29 10:07:57 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -122,32 +122,19 @@ arp_report_conflicted(const struct arp_s
 }
 
 static void
-arp_packet(void *arg)
+arp_packet(struct interface *ifp, uint8_t *data, size_t len)
 {
-	struct interface *ifp = arg;
 	const struct interface *ifn;
-	uint8_t buf[ARP_LEN];
 	struct arphdr ar;
 	struct arp_msg arm;
-	ssize_t bytes;
-	struct iarp_state *state;
+	const struct iarp_state *state;
 	struct arp_state *astate, *astaten;
-	unsigned char *hw_s, *hw_t;
-	int flags;
+	uint8_t *hw_s, *hw_t;
 
-	state = ARP_STATE(ifp);
-	flags = 0;
-	bytes = if_readraw(ifp, state->fd, buf, sizeof(buf), );
-	if (bytes == -1) {
-		logger(ifp->ctx, LOG_ERR,
-		"%s: arp if_readrawpacket: %m", ifp->name);
-		arp_close(ifp);
-		return;
-	}
 	/* We must have a full ARP header */
-	if ((size_t)bytes < sizeof(ar))
+	if (len < sizeof(ar))
 		return;
-	memcpy(, buf, sizeof(ar));
+	memcpy(, data, sizeof(ar));
 	/* Families must match */
 	if (ar.ar_hrd != htons(ifp->family))
 		return;
@@ -165,10 +152,10 @@ arp_packet(void *arg)
 		return;
 
 	/* Get pointers to the hardware addreses */
-	hw_s = buf + sizeof(ar);
+	hw_s = data + sizeof(ar);
 	hw_t = hw_s + ar.ar_hln + ar.ar_pln;
 	/* Ensure we got all the data */
-	if ((hw_t + ar.ar_hln + ar.ar_pln) - buf > bytes)
+	if ((size_t)((hw_t + ar.ar_hln + ar.ar_pln) - data) > len)
 		return;
 	/* Ignore messages from ourself */
 	TAILQ_FOREACH(ifn, ifp->ctx->ifaces, next) {
@@ -190,12 +177,39 @@ arp_packet(void *arg)
 	memcpy(_addr, hw_t + ar.ar_hln, ar.ar_pln);
 
 	/* Run the conflicts */
+	state = ARP_CSTATE(ifp);
 	TAILQ_FOREACH_SAFE(astate, >arp_states, next, astaten) {
 		if (astate->conflicted_cb)
 			astate->conflicted_cb(astate, );
 	}
 }
 
+static void
+arp_read(void *arg)
+{
+	struct interface *ifp = arg;
+	const struct iarp_state *state;
+	uint8_t buf[ARP_LEN];
+	int flags;
+	ssize_t bytes;
+
+	/* Some RAW mechanisms are generic file descriptors, not sockets.
+	 * This means we have no kernel call to just get one packet,
+	 * so we have to process the entire buffer. */
+	state = ARP_CSTATE(ifp);
+	flags = 0;
+	while (!(flags & RAW_EOF)) {
+		bytes = if_readraw(ifp, state->fd, buf, sizeof(buf), );
+		if (bytes == -1) {
+			logger(ifp->ctx, LOG_ERR,
+			"%s: arp if_readrawpacket: %m", ifp->name);
+			arp_close(ifp);
+			return;
+		}
+		arp_packet(ifp, buf, (size_t)bytes);
+	}
+}
+
 int
 arp_open(struct interface *ifp)
 {
@@ -209,7 +223,7 @@ 

CVS commit: src/external/bsd/dhcpcd/dist

2016-06-17 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Jun 17 19:42:32 UTC 2016

Modified Files:
src/external/bsd/dhcpcd/dist: arp.c arp.h bpf-filter.h defs.h
dhcp-common.c dhcp.c dhcp.h dhcp6.c dhcp6.h dhcpcd.c
dhcpcd.conf.5.in dhcpcd.h if-bsd.c if-options.c if.c if.h ipv4.c
ipv4.h ipv4ll.c ipv4ll.h ipv6.c ipv6.h ipv6nd.c script.c
src/external/bsd/dhcpcd/dist/dhcpcd-hooks: 20-resolv.conf 30-hostname

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/external/bsd/dhcpcd/dist/arp.c
cvs rdiff -u -r1.13 -r1.14 src/external/bsd/dhcpcd/dist/arp.h \
src/external/bsd/dhcpcd/dist/dhcp6.h
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/bpf-filter.h
cvs rdiff -u -r1.27 -r1.28 src/external/bsd/dhcpcd/dist/defs.h \
src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in
cvs rdiff -u -r1.17 -r1.18 src/external/bsd/dhcpcd/dist/dhcp-common.c \
src/external/bsd/dhcpcd/dist/dhcpcd.h src/external/bsd/dhcpcd/dist/ipv4.h
cvs rdiff -u -r1.42 -r1.43 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.16 -r1.17 src/external/bsd/dhcpcd/dist/dhcp.h \
src/external/bsd/dhcpcd/dist/if.h src/external/bsd/dhcpcd/dist/ipv4ll.c
cvs rdiff -u -r1.21 -r1.22 src/external/bsd/dhcpcd/dist/dhcp6.c \
src/external/bsd/dhcpcd/dist/if.c
cvs rdiff -u -r1.34 -r1.35 src/external/bsd/dhcpcd/dist/dhcpcd.c
cvs rdiff -u -r1.30 -r1.31 src/external/bsd/dhcpcd/dist/if-bsd.c
cvs rdiff -u -r1.33 -r1.34 src/external/bsd/dhcpcd/dist/if-options.c
cvs rdiff -u -r1.22 -r1.23 src/external/bsd/dhcpcd/dist/ipv4.c
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/ipv4ll.h
cvs rdiff -u -r1.18 -r1.19 src/external/bsd/dhcpcd/dist/ipv6.c \
src/external/bsd/dhcpcd/dist/ipv6.h
cvs rdiff -u -r1.29 -r1.30 src/external/bsd/dhcpcd/dist/ipv6nd.c
cvs rdiff -u -r1.26 -r1.27 src/external/bsd/dhcpcd/dist/script.c
cvs rdiff -u -r1.8 -r1.9 \
src/external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf
cvs rdiff -u -r1.7 -r1.8 \
src/external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname

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.19 src/external/bsd/dhcpcd/dist/arp.c:1.20
--- src/external/bsd/dhcpcd/dist/arp.c:1.19	Mon May  9 10:15:59 2016
+++ src/external/bsd/dhcpcd/dist/arp.c	Fri Jun 17 19:42:31 2016
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: arp.c,v 1.19 2016/05/09 10:15:59 roy Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.20 2016/06/17 19:42:31 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -65,6 +65,7 @@ arp_request(const struct interface *ifp,
 	struct arphdr ar;
 	size_t len;
 	uint8_t *p;
+	const struct iarp_state *state;
 
 	ar.ar_hrd = htons(ifp->family);
 	ar.ar_pro = htons(ETHERTYPE_IP);
@@ -91,7 +92,9 @@ arp_request(const struct interface *ifp,
 	APPEND(, sizeof(sip));
 	ZERO(ifp->hwlen);
 	APPEND(, sizeof(tip));
-	return if_sendrawpacket(ifp, ETHERTYPE_ARP, arp_buffer, len);
+
+	state = ARP_CSTATE(ifp);
+	return if_sendraw(ifp, state->fd, ETHERTYPE_ARP, arp_buffer, len);
 
 eexit:
 	errno = ENOBUFS;
@@ -123,7 +126,7 @@ arp_packet(void *arg)
 {
 	struct interface *ifp = arg;
 	const struct interface *ifn;
-	uint8_t arp_buffer[ARP_LEN];
+	uint8_t buf[ARP_LEN];
 	struct arphdr ar;
 	struct arp_msg arm;
 	ssize_t bytes;
@@ -134,65 +137,62 @@ arp_packet(void *arg)
 
 	state = ARP_STATE(ifp);
 	flags = 0;
-	while (!(flags & RAW_EOF)) {
-		bytes = if_readrawpacket(ifp, ETHERTYPE_ARP,
-		arp_buffer, sizeof(arp_buffer), );
-		if (bytes == -1) {
-			logger(ifp->ctx, LOG_ERR,
-			"%s: arp if_readrawpacket: %m", ifp->name);
-			arp_close(ifp);
-			return;
-		}
-		/* We must have a full ARP header */
-		if ((size_t)bytes < sizeof(ar))
-			continue;
-		memcpy(, arp_buffer, sizeof(ar));
-		/* Families must match */
-		if (ar.ar_hrd != htons(ifp->family))
-			continue;
+	bytes = if_readraw(ifp, state->fd, buf, sizeof(buf), );
+	if (bytes == -1) {
+		logger(ifp->ctx, LOG_ERR,
+		"%s: arp if_readrawpacket: %m", ifp->name);
+		arp_close(ifp);
+		return;
+	}
+	/* We must have a full ARP header */
+	if ((size_t)bytes < sizeof(ar))
+		return;
+	memcpy(, buf, sizeof(ar));
+	/* Families must match */
+	if (ar.ar_hrd != htons(ifp->family))
+		return;
 #if 0
-		/* These checks are enforced in the BPF filter. */
-		/* Protocol must be IP. */
-		if (ar.ar_pro != htons(ETHERTYPE_IP))
-			continue;
-		/* Only these types are recognised */
-		if (ar.ar_op != htons(ARPOP_REPLY) &&
-		ar.ar_op != htons(ARPOP_REQUEST))
-			continue;
+	/* These checks are enforced in the BPF filter. */
+	/* Protocol must be IP. */
+	if (ar.ar_pro != htons(ETHERTYPE_IP))
+		continue;
+	/* Only these types are recognised */
+	if (ar.ar_op != htons(ARPOP_REPLY) &&
+	ar.ar_op != htons(ARPOP_REQUEST))
+		continue;
 #endif
-		if (ar.ar_pln != sizeof(arm.sip.s_addr))
-			continue;
+	if (ar.ar_pln != 

CVS commit: src/external/bsd/dhcpcd/dist

2016-06-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jun  8 01:33:08 UTC 2016

Modified Files:
src/external/bsd/dhcpcd/dist: dhcp-common.c

Log Message:
fix variable length stack allocation from upstream


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/external/bsd/dhcpcd/dist/dhcp-common.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/dhcp-common.c
diff -u src/external/bsd/dhcpcd/dist/dhcp-common.c:1.16 src/external/bsd/dhcpcd/dist/dhcp-common.c:1.17
--- src/external/bsd/dhcpcd/dist/dhcp-common.c:1.16	Mon May  9 06:15:59 2016
+++ src/external/bsd/dhcpcd/dist/dhcp-common.c	Tue Jun  7 21:33:08 2016
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: dhcp-common.c,v 1.16 2016/05/09 10:15:59 roy Exp $");
+ __RCSID("$NetBSD: dhcp-common.c,v 1.17 2016/06/08 01:33:08 christos Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -833,7 +833,7 @@ int
 dhcp_set_leasefile(char *leasefile, size_t len, int family,
 const struct interface *ifp)
 {
-	char ssid[len];
+	char ssid[1 + (IF_SSIDLEN * 4) + 1];
 
 	if (ifp->name[0] == '\0') {
 		strlcpy(leasefile, ifp->ctx->pidfile, len);



CVS commit: src/external/bsd/dhcpcd/dist

2016-05-26 Thread Patrick Welche
Module Name:src
Committed By:   prlw1
Date:   Thu May 26 09:09:47 UTC 2016

Modified Files:
src/external/bsd/dhcpcd/dist: dhcp.c dhcp.h

Log Message:
Handle truncated DHCP messages, provided only the BOOTP vendor area
is truncated.  [3fd740f3ed]
OK from roy@


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/dhcp.h

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/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/dhcp.c:1.41 src/external/bsd/dhcpcd/dist/dhcp.c:1.42
--- src/external/bsd/dhcpcd/dist/dhcp.c:1.41	Mon May  9 20:28:08 2016
+++ src/external/bsd/dhcpcd/dist/dhcp.c	Thu May 26 09:09:47 2016
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: dhcp.c,v 1.41 2016/05/09 20:28:08 martin Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.42 2016/05/26 09:09:47 prlw1 Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -1087,9 +1087,12 @@ make_message(struct bootp **bootpm, cons
 	*p++ = DHO_END;
 	len = (size_t)(p - (uint8_t *)bootp);
 
-	/* Pad out to the BOOTP minimum message length.
-	 * Some DHCP servers incorrectly require this. */
-	while (len < BOOTP_MESSAGE_LENTH_MIN) {
+	/* Pad out to the BOOTP message length.
+	 * Even if we send a DHCP packet with a variable length vendor area,
+	 * some servers / relay agents don't like packets smaller than
+	 * a BOOTP message which is fine because that's stipulated
+	 * in RFC1542 section 2.1. */
+	while (len < sizeof(*bootp)) {
 		*p++ = DHO_PAD;
 		len++;
 	}
@@ -3139,14 +3142,26 @@ dhcp_handlepacket(void *arg)
 			"%s: server %s is not destination",
 			ifp->name, inet_ntoa(from));
 		}
-
+		/*
+		 * DHCP has a variable option area rather than a fixed
+		 * vendor area.
+		 * Because DHCP uses the BOOTP protocol it should
+		 * still send BOOTP sized packets to be RFC compliant.
+		 * However some servers send a truncated vendor area.
+		 * dhcpcd can work fine without the vendor area being sent.
+		 */
 		bytes = get_udp_data(, buf);
-		if (bytes < sizeof(struct bootp)) {
+		if (bytes < offsetof(struct bootp, vend)) {
 			logger(ifp->ctx, LOG_ERR,
 			"%s: truncated packet (%zu) from %s",
 			ifp->name, bytes, inet_ntoa(from));
 			continue;
 		}
+		/* But to make our IS_DHCP macro easy, ensure the vendor
+		 * area has at least 4 octets. */
+		while (bytes < offsetof(struct bootp, vend) + 4)
+			bootp[bytes++] = '\0';
+
 		dhcp_handledhcp(ifp, (struct bootp *)bootp, bytes, );
 		if (state->raw_fd == -1)
 			break;

Index: src/external/bsd/dhcpcd/dist/dhcp.h
diff -u src/external/bsd/dhcpcd/dist/dhcp.h:1.15 src/external/bsd/dhcpcd/dist/dhcp.h:1.16
--- src/external/bsd/dhcpcd/dist/dhcp.h:1.15	Mon May  9 10:15:59 2016
+++ src/external/bsd/dhcpcd/dist/dhcp.h	Thu May 26 09:09:47 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: dhcp.h,v 1.15 2016/05/09 10:15:59 roy Exp $ */
+/* $NetBSD: dhcp.h,v 1.16 2016/05/26 09:09:47 prlw1 Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -133,9 +133,6 @@ enum FQDN {
 	FQDN_BOTH   = 0x31
 };
 
-/* Some crappy DHCP servers require the BOOTP minimum length */
-#define BOOTP_MESSAGE_LENTH_MIN 300
-
 /* Don't import common.h as that defines __unused which causes problems
  * on some Linux systems which define it as part of a structure */
 #if __GNUC__ > 2 || defined(__INTEL_COMPILER)



CVS commit: src/external/bsd/dhcpcd/dist

2016-05-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon May  9 20:28:08 UTC 2016

Modified Files:
src/external/bsd/dhcpcd/dist: dhcp.c

Log Message:
Avoid a "conversion to '__uint16_t' from 'int' may alter its value"
error on some architectures (like m68k).


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/external/bsd/dhcpcd/dist/dhcp.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/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/dhcp.c:1.40 src/external/bsd/dhcpcd/dist/dhcp.c:1.41
--- src/external/bsd/dhcpcd/dist/dhcp.c:1.40	Mon May  9 10:15:59 2016
+++ src/external/bsd/dhcpcd/dist/dhcp.c	Mon May  9 20:28:08 2016
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: dhcp.c,v 1.40 2016/05/09 10:15:59 roy Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.41 2016/05/09 20:28:08 martin Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -890,7 +890,7 @@ make_message(struct bootp **bootpm, cons
 			AREA_CHECK(2);
 			*p++ = DHO_MAXMESSAGESIZE;
 			*p++ = 2;
-			sz = htons((uint16_t)mtu - IP_UDP_SIZE);
+			sz = htons((uint16_t)(mtu - IP_UDP_SIZE));
 			memcpy(p, , 2);
 			p += 2;
 		}



CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2016-05-09 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon May  9 10:19:26 UTC 2016

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
Define _OPENBSD_SOURCE so dhcpcd can access reallocarray(3).


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.30 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.31
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.30	Sun Apr 10 21:06:54 2016
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Mon May  9 10:19:26 2016
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.30 2016/04/10 21:06:54 roy Exp $
+# $NetBSD: Makefile,v 1.31 2016/05/09 10:19:26 roy Exp $
 #
 
 PROG=		dhcpcd
@@ -10,7 +10,7 @@ SRCS+=		if-bsd.c
 WARNS?=		6
 USE_FORT?=	yes	# network client (local server)
 
-CPPFLAGS+=	-DHAVE_CONFIG_H
+CPPFLAGS+=	-DHAVE_CONFIG_H -D_OPENBSD_SOURCE
 
 .include 
 



CVS commit: src/external/bsd/dhcpcd/dist

2016-04-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr 24 18:20:40 UTC 2016

Modified Files:
src/external/bsd/dhcpcd/dist: eloop.c

Log Message:
CID 1358677: (Negative returns) tuck in poll_fd assignment in eloop_open()


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/eloop.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/eloop.c
diff -u src/external/bsd/dhcpcd/dist/eloop.c:1.12 src/external/bsd/dhcpcd/dist/eloop.c:1.13
--- src/external/bsd/dhcpcd/dist/eloop.c:1.12	Sun Apr 10 17:00:53 2016
+++ src/external/bsd/dhcpcd/dist/eloop.c	Sun Apr 24 14:20:40 2016
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: eloop.c,v 1.12 2016/04/10 21:00:53 roy Exp $");
+ __RCSID("$NetBSD: eloop.c,v 1.13 2016/04/24 18:20:40 christos Exp $");
 
 /*
  * eloop - portable event based main loop.
@@ -620,6 +620,8 @@ eloop_open(struct eloop *eloop)
 	return eloop->poll_fd;
 #elif defined (HAVE_EPOLL)
 	return (eloop->poll_fd = epoll_create1(EPOLL_CLOEXEC));
+#else
+	return eloop->poll_fd = -1;
 #endif
 }
 #endif
@@ -790,7 +792,6 @@ eloop_new(void)
 		TAILQ_INIT(>free_timeouts);
 		eloop->exitcode = EXIT_FAILURE;
 #if defined(HAVE_KQUEUE) || defined(HAVE_EPOLL)
-		eloop->poll_fd = -1;
 		if (eloop_open(eloop) == -1) {
 			eloop_free(eloop);
 			return NULL;



  1   2   3   >