Module Name: src
Committed By: roy
Date: Fri Oct 6 08:49:42 UTC 2023
Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.c if-options.c
ipv6nd.c privsep.c
Log Message:
sync with dhcpcd-10.0.3
To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.30 -r1.31 src/external/bsd/dhcpcd/dist/src/dhcp6.c
cvs rdiff -u -r1.51 -r1.52 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.34 -r1.35 src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.29 -r1.30 src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.15 -r1.16 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.48 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.49
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.48 Wed Jul 19 13:53:03 2023
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c Fri Oct 6 08:49:42 2023
@@ -3314,7 +3314,8 @@ dhcp_handledhcp(struct interface *ifp, s
state->reason = "TEST";
script_runreason(ifp, state->reason);
eloop_exit(ifp->ctx->eloop, EXIT_SUCCESS);
- state->bpf->bpf_flags |= BPF_EOF;
+ if (state->bpf)
+ state->bpf->bpf_flags |= BPF_EOF;
return;
}
eloop_timeout_delete(ifp->ctx->eloop, send_discover, ifp);
Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.30 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.31
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.30 Wed Jul 19 13:53:03 2023
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c Fri Oct 6 08:49:42 2023
@@ -1022,9 +1022,11 @@ dhcp6_makemessage(struct interface *ifp)
n--;
while (n-- > 0)
*ep++ = *pp--;
- if (u8)
+ n = (size_t)(ep - exb);
+ if (u8) {
*ep = (uint8_t)(*pp << u8);
- n++;
+ n++;
+ }
COPYIN(D6_OPTION_PD_EXCLUDE, exb,
(uint16_t)n);
ia_na_len = (uint16_t)
@@ -1628,6 +1630,7 @@ dhcp6_startdiscover(void *arg)
struct interface *ifp;
struct dhcp6_state *state;
int llevel;
+ struct ipv6_addr *ia;
ifp = arg;
state = D6_STATE(ifp);
@@ -1652,6 +1655,14 @@ dhcp6_startdiscover(void *arg)
state->new = NULL;
state->new_len = 0;
+ /* If we fail to renew or confirm, our requested addreses will
+ * be marked as stale.
+ To re-request them, just mark them as not stale. */
+ TAILQ_FOREACH(ia, &state->addrs, next) {
+ if (ia->flags & IPV6_AF_REQUEST)
+ ia->flags &= ~IPV6_AF_STALE;
+ }
+
if (dhcp6_makemessage(ifp) == -1)
logerr("%s: %s", __func__, ifp->name);
else
@@ -2268,9 +2279,7 @@ dhcp6_findpd(struct interface *ifp, cons
} else {
if (!(a->flags & IPV6_AF_DELEGATEDPFX))
a->flags |= IPV6_AF_NEW | IPV6_AF_DELEGATEDPFX;
- a->flags &= ~(IPV6_AF_STALE |
- IPV6_AF_EXTENDED |
- IPV6_AF_REQUEST);
+ a->flags &= ~(IPV6_AF_STALE | IPV6_AF_EXTENDED);
if (a->prefix_vltime != pdp.vltime)
a->flags |= IPV6_AF_NEW;
}
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.51 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.52
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.51 Wed Jul 19 13:53:03 2023
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Fri Oct 6 08:49:42 2023
@@ -75,6 +75,9 @@ static const char dhcpcd_copyright[] = "
#ifdef HAVE_CAPSICUM
#include <sys/capsicum.h>
#endif
+#ifdef HAVE_OPENSSL
+#include <openssl/crypto.h>
+#endif
#ifdef HAVE_UTIL_H
#include <util.h>
#endif
@@ -1411,6 +1414,7 @@ dhcpcd_renew(struct dhcpcd_ctx *ctx)
#ifdef USE_SIGNALS
#define sigmsg "received %s, %s"
+static volatile bool dhcpcd_exiting = false;
void
dhcpcd_signal_cb(int sig, void *arg)
{
@@ -1483,9 +1487,20 @@ dhcpcd_signal_cb(int sig, void *arg)
return;
}
+ /*
+ * Privsep has a mini-eloop for reading data from other processes.
+ * This mini-eloop processes signals as well so we can reap children.
+ * During teardown we don't want to process SIGTERM or SIGINT again,
+ * as that could trigger memory issues.
+ */
+ if (dhcpcd_exiting)
+ return;
+
+ dhcpcd_exiting = true;
if (!(ctx->options & DHCPCD_TEST))
stop_all_interfaces(ctx, opts);
eloop_exit(ctx->eloop, exit_code);
+ dhcpcd_exiting = false;
}
#endif
@@ -1495,7 +1510,7 @@ dhcpcd_handleargs(struct dhcpcd_ctx *ctx
{
struct interface *ifp;
unsigned long long opts;
- int opt, oi, do_reboot, do_renew, af = AF_UNSPEC;
+ int opt, oi, oifind, do_reboot, do_renew, af = AF_UNSPEC;
size_t len, l, nifaces;
char *tmp, *p;
@@ -1511,7 +1526,7 @@ dhcpcd_handleargs(struct dhcpcd_ctx *ctx
return control_queue(fd, UNCONST(fd->ctx->cffile),
strlen(fd->ctx->cffile) + 1);
} else if (strcmp(*argv, "--getinterfaces") == 0) {
- optind = argc = 0;
+ oifind = argc = 0;
goto dumplease;
} else if (strcmp(*argv, "--listen") == 0) {
fd->flags |= FD_LISTEN;
@@ -1574,6 +1589,9 @@ dhcpcd_handleargs(struct dhcpcd_ctx *ctx
}
}
+ /* store the index; the optind will change when a getopt get called */
+ oifind = optind;
+
if (opts & DHCPCD_DUMPLEASE) {
ctx->options |= DHCPCD_DUMPLEASE;
dumplease:
@@ -1581,11 +1599,11 @@ dumplease:
TAILQ_FOREACH(ifp, ctx->ifaces, next) {
if (!ifp->active)
continue;
- for (oi = optind; oi < argc; oi++) {
+ for (oi = oifind; oi < argc; oi++) {
if (strcmp(ifp->name, argv[oi]) == 0)
break;
}
- if (optind == argc || oi < argc) {
+ if (oifind == argc || oi < argc) {
opt = send_interface(NULL, ifp, af);
if (opt == -1)
goto dumperr;
@@ -1597,11 +1615,11 @@ dumplease:
TAILQ_FOREACH(ifp, ctx->ifaces, next) {
if (!ifp->active)
continue;
- for (oi = optind; oi < argc; oi++) {
+ for (oi = oifind; oi < argc; oi++) {
if (strcmp(ifp->name, argv[oi]) == 0)
break;
}
- if (optind == argc || oi < argc) {
+ if (oifind == argc || oi < argc) {
if (send_interface(fd, ifp, af) == -1)
goto dumperr;
}
@@ -1620,12 +1638,12 @@ dumperr:
}
if (opts & (DHCPCD_EXITING | DHCPCD_RELEASE)) {
- if (optind == argc) {
+ if (oifind == argc) {
stop_all_interfaces(ctx, opts);
eloop_exit(ctx->eloop, EXIT_SUCCESS);
return 0;
}
- for (oi = optind; oi < argc; oi++) {
+ for (oi = oifind; oi < argc; oi++) {
if ((ifp = if_find(ctx->ifaces, argv[oi])) == NULL)
continue;
if (!ifp->active)
@@ -1639,11 +1657,11 @@ dumperr:
}
if (do_renew) {
- if (optind == argc) {
+ if (oifind == argc) {
dhcpcd_renew(ctx);
return 0;
}
- for (oi = optind; oi < argc; oi++) {
+ for (oi = oifind; oi < argc; oi++) {
if ((ifp = if_find(ctx->ifaces, argv[oi])) == NULL)
continue;
dhcpcd_ifrenew(ifp);
@@ -1653,7 +1671,7 @@ dumperr:
reload_config(ctx);
/* XXX: Respect initial commandline options? */
- reconf_reboot(ctx, do_reboot, argc, argv, optind - 1);
+ reconf_reboot(ctx, do_reboot, argc, argv, oifind);
return 0;
}
@@ -1822,7 +1840,7 @@ dhcpcd_stderr_cb(void *arg, unsigned sho
if (!(events & ELE_READ))
return;
- len = read(ctx->stderr_fd, log, sizeof(log));
+ len = read(ctx->stderr_fd, log, sizeof(log) - 1);
if (len == -1) {
if (errno != ECONNRESET)
logerr(__func__);
@@ -2197,6 +2215,11 @@ printpidfile:
}
#endif
+#ifdef HAVE_OPENSSL
+ OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS |
+ OPENSSL_INIT_ADD_ALL_DIGESTS | OPENSSL_INIT_LOAD_CONFIG, NULL);
+#endif
+
#ifdef PRIVSEP
ps_init(&ctx);
#endif
Index: src/external/bsd/dhcpcd/dist/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.34 src/external/bsd/dhcpcd/dist/src/if-options.c:1.35
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.34 Wed Jul 19 13:53:03 2023
+++ src/external/bsd/dhcpcd/dist/src/if-options.c Fri Oct 6 08:49:42 2023
@@ -1833,6 +1833,8 @@ err_sla:
t |= OT_ADDRIPV6;
else if (strcasecmp(arg, "string") == 0)
t |= OT_STRING;
+ else if (strcasecmp(arg, "uri") == 0)
+ t |= OT_URI;
else if (strcasecmp(arg, "byte") == 0)
t |= OT_UINT8;
else if (strcasecmp(arg, "bitflags") == 0)
Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.29 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.30
--- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.29 Fri Apr 21 16:54:26 2023
+++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c Fri Oct 6 08:49:42 2023
@@ -1238,7 +1238,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx,
old_lifetime = rap->lifetime;
rap->lifetime = ntohs(nd_ra->nd_ra_router_lifetime);
if (!new_rap && rap->lifetime == 0 && old_lifetime != 0)
- logwarnx("%s: %s: no longer a default router",
+ logwarnx("%s: %s: no longer a default router (lifetime = 0)",
ifp->name, rap->sfrom);
if (nd_ra->nd_ra_curhoplimit != 0)
rap->hoplimit = nd_ra->nd_ra_curhoplimit;
Index: src/external/bsd/dhcpcd/dist/src/privsep.c
diff -u src/external/bsd/dhcpcd/dist/src/privsep.c:1.15 src/external/bsd/dhcpcd/dist/src/privsep.c:1.16
--- src/external/bsd/dhcpcd/dist/src/privsep.c:1.15 Wed Jul 19 13:53:03 2023
+++ src/external/bsd/dhcpcd/dist/src/privsep.c Fri Oct 6 08:49:42 2023
@@ -412,7 +412,6 @@ ps_startprocess(struct ps_process *psp,
return pid;
}
-
#ifdef PLUGIN_DEV
/* If we are not the root process, stop listening to devices. */
if (ctx->ps_root != psp)
@@ -541,11 +540,11 @@ ps_stopprocess(struct ps_process *psp)
err = -1;
}
#endif
- psp->psp_fd = -1;
}
/* Don't wait for the process as it may not respond to the shutdown
- * request. We'll reap the process on receipt of SIGCHLD. */
+ * request. We'll reap the process on receipt of SIGCHLD where we
+ * also close the fd. */
return err;
}
@@ -1200,7 +1199,7 @@ ps_newprocess(struct dhcpcd_ctx *ctx, st
#endif
if (!(ctx->options & DHCPCD_MANAGER))
- strlcpy(psp->psp_ifname, ctx->ifv[0], sizeof(psp->psp_name));
+ strlcpy(psp->psp_ifname, ctx->ifv[0], sizeof(psp->psp_ifname));
TAILQ_INSERT_TAIL(&ctx->ps_processes, psp, next);
return psp;
}