Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/dhcpcd/dist Sync
details: https://anonhg.NetBSD.org/src/rev/67c8aaa8f917
branches: trunk
changeset: 1009134:67c8aaa8f917
user: roy <roy%NetBSD.org@localhost>
date: Mon Apr 13 15:46:26 2020 +0000
description:
Sync
diffstat:
external/bsd/dhcpcd/dist/hooks/00-linux | 11 -
external/bsd/dhcpcd/dist/hooks/02-dump | 8 -
external/bsd/dhcpcd/dist/src/dhcp.c | 4 +-
external/bsd/dhcpcd/dist/src/dhcp6.c | 9 +-
external/bsd/dhcpcd/dist/src/dhcpcd.c | 96 +++++---
external/bsd/dhcpcd/dist/src/if-bsd.c | 8 +-
external/bsd/dhcpcd/dist/src/if-options.c | 6 +
external/bsd/dhcpcd/dist/src/ipv6.c | 302 ++++++++++-------------------
external/bsd/dhcpcd/dist/src/ipv6.h | 17 +-
external/bsd/dhcpcd/dist/src/ipv6nd.c | 9 +-
external/bsd/dhcpcd/dist/src/script.c | 7 +-
11 files changed, 190 insertions(+), 287 deletions(-)
diffs (truncated from 952 to 300 lines):
diff -r 30f819afb82b -r 67c8aaa8f917 external/bsd/dhcpcd/dist/hooks/00-linux
--- a/external/bsd/dhcpcd/dist/hooks/00-linux Mon Apr 13 15:42:20 2020 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-# setup chroot mounts
-
-if [ "$reason" = CHROOT ] && [ -n "$chroot" ]; then
- for d in /dev /proc /sys /run/udev; do
- [ -d "$d" ] || continue
- if ! mountpoint -q "$chroot$d"; then
- mkdir -p "$chroot$d"
- mount --bind $d "$chroot$d"
- fi
- done
-fi
diff -r 30f819afb82b -r 67c8aaa8f917 external/bsd/dhcpcd/dist/hooks/02-dump
--- a/external/bsd/dhcpcd/dist/hooks/02-dump Mon Apr 13 15:42:20 2020 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-# Just echo our DHCP options we have
-
-case "$reason" in
-DUMP|DUMP6)
- set | sed -ne 's/^new_//p' | sort
- exit 0
- ;;
-esac
diff -r 30f819afb82b -r 67c8aaa8f917 external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c Mon Apr 13 15:42:20 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c Mon Apr 13 15:46:26 2020 +0000
@@ -2301,7 +2301,7 @@
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 @@
memcpy(&udp, (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. */
diff -r 30f819afb82b -r 67c8aaa8f917 external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c Mon Apr 13 15:42:20 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c Mon Apr 13 15:46:26 2020 +0000
@@ -2503,10 +2503,8 @@
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 @@
vl |= sla->suffix;
be64enc(daddr.s6_addr + 8, vl);
} else {
- dadcounter = ipv6_makeaddr(&daddr, ifp, &addr, pfxlen);
+ dadcounter = ipv6_makeaddr(&daddr, ifp, &addr, pfxlen, 0);
if (dadcounter == -1) {
logerrx("%s: error adding slaac to prefix_len %d",
ifp->name, pfxlen);
@@ -3162,7 +3160,8 @@
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
diff -r 30f819afb82b -r 67c8aaa8f917 external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c Mon Apr 13 15:42:20 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c Mon Apr 13 15:46:26 2020 +0000
@@ -781,8 +781,10 @@
* 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 @@
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, &nifaces, 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 (!ifp->active)
continue;
- send_interface(fd, ifp, af);
+ for (oi = optind; oi < argc; oi++) {
+ if (strcmp(ifp->name, argv[oi]) == 0)
+ break;
+ }
+ if (optind == argc || oi < argc) {
+ if (send_interface(fd, ifp, af) == -1)
+ goto dumperr;
+ }
}
ctx->options &= ~DHCPCD_DUMPLEASE;
return 0;
+dumperr:
+ ctx->options &= ~DHCPCD_DUMPLEASE;
+ return -1;
}
/* Only privileged users can control dhcpcd via the socket. */
@@ -1618,14 +1633,20 @@
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;
+ size_t nifaces, buflen = 0, dlen, i;
ssize_t len;
char *buf = NULL, *dp, *de;
- bool print;
+ const char *skip;
again1:
len = read(ctx->control_fd, &nifaces, sizeof(nifaces));
@@ -1660,6 +1681,11 @@
buf = nbuf;
buflen = dlen;
}
+ if (dlen == 0) {
+ errno = EINVAL;
+ error = -1;
+ goto out;
+ }
again3:
if (read(ctx->control_fd, buf, dlen) != (ssize_t)dlen) {
if (errno == EAGAIN)
@@ -1669,28 +1695,23 @@
}
dp = buf;
de = dp + dlen;
+ if (*(dp - 1) != '\0') {
+ errno = EINVAL;
+ error = -1;
+ goto out;
+ }
while (dp < de) {
- if (dp + 6 >= de) /* _new and = something */
- break;
- if (dp[0] == 'n' && dp[3] == '_') {
- if (dp[1] == 'e' && dp[2] == 'w') {
- print = true;
+ for (i = 0; i < __arraycount(dumpskip); i++) {
+ skip = dumpskip[i];
+ if (strncmp(dp, skip, strlen(skip)) == 0)
+ break;
+ }
+ if (i == __arraycount(dumpskip)) {
+ if (strncmp(dp, "new_", 4) == 0)
dp += 4;
- } else if (dp[1] == 'd' &&
- isdigit((unsigned char)dp[2]))
- print = true;
- else
- print = false;
- } else
- print = false;
- while (dp < de && *dp != '\0') {
- if (print)
- putchar(*dp);
- dp++;
+ printf("%s\n", dp);
}
- if (print)
- putchar('\n');
- dp++;
+ dp += strlen(dp) + 1;
}
fflush(stdout);
if (nifaces != 1)
@@ -2107,16 +2128,11 @@
}
#endif
- logdebugx(PACKAGE "-" VERSION " starting");
+ loginfox(PACKAGE "-" VERSION " starting");
freopen(_PATH_DEVNULL, "r", stdin);
#ifdef PRIVSEP
- if (ps_init(&ctx) == -1) {
- if (errno != 0) {
- logerr("ps_init");
- goto exit_failure;
- }
- } else
+ if (ps_init(&ctx) == 0)
script_runchroot(&ctx, ifo->script);
#endif
@@ -2169,7 +2185,7 @@
}
#endif
-#ifdef BSD
+#if defined(BSD) && defined(INET6)
/* Disable the kernel RTADV sysctl as early as possible. */
if (ctx.options & DHCPCD_IPV6 && ctx.options & DHCPCD_IPV6RS)
if_disable_rtadv();
diff -r 30f819afb82b -r 67c8aaa8f917 external/bsd/dhcpcd/dist/src/if-bsd.c
--- a/external/bsd/dhcpcd/dist/src/if-bsd.c Mon Apr 13 15:42:20 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/if-bsd.c Mon Apr 13 15:46:26 2020 +0000
@@ -1037,7 +1037,7 @@
if (ia->addr_flags & IN6_IFF_TENTATIVE)
ifa.ifra_flags |= IN6_IFF_TENTATIVE;
#endif
-#ifdef IPV6_MANGETEMPADDR
+#ifdef IPV6_MANAGETEMPADDR
if (ia->flags & IPV6_AF_TEMPORARY)
ifa.ifra_flags |= IN6_IFF_TEMPORARY;
#endif
@@ -1524,6 +1524,8 @@
#ifdef INET6
if (sa->sa_family == AF_INET6)
ifa_setscope(satosin6(sa), ifp->index);
+#else
+ UNUSED(ifp);
#endif
cp = ctx->rt_missfilter + ctx->rt_missfilterlen;
@@ -1728,14 +1730,14 @@
ip6_temp_preferred_lifetime(__unused const char *ifname)
{
- return ND6_PRIV_PREFERRED_LIFETIME;
+ return TEMP_PREFERRED_LIFETIME;
}
int
ip6_temp_valid_lifetime(__unused const char *ifname)
{
- return ND6_PRIV_VALID_LIFETIME;
+ return TEMP_VALID_LIFETIME;
}
#else /* __OpenBSD__ */
diff -r 30f819afb82b -r 67c8aaa8f917 external/bsd/dhcpcd/dist/src/if-options.c
--- a/external/bsd/dhcpcd/dist/src/if-options.c Mon Apr 13 15:42:20 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/if-options.c Mon Apr 13 15:46:26 2020 +0000
@@ -573,6 +573,8 @@
return;
}
#endif
+#else
+ UNUSED(arg);
Home |
Main Index |
Thread Index |
Old Index