Module Name:    src
Committed By:   roy
Date:           Fri Oct 22 13:23:20 UTC 2021

Modified Files:
        src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcp6.c dhcpcd.c
            if-bsd.c if-options.c ipv6.c ipv6.h ipv6nd.c logerr.c privsep.c
            script.c
Added Files:
        src/external/bsd/dhcpcd/dist/hooks: 30-hostname
Removed Files:
        src/external/bsd/dhcpcd/dist/hooks: 30-hostname.in 50-ypbind.in
            dhcpcd-run-hooks.8.in dhcpcd-run-hooks.in
        src/external/bsd/dhcpcd/dist/src: dhcpcd.8.in dhcpcd.conf.5.in

Log Message:
Sync update


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.5 src/external/bsd/dhcpcd/dist/hooks/30-hostname
cvs rdiff -u -r1.1.1.3 -r0 src/external/bsd/dhcpcd/dist/hooks/30-hostname.in
cvs rdiff -u -r1.3 -r0 src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in
cvs rdiff -u -r1.1.1.8 -r0 \
    src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in
cvs rdiff -u -r1.6 -r0 src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in
cvs rdiff -u -r1.17 -r1.18 src/external/bsd/dhcpcd/dist/src/bpf.c
cvs rdiff -u -r1.45 -r1.46 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.27 -r1.28 src/external/bsd/dhcpcd/dist/src/dhcp6.c \
    src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.11 -r0 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in
cvs rdiff -u -r1.48 -r1.49 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.1.1.25 -r0 src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in
cvs rdiff -u -r1.26 -r1.27 src/external/bsd/dhcpcd/dist/src/if-bsd.c
cvs rdiff -u -r1.31 -r1.32 src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.16 -r1.17 src/external/bsd/dhcpcd/dist/src/ipv6.c
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/src/ipv6.h \
    src/external/bsd/dhcpcd/dist/src/privsep.c
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/src/logerr.c
cvs rdiff -u -r1.13 -r1.14 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.17 src/external/bsd/dhcpcd/dist/src/bpf.c:1.18
--- src/external/bsd/dhcpcd/dist/src/bpf.c:1.17	Mon Oct  5 16:02:15 2020
+++ src/external/bsd/dhcpcd/dist/src/bpf.c	Fri Oct 22 13:23:20 2021
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd: BPF arp and bootp filtering
- * Copyright (c) 2006-2020 Roy Marples <r...@marples.name>
+ * Copyright (c) 2006-2021 Roy Marples <r...@marples.name>
  * 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.45 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.46
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.45	Mon Dec 28 13:57:40 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Fri Oct 22 13:23:20 2021
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2020 Roy Marples <r...@marples.name>
+ * Copyright (c) 2006-2021 Roy Marples <r...@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -2031,14 +2031,14 @@ dhcp_finish_dad(struct interface *ifp, s
 
 #ifdef IPV4LL
 	/* Stop IPv4LL now we have a working DHCP address */
-	ipv4ll_drop(ifp);
+	if (!IN_LINKLOCAL(ntohl(ia->s_addr)))
+		ipv4ll_drop(ifp);
 #endif
 
 	if (ifp->options->options & DHCPCD_INFORM)
 		dhcp_inform(ifp);
 }
 
-
 static bool
 dhcp_addr_duplicated(struct interface *ifp, struct in_addr *ia)
 {
@@ -2069,7 +2069,7 @@ dhcp_addr_duplicated(struct interface *i
 	if (opts & (DHCPCD_STATIC | DHCPCD_INFORM)) {
 		state->reason = "EXPIRE";
 		script_runreason(ifp, state->reason);
-#define NOT_ONLY_SELF (DHCPCD_MASTER | DHCPCD_IPV6RS | DHCPCD_DHCP6)
+#define NOT_ONLY_SELF (DHCPCD_MANAGER | DHCPCD_IPV6RS | DHCPCD_DHCP6)
 		if (!(ctx->options & NOT_ONLY_SELF))
 			eloop_exit(ifp->ctx->eloop, EXIT_FAILURE);
 		return deleted;
@@ -2380,8 +2380,9 @@ dhcp_bind(struct interface *ifp)
 	dhcp_closebpf(ifp);
 
 openudp:
-	/* If not in master mode, open an address specific socket. */
-	if (ctx->options & DHCPCD_MASTER ||
+	/* If not in manager mode, open an address specific socket. */
+	if (ctx->options & DHCPCD_MANAGER ||
+	    ifo->options & DHCPCD_STATIC ||
 	    (state->old != NULL &&
 	     state->old->yiaddr == state->new->yiaddr &&
 	     old_state & STATE_ADDED && !(old_state & STATE_FAKE)))
@@ -2399,7 +2400,7 @@ openudp:
 	state->udp_rfd = dhcp_openudp(&state->addr->addr);
 	if (state->udp_rfd == -1) {
 		logerr(__func__);
-		/* Address sharing without master mode is not supported.
+		/* Address sharing without manager mode is not supported.
 		 * It's also possible another DHCP client could be running,
 		 * which is even worse.
 		 * We still need to work, so re-open BPF. */
@@ -2569,7 +2570,6 @@ dhcp_inform(struct interface *ifp)
 	state = D_STATE(ifp);
 	ifo = ifp->options;
 
-	state->state = DHS_INFORM;
 	free(state->offer);
 	state->offer = NULL;
 	state->offer_len = 0;
@@ -2610,6 +2610,7 @@ dhcp_inform(struct interface *ifp)
 		}
 	}
 
+	state->state = DHS_INFORM;
 	state->addr = ia;
 	state->offer_len = dhcp_message_new(&state->offer,
 	    &ia->addr, &ia->mask);
@@ -3952,9 +3953,9 @@ dhcp_start1(void *arg)
 
 	/* Listen on *.*.*.*:bootpc so that the kernel never sends an
 	 * ICMP port unreachable message back to the DHCP server.
-	 * Only do this in master mode so we don't swallow messages
+	 * Only do this in manager mode so we don't swallow messages
 	 * for dhcpcd running on another interface. */
-	if ((ctx->options & (DHCPCD_MASTER|DHCPCD_PRIVSEP)) == DHCPCD_MASTER
+	if ((ctx->options & (DHCPCD_MANAGER|DHCPCD_PRIVSEP)) == DHCPCD_MANAGER
 	    && ctx->udp_rfd == -1)
 	{
 		ctx->udp_rfd = dhcp_openudp(NULL);
@@ -4244,7 +4245,7 @@ dhcp_handleifa(int cmd, struct ipv4_addr
 
 #ifdef PRIVSEP
 	if (IN_PRIVSEP_SE(ifp->ctx) &&
-	    !(ifp->ctx->options & (DHCPCD_MASTER | DHCPCD_CONFIGURE)) &&
+	    !(ifp->ctx->options & (DHCPCD_MANAGER | DHCPCD_CONFIGURE)) &&
 	    IN_ARE_ADDR_EQUAL(&state->lease.addr, &ia->addr))
 	{
 		state->addr = ia;
@@ -4255,37 +4256,38 @@ dhcp_handleifa(int cmd, struct ipv4_addr
 	}
 #endif
 
+	/* If we have requested a specific address, return now.
+	 * The below code is only for when inform or static has been
+	 * requested without a specific address. */
+	if (ifo->req_addr.s_addr != INADDR_ANY)
+		return ia;
+
+	/* Only inform if we are NOT in the inform state or bound. */
 	if (ifo->options & DHCPCD_INFORM) {
-		if (state->state != DHS_INFORM)
+		if (state->state != DHS_INFORM && state->state != DHS_BOUND)
 			dhcp_inform(ifp);
 		return ia;
 	}
 
+	/* Static and inform are mutually exclusive. If not static, return. */
 	if (!(ifo->options & DHCPCD_STATIC))
 		return ia;
-	if (ifo->req_addr.s_addr != INADDR_ANY)
-		return ia;
 
 	free(state->old);
 	state->old = state->new;
 	state->new_len = dhcp_message_new(&state->new, &ia->addr, &ia->mask);
 	if (state->new == NULL)
 		return ia;
+
 	if (ifp->flags & IFF_POINTOPOINT) {
 		for (i = 1; i < 255; i++)
 			if (i != DHO_ROUTER && has_option_mask(ifo->dstmask,i))
 				dhcp_message_add_addr(state->new, i, ia->brd);
 	}
+
 	state->reason = "STATIC";
 	rt_build(ifp->ctx, AF_INET);
 	script_runreason(ifp, state->reason);
-	if (ifo->options & DHCPCD_INFORM) {
-		state->state = DHS_INFORM;
-		dhcp_new_xid(ifp);
-		state->lease.server.s_addr = INADDR_ANY;
-		state->addr = ia;
-		dhcp_inform(ifp);
-	}
 
 	return ia;
 }

Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.27 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.28
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.27	Mon Dec 28 13:57:40 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c	Fri Oct 22 13:23:20 2021
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2020 Roy Marples <r...@marples.name>
+ * Copyright (c) 2006-2021 Roy Marples <r...@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -637,7 +637,7 @@ dhcp6_makemessage(struct interface *ifp)
 	uint8_t type;
 	uint16_t si_len, uni_len, n_options;
 	uint8_t *o_lenp;
-	struct if_options *ifo;
+	struct if_options *ifo = ifp->options;
 	const struct dhcp_opt *opt, *opt2;
 	const struct ipv6_addr *ap;
 	char hbuf[HOSTNAME_MAX_LEN + 1];
@@ -658,8 +658,50 @@ dhcp6_makemessage(struct interface *ifp)
 		state->send = NULL;
 	}
 
-	ifo = ifp->options;
-	fqdn = ifo->fqdn;
+	switch(state->state) {
+	case DH6S_INIT: /* FALLTHROUGH */
+	case DH6S_DISCOVER:
+		type = DHCP6_SOLICIT;
+		break;
+	case DH6S_REQUEST:
+		type = DHCP6_REQUEST;
+		break;
+	case DH6S_CONFIRM:
+		type = DHCP6_CONFIRM;
+		break;
+	case DH6S_REBIND:
+		type = DHCP6_REBIND;
+		break;
+	case DH6S_RENEW:
+		type = DHCP6_RENEW;
+		break;
+	case DH6S_INFORM:
+		type = DHCP6_INFORMATION_REQ;
+		break;
+	case DH6S_RELEASE:
+		type = DHCP6_RELEASE;
+		break;
+	case DH6S_DECLINE:
+		type = DHCP6_DECLINE;
+		break;
+	default:
+		errno = EINVAL;
+		return -1;
+	}
+
+	/* RFC 4704 Section 5 says we can only send FQDN for these
+	 * message types. */
+	switch(type) {
+	case DHCP6_SOLICIT:
+	case DHCP6_REQUEST:
+	case DHCP6_RENEW:
+	case DHCP6_REBIND:
+		fqdn = ifo->fqdn;
+		break;
+	default:
+		fqdn = FQDN_DISABLE;
+		break;
+	}
 
 	if (fqdn == FQDN_DISABLE && ifo->options & DHCPCD_HOSTNAME) {
 		/* We're sending the DHCPv4 hostname option, so send FQDN as
@@ -823,37 +865,6 @@ dhcp6_makemessage(struct interface *ifp)
 	}
 
 	switch(state->state) {
-	case DH6S_INIT: /* FALLTHROUGH */
-	case DH6S_DISCOVER:
-		type = DHCP6_SOLICIT;
-		break;
-	case DH6S_REQUEST:
-		type = DHCP6_REQUEST;
-		break;
-	case DH6S_CONFIRM:
-		type = DHCP6_CONFIRM;
-		break;
-	case DH6S_REBIND:
-		type = DHCP6_REBIND;
-		break;
-	case DH6S_RENEW:
-		type = DHCP6_RENEW;
-		break;
-	case DH6S_INFORM:
-		type = DHCP6_INFORMATION_REQ;
-		break;
-	case DH6S_RELEASE:
-		type = DHCP6_RELEASE;
-		break;
-	case DH6S_DECLINE:
-		type = DHCP6_DECLINE;
-		break;
-	default:
-		errno = EINVAL;
-		return -1;
-	}
-
-	switch(state->state) {
 	case DH6S_REQUEST: /* FALLTHROUGH */
 	case DH6S_RENEW:   /* FALLTHROUGH */
 	case DH6S_RELEASE:
@@ -868,11 +879,11 @@ dhcp6_makemessage(struct interface *ifp)
 		break;
 	}
 
-	/* In non master mode we listen and send from fixed addresses.
+	/* In non manager mode we listen and send from fixed addresses.
 	 * We should try and match an address we have to unicast to,
 	 * but for now this is the safest policy. */
-	if (unicast != NULL && !(ifp->ctx->options & DHCPCD_MASTER)) {
-		logdebugx("%s: ignoring unicast option as not master",
+	if (unicast != NULL && !(ifp->ctx->options & DHCPCD_MANAGER)) {
+		logdebugx("%s: ignoring unicast option as not manager",
 		    ifp->name);
 		unicast = NULL;
 	}
@@ -1638,7 +1649,7 @@ dhcp6_startinform(void *arg)
 
 	ifp = arg;
 	state = D6_STATE(ifp);
-	if (state->new == NULL && !state->failed)
+	if (state->new_start || (state->new == NULL && !state->failed))
 		llevel = LOG_INFO;
 	else
 		llevel = LOG_DEBUG;
@@ -3035,18 +3046,25 @@ static void
 dhcp6_bind(struct interface *ifp, const char *op, const char *sfrom)
 {
 	struct dhcp6_state *state = D6_STATE(ifp);
-	bool timedout = (op == NULL), has_new = false, confirmed;
+	bool timedout = (op == NULL), confirmed;
 	struct ipv6_addr *ia;
 	int loglevel;
 	struct timespec now;
 
-	TAILQ_FOREACH(ia, &state->addrs, next) {
-		if (ia->flags & IPV6_AF_NEW) {
-			has_new = true;
-			break;
+	if (state->state == DH6S_RENEW && !state->new_start) {
+		loglevel = LOG_DEBUG;
+		TAILQ_FOREACH(ia, &state->addrs, next) {
+			if (ia->flags & IPV6_AF_NEW) {
+				loglevel = LOG_INFO;
+				break;
+			}
 		}
-	}
-	loglevel = has_new || state->state != DH6S_RENEW ? LOG_INFO : LOG_DEBUG;
+	} else if (state->state == DH6S_INFORM)
+		loglevel = state->new_start ? LOG_INFO : LOG_DEBUG;
+	else
+		loglevel = LOG_INFO;
+	state->new_start = false;
+
 	if (!timedout) {
 		logmessage(loglevel, "%s: %s received from %s",
 		    ifp->name, op, sfrom);
@@ -3245,7 +3263,7 @@ dhcp6_bind(struct interface *ifp, const 
 
 	if (ifp->ctx->options & DHCPCD_TEST ||
 	    (ifp->options->options & DHCPCD_INFORM &&
-	    !(ifp->ctx->options & DHCPCD_MASTER)))
+	    !(ifp->ctx->options & DHCPCD_MANAGER)))
 	{
 		eloop_exit(ifp->ctx->eloop, EXIT_SUCCESS);
 	}
@@ -3852,7 +3870,7 @@ dhcp6_start1(void *arg)
 	size_t i;
 	const struct dhcp_compat *dhc;
 
-	if ((ctx->options & (DHCPCD_MASTER|DHCPCD_PRIVSEP)) == DHCPCD_MASTER &&
+	if ((ctx->options & (DHCPCD_MANAGER|DHCPCD_PRIVSEP)) == DHCPCD_MANAGER &&
 	    ctx->dhcp6_rfd == -1)
 	{
 		ctx->dhcp6_rfd = dhcp6_openudp(0, NULL);
@@ -3923,7 +3941,13 @@ dhcp6_start(struct interface *ifp, enum 
 			    (state->state == DH6S_DISCOVER &&
 			    !(ifp->options->options & DHCPCD_IA_FORCED) &&
 			    !ipv6nd_hasradhcp(ifp, true)))
+			{
+				/* We don't want log spam when the RA
+				 * has just adjusted it's prefix times. */
+				if (state->state != DH6S_INFORMED)
+					state->new_start = true;
 				dhcp6_startinform(ifp);
+			}
 			break;
 		case DH6S_REQUEST:
 			if (ifp->options->options & DHCPCD_DHCP6 &&
@@ -3972,6 +3996,7 @@ dhcp6_start(struct interface *ifp, enum 
 	TAILQ_INIT(&state->addrs);
 
 gogogo:
+	state->new_start = true;
 	state->state = init_state;
 	state->lerror = 0;
 	state->failed = false;
@@ -4155,11 +4180,11 @@ dhcp6_handleifa(int cmd, struct ipv6_add
 	struct dhcp6_state *state;
 	struct interface *ifp = ia->iface;
 
-	/* If not running in master mode, listen to this address */
+	/* If not running in manager mode, listen to this address */
 	if (cmd == RTM_NEWADDR &&
 	    !(ia->addr_flags & IN6_IFF_NOTUSEABLE) &&
 	    ifp->active == IF_ACTIVE_USER &&
-	    !(ifp->ctx->options & DHCPCD_MASTER) &&
+	    !(ifp->ctx->options & DHCPCD_MANAGER) &&
 	    ifp->options->options & DHCPCD_DHCP6)
 	{
 #ifdef PRIVSEP
Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.27 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.28
--- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.27	Mon Dec 28 13:57:40 2020
+++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c	Fri Oct 22 13:23:20 2021
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd - IPv6 ND handling
- * Copyright (c) 2006-2020 Roy Marples <r...@marples.name>
+ * Copyright (c) 2006-2021 Roy Marples <r...@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without

Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.48 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.49
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.48	Mon Dec 28 13:57:40 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Fri Oct 22 13:23:20 2021
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2020 Roy Marples <r...@marples.name>
+ * Copyright (c) 2006-2021 Roy Marples <r...@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 
-static const char dhcpcd_copyright[] = "Copyright (c) 2006-2020 Roy Marples";
+static const char dhcpcd_copyright[] = "Copyright (c) 2006-2021 Roy Marples";
 
 #include <sys/file.h>
 #include <sys/ioctl.h>
@@ -107,7 +107,7 @@ printf("usage: "PACKAGE"\t[-146ABbDdEGgH
 	"\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] [-j, --logfile logfile]\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"
@@ -196,7 +196,7 @@ handle_exit_timeout(void *arg)
 
 	ctx = arg;
 	logerrx("timed out");
-	if (!(ctx->options & DHCPCD_MASTER)) {
+	if (!(ctx->options & DHCPCD_MANAGER)) {
 		struct interface *ifp;
 
 		TAILQ_FOREACH(ifp, ctx->ifaces, next) {
@@ -370,12 +370,12 @@ dhcpcd_daemonise(struct dhcpcd_ctx *ctx)
 
 	/*
 	 * Stop writing to stderr.
-	 * On the happy path, only the master process writes to stderr,
+	 * On the happy path, only the manager process writes to stderr,
 	 * so this just stops wasting fprintf calls to nowhere.
 	 * All other calls - ie errors in privsep processes or script output,
 	 * will error when printing.
 	 * If we *really* want to fix that, then we need to suck
-	 * stderr/stdout in the master process and either disacrd it or pass
+	 * stderr/stdout in the manager process and either disacrd it or pass
 	 * it to the launcher process and then to stderr.
 	 */
 	logopts &= ~LOGERR_ERR;
@@ -427,7 +427,7 @@ stop_interface(struct interface *ifp, co
 	ifp->active = IF_INACTIVE;
 	ifp->options->options &= ~DHCPCD_STOPPING;
 
-	if (!(ctx->options & (DHCPCD_MASTER | DHCPCD_TEST)))
+	if (!(ctx->options & (DHCPCD_MANAGER | DHCPCD_TEST)))
 		eloop_exit(ctx->eloop, EXIT_FAILURE);
 }
 
@@ -980,7 +980,7 @@ dhcpcd_prestartinterface(void *arg)
 	} else
 		randmac_down = false;
 
-	if ((!(ctx->options & DHCPCD_MASTER) ||
+	if ((!(ctx->options & DHCPCD_MANAGER) ||
 	    ifp->options->options & DHCPCD_IF_UP || randmac_down) &&
 	    !(ifp->flags & IFF_UP))
 	{
@@ -1311,8 +1311,8 @@ reload_config(struct dhcpcd_ctx *ctx)
 	/* We need to preserve these options. */
 	if (ctx->options & DHCPCD_STARTED)
 		ifo->options |= DHCPCD_STARTED;
-	if (ctx->options & DHCPCD_MASTER)
-		ifo->options |= DHCPCD_MASTER;
+	if (ctx->options & DHCPCD_MANAGER)
+		ifo->options |= DHCPCD_MANAGER;
 	if (ctx->options & DHCPCD_DAEMONISED)
 		ifo->options |= DHCPCD_DAEMONISED;
 	if (ctx->options & DHCPCD_PRIVSEP)
@@ -1988,7 +1988,7 @@ main(int argc, char **argv, char **envp)
 	}
 
 	if (optind != argc - 1)
-		ctx.options |= DHCPCD_MASTER;
+		ctx.options |= DHCPCD_MANAGER;
 
 	logsetopts(logopts);
 	logopen(ctx.logfile);
@@ -2068,7 +2068,7 @@ main(int argc, char **argv, char **envp)
 printpidfile:
 		/* If we have any other args, we should run as a single dhcpcd
 		 *  instance for that interface. */
-		if (optind == argc - 1 && !(ctx.options & DHCPCD_MASTER)) {
+		if (optind == argc - 1 && !(ctx.options & DHCPCD_MANAGER)) {
 			const char *per;
 			const char *ifname;
 
@@ -2094,7 +2094,7 @@ printpidfile:
 		} else {
 			snprintf(ctx.pidfile, sizeof(ctx.pidfile),
 			    PIDFILE, "", "", "");
-			ctx.options |= DHCPCD_MASTER;
+			ctx.options |= DHCPCD_MANAGER;
 		}
 		if (ctx.options & DHCPCD_PRINT_PIDFILE) {
 			printf("%s\n", ctx.pidfile);
@@ -2170,7 +2170,7 @@ printpidfile:
 	{
 		ctx.options |= DHCPCD_FORKED; /* pretend child process */
 #ifdef PRIVSEP
-		if (IN_PRIVSEP(&ctx) && ps_mastersandbox(&ctx, NULL) == -1)
+		if (IN_PRIVSEP(&ctx) && ps_managersandbox(&ctx, NULL) == -1)
 			goto exit_failure;
 #endif
 		ifp = calloc(1, sizeof(*ifp));
@@ -2214,10 +2214,10 @@ printpidfile:
 	    !(ctx.options & DHCPCD_TEST))
 	{
 		ctx.options |= DHCPCD_FORKED; /* avoid socket unlink */
-		if (!(ctx.options & DHCPCD_MASTER))
+		if (!(ctx.options & DHCPCD_MANAGER))
 			ctx.control_fd = control_open(argv[optind], family,
 			    ctx.options & DHCPCD_DUMPLEASE);
-		if (!(ctx.options & DHCPCD_MASTER) && ctx.control_fd == -1)
+		if (!(ctx.options & DHCPCD_MANAGER) && ctx.control_fd == -1)
 			ctx.control_fd = control_open(argv[optind], AF_UNSPEC,
 			    ctx.options & DHCPCD_DUMPLEASE);
 		if (ctx.control_fd == -1)
@@ -2226,7 +2226,7 @@ printpidfile:
 		if (ctx.control_fd != -1) {
 #ifdef PRIVSEP
 			if (IN_PRIVSEP(&ctx) &&
-			    ps_mastersandbox(&ctx, NULL) == -1)
+			    ps_managersandbox(&ctx, NULL) == -1)
 				goto exit_failure;
 #endif
 			if (!(ctx.options & DHCPCD_DUMPLEASE))
@@ -2284,7 +2284,7 @@ printpidfile:
 
 #if defined(USE_SIGNALS) && !defined(THERE_IS_NO_FORK)
 	if (!(ctx.options & DHCPCD_DAEMONISE))
-		goto start_master;
+		goto start_manager;
 
 	if (xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, fork_fd) == -1 ||
 	    (ctx.stderr_valid &&
@@ -2368,7 +2368,7 @@ printpidfile:
 			    dhcpcd_stderr_cb, &ctx);
 		}
 #ifdef PRIVSEP
-		if (IN_PRIVSEP(&ctx) && ps_mastersandbox(&ctx, NULL) == -1)
+		if (IN_PRIVSEP(&ctx) && ps_managersandbox(&ctx, NULL) == -1)
 			goto exit_failure;
 #endif
 		goto run_loop;
@@ -2376,8 +2376,8 @@ printpidfile:
 
 	/* We have now forked, setsid, forked once more.
 	 * From this point on, we are the controlling daemon. */
-	logdebugx("spawned master process on PID %d", getpid());
-start_master:
+	logdebugx("spawned manager process on PID %d", getpid());
+start_manager:
 	ctx.options |= DHCPCD_STARTED;
 	if ((pid = pidfile_lock(ctx.pidfile)) != 0) {
 		logerr("%s: pidfile_lock %d", __func__, pid);
@@ -2408,7 +2408,7 @@ start_master:
 
 	if (!(ctx.options & DHCPCD_TEST)) {
 		if (control_start(&ctx,
-		    ctx.options & DHCPCD_MASTER ?
+		    ctx.options & DHCPCD_MANAGER ?
 		    NULL : argv[optind], family) == -1)
 		{
 			logerr("%s: control_start", __func__);
@@ -2420,13 +2420,13 @@ start_master:
 	/* Start any dev listening plugin which may want to
 	 * change the interface name provided by the kernel */
 	if (!IN_PRIVSEP(&ctx) &&
-	    (ctx.options & (DHCPCD_MASTER | DHCPCD_DEV)) ==
-	    (DHCPCD_MASTER | DHCPCD_DEV))
+	    (ctx.options & (DHCPCD_MANAGER | DHCPCD_DEV)) ==
+	    (DHCPCD_MANAGER | DHCPCD_DEV))
 		dev_start(&ctx, dhcpcd_handleinterface);
 #endif
 
 	setproctitle("%s%s%s",
-	    ctx.options & DHCPCD_MASTER ? "[master]" : argv[optind],
+	    ctx.options & DHCPCD_MANAGER ? "[manager]" : argv[optind],
 	    ctx.options & DHCPCD_IPV4 ? " [ip4]" : "",
 	    ctx.options & DHCPCD_IPV6 ? " [ip6]" : "");
 
@@ -2450,7 +2450,7 @@ start_master:
 	eloop_event_add(ctx.eloop, ctx.link_fd, dhcpcd_handlelink, &ctx);
 
 #ifdef PRIVSEP
-	if (IN_PRIVSEP(&ctx) && ps_mastersandbox(&ctx, "stdio route") == -1)
+	if (IN_PRIVSEP(&ctx) && ps_managersandbox(&ctx, "stdio route") == -1)
 		goto exit_failure;
 #endif
 
@@ -2511,7 +2511,7 @@ start_master:
 	}
 
 	if (!(ctx.options & DHCPCD_BACKGROUND)) {
-		if (ctx.options & DHCPCD_MASTER)
+		if (ctx.options & DHCPCD_MANAGER)
 			t = ifo->timeout;
 		else {
 			t = 0;

Index: src/external/bsd/dhcpcd/dist/src/if-bsd.c
diff -u src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.26 src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.27
--- src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.26	Mon Dec 28 13:57:40 2020
+++ src/external/bsd/dhcpcd/dist/src/if-bsd.c	Fri Oct 22 13:23:20 2021
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * BSD interface driver for dhcpcd
- * Copyright (c) 2006-2020 Roy Marples <r...@marples.name>
+ * Copyright (c) 2006-2021 Roy Marples <r...@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -235,6 +235,7 @@ if_closesockets_os(struct dhcpcd_ctx *ct
 		close(priv->pf_inet6_fd);
 	free(priv);
 	ctx->priv = NULL;
+	free(ctx->rt_missfilter);
 }
 
 #if defined(SIOCALIFADDR) && defined(IFLR_ACTIVE) /*NetBSD */
@@ -626,6 +627,8 @@ if_findsa(struct dhcpcd_ctx *ctx, const 
 		sin = (const void *)sa;
 		if ((ia = ipv4_findmaskaddr(ctx, &sin->sin_addr)))
 			return ia->iface;
+		if ((ia = ipv4_findmaskbrd(ctx, &sin->sin_addr)))
+			return ia->iface;
 		break;
 	}
 #endif

Index: src/external/bsd/dhcpcd/dist/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.31 src/external/bsd/dhcpcd/dist/src/if-options.c:1.32
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.31	Mon Dec 28 13:57:40 2020
+++ src/external/bsd/dhcpcd/dist/src/if-options.c	Fri Oct 22 13:23:20 2021
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2020 Roy Marples <r...@marples.name>
+ * Copyright (c) 2006-2021 Roy Marples <r...@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -104,7 +104,7 @@ const struct option cf_options[] = {
 	{"broadcast",       no_argument,       NULL, 'J'},
 	{"nolink",          no_argument,       NULL, 'K'},
 	{"noipv4ll",        no_argument,       NULL, 'L'},
-	{"master",          no_argument,       NULL, 'M'},
+	{"manager",         no_argument,       NULL, 'M'},
 	{"renew",           no_argument,       NULL, 'N'},
 	{"nooption",        required_argument, NULL, 'O'},
 	{"printpidfile",    no_argument,       NULL, 'P'},
@@ -321,9 +321,10 @@ parse_str(char *sbuf, size_t slen, const
 						break;
 					c[i] = *str++;
 				}
-				if (c[1] != '\0' && sbuf) {
+				if (c[1] != '\0') {
 					c[2] = '\0';
-					*sbuf++ = (char)strtol(c, NULL, 16);
+					if (sbuf)
+						*sbuf++ = (char)strtol(c, NULL, 16);
 				} else
 					l--;
 				break;
@@ -335,11 +336,12 @@ parse_str(char *sbuf, size_t slen, const
 						break;
 					c[i] = *str++;
 				}
-				if (c[2] != '\0' && sbuf) {
+				if (c[2] != '\0') {
 					i = (int)strtol(c, NULL, 8);
 					if (i > 255)
 						i = 255;
-					*sbuf ++= (char)i;
+					if (sbuf)
+						*sbuf++ = (char)i;
 				} else
 					l--;
 				break;
@@ -1068,7 +1070,7 @@ parse_option(struct dhcpcd_ctx *ctx, con
 		ifo->options &= ~DHCPCD_IPV4LL;
 		break;
 	case 'M':
-		ifo->options |= DHCPCD_MASTER;
+		ifo->options |= DHCPCD_MANAGER;
 		break;
 	case 'O':
 		ARG_REQUIRED;
@@ -1356,7 +1358,7 @@ parse_option(struct dhcpcd_ctx *ctx, con
 #endif
 	case O_IAID:
 		ARG_REQUIRED;
-		if (ctx->options & DHCPCD_MASTER && !IN_CONFIG_BLOCK(ifo)) {
+		if (ctx->options & DHCPCD_MANAGER && !IN_CONFIG_BLOCK(ifo)) {
 			logerrx("IAID must belong in an interface block");
 			return -1;
 		}
@@ -1398,7 +1400,7 @@ parse_option(struct dhcpcd_ctx *ctx, con
 			logwarnx("%s: IA_PD not compiled in", ifname);
 			return -1;
 #else
-			if (ctx->options & DHCPCD_MASTER &&
+			if (ctx->options & DHCPCD_MANAGER &&
 			    !IN_CONFIG_BLOCK(ifo))
 			{
 				logerrx("IA PD must belong in an "
@@ -1408,7 +1410,7 @@ parse_option(struct dhcpcd_ctx *ctx, con
 			i = D6_OPTION_IA_PD;
 #endif
 		}
-		if (ctx->options & DHCPCD_MASTER &&
+		if (ctx->options & DHCPCD_MANAGER &&
 		    !IN_CONFIG_BLOCK(ifo) && arg)
 		{
 			logerrx("IA with IAID must belong in an "

Index: src/external/bsd/dhcpcd/dist/src/ipv6.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6.c:1.16 src/external/bsd/dhcpcd/dist/src/ipv6.c:1.17
--- src/external/bsd/dhcpcd/dist/src/ipv6.c:1.16	Fri Nov 20 13:24:58 2020
+++ src/external/bsd/dhcpcd/dist/src/ipv6.c	Fri Oct 22 13:23:20 2021
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2020 Roy Marples <r...@marples.name>
+ * Copyright (c) 2006-2021 Roy Marples <r...@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -596,7 +596,7 @@ ipv6_deletedaddr(struct ipv6_addr *ia)
 
 #ifdef DHCP6
 #ifdef PRIVSEP
-	if (!(ia->iface->ctx->options & DHCPCD_MASTER))
+	if (!(ia->iface->ctx->options & DHCPCD_MANAGER))
 		ps_inet_closedhcp6(ia);
 #elif defined(SMALL)
 	UNUSED(ia);

Index: src/external/bsd/dhcpcd/dist/src/ipv6.h
diff -u src/external/bsd/dhcpcd/dist/src/ipv6.h:1.12 src/external/bsd/dhcpcd/dist/src/ipv6.h:1.13
--- src/external/bsd/dhcpcd/dist/src/ipv6.h:1.12	Thu Jul  2 13:59:19 2020
+++ src/external/bsd/dhcpcd/dist/src/ipv6.h	Fri Oct 22 13:23:20 2021
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2020 Roy Marples <r...@marples.name>
+ * Copyright (c) 2006-2021 Roy Marples <r...@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
Index: src/external/bsd/dhcpcd/dist/src/privsep.c
diff -u src/external/bsd/dhcpcd/dist/src/privsep.c:1.12 src/external/bsd/dhcpcd/dist/src/privsep.c:1.13
--- src/external/bsd/dhcpcd/dist/src/privsep.c:1.12	Mon Dec 28 13:57:40 2020
+++ src/external/bsd/dhcpcd/dist/src/privsep.c	Fri Oct 22 13:23:20 2021
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * Privilege Separation for dhcpcd
- * Copyright (c) 2006-2020 Roy Marples <r...@marples.name>
+ * Copyright (c) 2006-2021 Roy Marples <r...@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -33,8 +33,8 @@
  * or address specific listener.
  * Spawn an unpriv process to send/receive common network data.
  * Then drop all privs and start running.
- * Every process aside from the privileged actioneer is chrooted.
- * All privsep processes ignore signals - only the master process accepts them.
+ * Every process aside from the privileged proxy is chrooted.
+ * All privsep processes ignore signals - only the manager process accepts them.
  *
  * dhcpcd will maintain the config file in the chroot, no need to handle
  * this in a script or something.
@@ -81,6 +81,15 @@
 #include <util.h>
 #endif
 
+/* CMSG_ALIGN is a Linux extension */
+#ifndef CMSG_ALIGN
+#define CMSG_ALIGN(n)	(CMSG_SPACE((n)) - CMSG_SPACE(0))
+#endif
+
+/* Calculate number of padding bytes to achieve 'struct cmsghdr' alignment */
+#define CALC_CMSG_PADLEN(has_cmsg, pos) \
+    ((has_cmsg) ? (socklen_t)(CMSG_ALIGN((pos)) - (pos)) : 0)
+
 int
 ps_init(struct dhcpcd_ctx *ctx)
 {
@@ -369,7 +378,15 @@ ps_dostart(struct dhcpcd_ctx *ctx,
 		ctx->fork_fd = -1;
 	}
 	pidfile_clean();
+
 	eloop_clear(ctx->eloop);
+	eloop_signal_set_cb(ctx->eloop,
+	    dhcpcd_signals, dhcpcd_signals_len, signal_cb, ctx);
+	/* ctx->sigset aready has the initial sigmask set in main() */
+	if (eloop_signal_mask(ctx->eloop, NULL) == -1) {
+		logerr("%s: eloop_signal_mask", __func__);
+		goto errexit;
+	}
 
 	/* We are not root */
 	if (priv_fd != &ctx->ps_root_fd) {
@@ -393,15 +410,6 @@ ps_dostart(struct dhcpcd_ctx *ctx,
 		ctx->ps_inet_fd = -1;
 	}
 
-	eloop_signal_set_cb(ctx->eloop,
-	    dhcpcd_signals, dhcpcd_signals_len, signal_cb, ctx);
-
-	/* ctx->sigset aready has the initial sigmask set in main() */
-	if (eloop_signal_mask(ctx->eloop, NULL) == -1) {
-		logerr("%s: eloop_signal_mask", __func__);
-		goto errexit;
-	}
-
 	if (eloop_event_add(ctx->eloop, *priv_fd, recv_msg, recv_ctx) == -1)
 	{
 		logerr("%s: eloop_event_add", __func__);
@@ -466,7 +474,7 @@ ps_start(struct dhcpcd_ctx *ctx)
 	case 0:
 		return 0;
 	default:
-		logdebugx("spawned privileged actioneer on PID %d", pid);
+		logdebugx("spawned privileged proxy on PID %d", pid);
 	}
 
 	/* No point in spawning the generic network listener if we're
@@ -532,7 +540,7 @@ ps_entersandbox(const char *_pledge, con
 }
 
 int
-ps_mastersandbox(struct dhcpcd_ctx *ctx, const char *_pledge)
+ps_managersandbox(struct dhcpcd_ctx *ctx, const char *_pledge)
 {
 	const char *sandbox = NULL;
 	bool forked;
@@ -583,7 +591,7 @@ ps_mastersandbox(struct dhcpcd_ctx *ctx,
 		return -1;
 	} else if (ctx->options & DHCPCD_LAUNCHER ||
 		  ((!(ctx->options & DHCPCD_DAEMONISE)) &&
-		   ctx->options & DHCPCD_MASTER))
+		   ctx->options & DHCPCD_MANAGER))
 		logdebugx("sandbox: %s", sandbox);
 	return 0;
 }
@@ -607,7 +615,7 @@ ps_stop(struct dhcpcd_ctx *ctx)
 		ret = r;
 
 	/* We've been chrooted, so we need to tell the
-	 * privileged actioneer to remove the pidfile. */
+	 * privileged proxy to remove the pidfile. */
 	ps_root_unlink(ctx, ctx->pidfile);
 
 	r = ps_root_stop(ctx);
@@ -656,9 +664,11 @@ ps_unrollmsg(struct msghdr *msg, struct 
     const void *data, size_t len)
 {
 	uint8_t *datap, *namep, *controlp;
+	socklen_t cmsg_padlen =
+	    CALC_CMSG_PADLEN(psm->ps_controllen, psm->ps_namelen);
 
 	namep = UNCONST(data);
-	controlp = namep + psm->ps_namelen;
+	controlp = namep + psm->ps_namelen + cmsg_padlen;
 	datap = controlp + psm->ps_controllen;
 
 	if (psm->ps_namelen != 0) {
@@ -678,7 +688,7 @@ ps_unrollmsg(struct msghdr *msg, struct 
 			return -1;
 		}
 		msg->msg_control = controlp;
-		len -= psm->ps_controllen;
+		len -= psm->ps_controllen + cmsg_padlen;
 	} else
 		msg->msg_control = NULL;
 	msg->msg_controllen = psm->ps_controllen;
@@ -699,9 +709,11 @@ ssize_t
 ps_sendpsmmsg(struct dhcpcd_ctx *ctx, int fd,
     struct ps_msghdr *psm, const struct msghdr *msg)
 {
+	long padding[1] = { 0 };
 	struct iovec iov[] = {
 		{ .iov_base = UNCONST(psm), .iov_len = sizeof(*psm) },
 		{ .iov_base = NULL, },	/* name */
+		{ .iov_base = NULL, },	/* control padding */
 		{ .iov_base = NULL, },	/* control */
 		{ .iov_base = NULL, },	/* payload 1 */
 		{ .iov_base = NULL, },	/* payload 2 */
@@ -713,6 +725,7 @@ ps_sendpsmmsg(struct dhcpcd_ctx *ctx, in
 	if (msg != NULL) {
 		struct iovec *iovp = &iov[1];
 		int i;
+		socklen_t cmsg_padlen;
 
 		psm->ps_namelen = msg->msg_namelen;
 		psm->ps_controllen = (socklen_t)msg->msg_controllen;
@@ -720,9 +733,17 @@ ps_sendpsmmsg(struct dhcpcd_ctx *ctx, in
 		iovp->iov_base = msg->msg_name;
 		iovp->iov_len = msg->msg_namelen;
 		iovp++;
+
+		cmsg_padlen =
+		    CALC_CMSG_PADLEN(msg->msg_controllen, msg->msg_namelen);
+		assert(cmsg_padlen <= sizeof(padding));
+		iovp->iov_len = cmsg_padlen;
+		iovp->iov_base = cmsg_padlen != 0 ? padding : NULL;
+		iovp++;
+
 		iovp->iov_base = msg->msg_control;
 		iovp->iov_len = msg->msg_controllen;
-		iovlen = 3;
+		iovlen = 4;
 
 		for (i = 0; i < (int)msg->msg_iovlen; i++) {
 			if ((size_t)(iovlen + i) > __arraycount(iov)) {
@@ -833,6 +854,8 @@ ps_sendcmdmsg(int fd, uint16_t cmd, cons
 		{ .iov_base = data, .iov_len = 0 },
 	};
 	size_t dl = sizeof(data);
+	socklen_t cmsg_padlen =
+	    CALC_CMSG_PADLEN(msg->msg_controllen, msg->msg_namelen);
 
 	if (msg->msg_namelen != 0) {
 		if (msg->msg_namelen > dl)
@@ -844,8 +867,13 @@ ps_sendcmdmsg(int fd, uint16_t cmd, cons
 	}
 
 	if (msg->msg_controllen != 0) {
-		if (msg->msg_controllen > dl)
+		if (msg->msg_controllen + cmsg_padlen > dl)
 			goto nobufs;
+		if (cmsg_padlen != 0) {
+			memset(p, 0, cmsg_padlen);
+			p += cmsg_padlen;
+			dl -= cmsg_padlen;
+		}
 		psm.ps_controllen = (socklen_t)msg->msg_controllen;
 		memcpy(p, msg->msg_control, msg->msg_controllen);
 		p += msg->msg_controllen;
@@ -856,7 +884,8 @@ ps_sendcmdmsg(int fd, uint16_t cmd, cons
 	if (psm.ps_datalen > dl)
 		goto nobufs;
 
-	iov[1].iov_len = psm.ps_namelen + psm.ps_controllen + psm.ps_datalen;
+	iov[1].iov_len =
+	    psm.ps_namelen + psm.ps_controllen + psm.ps_datalen + cmsg_padlen;
 	if (psm.ps_datalen != 0)
 		memcpy(p, msg->msg_iov[0].iov_base, psm.ps_datalen);
 	return writev(fd, iov, __arraycount(iov));

Index: src/external/bsd/dhcpcd/dist/src/logerr.c
diff -u src/external/bsd/dhcpcd/dist/src/logerr.c:1.11 src/external/bsd/dhcpcd/dist/src/logerr.c:1.12
--- src/external/bsd/dhcpcd/dist/src/logerr.c:1.11	Sun Nov  1 14:24:01 2020
+++ src/external/bsd/dhcpcd/dist/src/logerr.c	Fri Oct 22 13:23:20 2021
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * logerr: errx with logging
- * Copyright (c) 2006-2020 Roy Marples <r...@marples.name>
+ * Copyright (c) 2006-2021 Roy Marples <r...@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -484,13 +484,14 @@ logclose(void)
 #endif
 
 	closelog();
+#if defined(__linux__)
+	free(_logprog);
+	_logprog = NULL;
+#endif
 #ifndef SMALL
 	if (ctx->log_file == NULL)
 		return;
 	fclose(ctx->log_file);
 	ctx->log_file = NULL;
 #endif
-#if defined(__linux__)
-	free(_logprog);
-#endif
 }

Index: src/external/bsd/dhcpcd/dist/src/script.c
diff -u src/external/bsd/dhcpcd/dist/src/script.c:1.13 src/external/bsd/dhcpcd/dist/src/script.c:1.14
--- src/external/bsd/dhcpcd/dist/src/script.c:1.13	Mon Dec 28 13:57:40 2020
+++ src/external/bsd/dhcpcd/dist/src/script.c	Fri Oct 22 13:23:20 2021
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2020 Roy Marples <r...@marples.name>
+ * Copyright (c) 2006-2021 Roy Marples <r...@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -390,6 +390,7 @@ make_env(struct dhcpcd_ctx *ctx, const s
 	if (ifp->ctx->options & DHCPCD_DUMPLEASE)
 		goto dumplease;
 
+	ifp->ctx->rt_order = 0;
 	rb_tree_init(&ifaces, &rt_compare_proto_ops);
 	TAILQ_FOREACH(ifp2, ifp->ctx->ifaces, next) {
 		if (!ifp2->active)
@@ -397,7 +398,7 @@ make_env(struct dhcpcd_ctx *ctx, const s
 		rt = rt_new(UNCONST(ifp2));
 		if (rt == NULL)
 			goto eexit;
-		if (rb_tree_insert_node(&ifaces, rt) != rt)
+		if (rt_proto_add(&ifaces, rt) != rt)
 			goto eexit;
 	}
 	if (fprintf(fp, "interface_order=") == -1)

Added files:

Index: src/external/bsd/dhcpcd/dist/hooks/30-hostname
diff -u /dev/null src/external/bsd/dhcpcd/dist/hooks/30-hostname:1.5
--- /dev/null	Fri Oct 22 13:23:20 2021
+++ src/external/bsd/dhcpcd/dist/hooks/30-hostname	Fri Oct 22 13:23:20 2021
@@ -0,0 +1,158 @@
+# Set the hostname from DHCP data if required
+
+# A hostname can either be a short hostname or a FQDN.
+# hostname_fqdn=true
+# hostname_fqdn=false
+# hostname_fqdn=server
+
+# A value of server means just what the server says, don't manipulate it.
+# This could lead to an inconsistent hostname on a DHCPv4 and DHCPv6 network
+# where the DHCPv4 hostname is short and the DHCPv6 has an FQDN.
+# DHCPv6 has no hostname option.
+# RFC4702 section 3.1 says FQDN should be prefered over hostname.
+#
+# As such, the default is hostname_fqdn=true so that a consistent hostname
+# is always assigned.
+: ${hostname_fqdn:=true}
+
+# If we used to set the hostname, but relinquish control of it, we should
+# reset to the default value.
+: ${hostname_default=}
+
+# Some systems don't have hostname(1)
+_hostname()
+{
+	if [ -z "${1+x}" ]; then
+		if [ -r /proc/sys/kernel/hostname ]; then
+			read name </proc/sys/kernel/hostname && echo "$name"
+		elif type hostname >/dev/null 2>/dev/null; then
+			hostname
+		elif sysctl kern.hostname >/dev/null 2>&1; then
+			sysctl -n kern.hostname
+		elif sysctl kernel.hostname >/dev/null 2>&1; then
+			sysctl -n kernel.hostname
+		else
+			return 1
+		fi
+		return $?
+	fi
+
+	if [ -w /proc/sys/kernel/hostname ]; then
+		echo "$1" >/proc/sys/kernel/hostname
+	elif [ -n "$1" ] && type hostname >/dev/null 2>&1; then
+		hostname "$1"
+	elif sysctl kern.hostname >/dev/null 2>&1; then
+		sysctl -w "kern.hostname=$1" >/dev/null
+	elif sysctl kernel.hostname >/dev/null 2>&1; then
+		sysctl -w "kernel.hostname=$1" >/dev/null
+	else
+		# May fail to set a blank hostname
+		hostname "$1"
+	fi
+}
+
+is_default_hostname()
+{
+	case "$1" in
+	""|"$hostname_default"|localhost|localhost.localdomain)
+		return 0;;
+	esac
+	return 1
+}
+
+need_hostname()
+{
+	# Always load the hostname variable for future use
+	hostname="$(_hostname)"
+	is_default_hostname "$hostname" && return 0
+
+	case "$force_hostname" in
+	[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) return 0;;
+	esac
+
+	if [ -n "$old_fqdn" ]; then
+		if ${hfqdn} || ! ${hshort}; then
+			[ "$hostname" = "$old_fqdn" ]
+		else
+			[ "$hostname" = "${old_fqdn%%.*}" ]
+		fi
+	elif [ -n "$old_host_name" ]; then
+		if ${hfqdn}; then
+			if [ -n "$old_domain_name" ] &&
+			   [ "$old_host_name" = "${old_host_name#*.}" ]
+			then
+				[ "$hostname" = \
+				    "$old_host_name.$old_domain_name" ]
+			else
+				[ "$hostname" = "$old_host_name" ]
+			fi
+		elif ${hshort}; then
+			[ "$hostname" = "${old_host_name%%.*}" ]
+		else
+			[ "$hostname" = "$old_host_name" ]
+		fi
+	else
+		# No old hostname
+		false
+	fi
+}
+
+try_hostname()
+{
+	[ "$hostname" = "$1" ] && return 0
+	if valid_domainname "$1"; then
+		syslog info "Setting hostname: $1"
+		_hostname "$1"
+	else
+		syslog err "Invalid hostname: $1"
+	fi
+}
+
+set_hostname()
+{
+	hfqdn=false
+	hshort=false
+	case "$hostname_fqdn" in
+	[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1)	hfqdn=true;;
+	""|[Ss][Ee][Rr][Vv][Ee][Rr])		;;
+	*)					hshort=true;;
+	esac
+
+	need_hostname || return
+
+	if [ -n "$new_fqdn" ]; then
+		if ${hfqdn} || ! ${hshort}; then
+			try_hostname "$new_fqdn"
+		else
+			try_hostname "${new_fqdn%%.*}"
+		fi
+	elif [ -n "$new_host_name" ]; then
+		if ${hfqdn}; then
+			if [ -n "$new_domain_name" ] &&
+			   [ "$new_host_name" = "${new_host_name#*.}" ]
+			then
+				try_hostname "$new_host_name.$new_domain_name"
+			else
+				try_hostname "$new_host_name"
+			fi
+		elif ${hshort}; then
+			try_hostname "${new_host_name%%.*}"
+		else
+			try_hostname "$new_host_name"
+		fi
+	elif ! is_default_hostname "$hostname"; then
+		try_hostname "$hostname_default"
+	fi
+}
+
+# For ease of use, map DHCP6 names onto our DHCP4 names
+case "$reason" in
+BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
+	new_fqdn="$new_dhcp6_fqdn"
+	old_fqdn="$old_dhcp6_fqdn"
+	;;
+esac
+
+if $if_configured && $if_up && [ "$reason" != ROUTERADVERT ]; then
+	set_hostname
+fi

Reply via email to