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/src Sync
details: https://anonhg.NetBSD.org/src/rev/86519dfb3d68
branches: trunk
changeset: 973482:86519dfb3d68
user: roy <roy%NetBSD.org@localhost>
date: Thu Jul 02 13:59:19 2020 +0000
description:
Sync
diffstat:
external/bsd/dhcpcd/dist/src/dhcp6.c | 6 +-
external/bsd/dhcpcd/dist/src/dhcpcd.c | 73 +++++++++++++++++-------------
external/bsd/dhcpcd/dist/src/if-bsd.c | 9 +++-
external/bsd/dhcpcd/dist/src/if-options.c | 36 ++++++++++++--
external/bsd/dhcpcd/dist/src/ipv6.c | 1 +
external/bsd/dhcpcd/dist/src/ipv6.h | 3 +-
external/bsd/dhcpcd/dist/src/ipv6nd.c | 62 +++++++++++++++++++------
external/bsd/dhcpcd/dist/src/logerr.c | 46 ++++++++++++++++--
external/bsd/dhcpcd/dist/src/privsep.c | 12 +---
external/bsd/dhcpcd/dist/src/script.c | 41 +++++++++--------
10 files changed, 193 insertions(+), 96 deletions(-)
diffs (truncated from 708 to 300 lines):
diff -r 8a756e53a70f -r 86519dfb3d68 external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c Thu Jul 02 13:57:40 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c Thu Jul 02 13:59:19 2020 +0000
@@ -3183,14 +3183,12 @@
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)
diff -r 8a756e53a70f -r 86519dfb3d68 external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c Thu Jul 02 13:57:40 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c Thu Jul 02 13:59:19 2020 +0000
@@ -339,6 +339,7 @@
return 0;
#else
int i;
+ unsigned int logopts = loggetopts();
if (ctx->options & DHCPCD_DAEMONISE &&
!(ctx->options & (DHCPCD_DAEMONISED | DHCPCD_NOWAITIP)))
@@ -359,7 +360,7 @@
return;
/* Don't use loginfo because this makes no sense in a log. */
- if (!(loggetopts() & LOGERR_QUIET))
+ if (!(logopts & LOGERR_QUIET))
(void)fprintf(stderr, "forked to background, child pid %d\n",
getpid());
i = EXIT_SUCCESS;
@@ -369,16 +370,11 @@
eloop_event_delete(ctx->eloop, ctx->fork_fd);
close(ctx->fork_fd);
ctx->fork_fd = -1;
-#ifdef PRIVSEP
- if (ctx->options & DHCPCD_PRIVSEP) {
- /* Aside from Linux, we don't have access to /dev/null */
- fclose(stdout);
- fclose(stderr);
- } else
-#endif
- {
- (void)freopen(_PATH_DEVNULL, "w", stdout);
- (void)freopen(_PATH_DEVNULL, "w", stderr);
+
+ if (isatty(loggeterrfd())) {
+ logopts &= ~LOGERR_ERR;
+ logsetopts(logopts);
+ logseterrfd(-1);
}
#endif
}
@@ -867,7 +863,6 @@
{
struct interface *ifp = arg;
struct if_options *ifo = ifp->options;
- int carrier;
if (ifo->options & DHCPCD_LINK) {
switch (ifp->carrier) {
@@ -879,19 +874,8 @@
case LINK_UNKNOWN:
/* No media state available.
* Loop until both IFF_UP and IFF_RUNNING are set */
- carrier = if_carrier(ifp);
- if (carrier == LINK_UNKNOWN) {
- if (IF_UPANDRUNNING(ifp))
- carrier = LINK_UP;
- else {
- eloop_timeout_add_msec(ifp->ctx->eloop,
- IF_POLL_UP * MSEC_PER_SEC,
- dhcpcd_startinterface, ifp);
- return;
- }
- }
- dhcpcd_handlecarrier(ifp->ctx, carrier,
- ifp->flags, ifp->name);
+ if (ifo->poll == 0)
+ if_pollinit(ifp);
return;
}
}
@@ -979,6 +963,7 @@
dhcpcd_prestartinterface(void *arg)
{
struct interface *ifp = arg;
+ struct dhcpcd_ctx *ctx = ifp->ctx;
bool anondown;
if (ifp->carrier == LINK_DOWN &&
@@ -990,7 +975,7 @@
} else
anondown = false;
- if ((!(ifp->ctx->options & DHCPCD_MASTER) ||
+ if ((!(ctx->options & DHCPCD_MASTER) ||
ifp->options->options & DHCPCD_IF_UP || anondown) &&
!(ifp->flags & IFF_UP))
{
@@ -1001,6 +986,9 @@
logerr(__func__);
}
+ if (ifp->options->poll != 0)
+ if_pollinit(ifp);
+
dhcpcd_startinterface(ifp);
}
@@ -1299,7 +1287,9 @@
if ((ifo = read_config(ctx, NULL, NULL, NULL)) == NULL)
return;
add_options(ctx, NULL, ifo, ctx->argc, ctx->argv);
- /* We need to preserve these two options. */
+ /* 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_DAEMONISED)
@@ -1409,6 +1399,9 @@
}
if (sig != SIGCHLD && ctx->options & DHCPCD_FORKED) {
+ if (sig == SIGHUP)
+ return;
+
pid_t pid = pidfile_read(ctx->pidfile);
if (pid == -1) {
if (errno != ENOENT)
@@ -1861,9 +1854,7 @@
#endif
#ifdef PRIVSEP
ctx.ps_root_fd = ctx.ps_data_fd = -1;
-#ifdef PRIVSEP_COMTROLLER
- ctx.ps_ctl_fd = -1;
-#endif
+ ctx.ps_inet_fd = ctx.ps_control_fd = -1;
TAILQ_INIT(&ctx.ps_processes);
#endif
rt_init(&ctx);
@@ -2210,7 +2201,9 @@
}
loginfox(PACKAGE "-" VERSION " starting");
- freopen(_PATH_DEVNULL, "r", stdin);
+ if (freopen(_PATH_DEVNULL, "r", stdin) == NULL)
+ logerr("%s: freopen stdin", __func__);
+
#ifdef PRIVSEP
ps_init(&ctx);
@@ -2275,6 +2268,22 @@
if_disable_rtadv();
#endif
+ if (isatty(STDOUT_FILENO) &&
+ freopen(_PATH_DEVNULL, "r", stdout) == NULL)
+ logerr("%s: freopen stdout", __func__);
+ if (isatty(STDERR_FILENO)) {
+ int fd = dup(STDERR_FILENO);
+
+ if (fd == -1)
+ logerr("%s: dup", __func__);
+ else if (logseterrfd(fd) == -1)
+ logerr("%s: logseterrfd", __func__);
+ else if (freopen(_PATH_DEVNULL, "r", stderr) == NULL) {
+ logseterrfd(-1);
+ logerr("%s: freopen stderr", __func__);
+ }
+ }
+
/* If we're not running in privsep, we need to create the DB
* directory here. */
if (!(ctx.options & DHCPCD_PRIVSEP)) {
@@ -2328,7 +2337,7 @@
/* Cache the default vendor option. */
if (dhcp_vendor(ctx.vendor, sizeof(ctx.vendor)) == -1)
- logerrx("dhcp_vendor");
+ logerr("dhcp_vendor");
/* Start handling kernel messages for interfaces, addresses and
* routes. */
diff -r 8a756e53a70f -r 86519dfb3d68 external/bsd/dhcpcd/dist/src/if-bsd.c
--- a/external/bsd/dhcpcd/dist/src/if-bsd.c Thu Jul 02 13:57:40 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/if-bsd.c Thu Jul 02 13:59:19 2020 +0000
@@ -358,6 +358,10 @@
{
struct ifmediareq ifmr = { .ifm_status = 0 };
+ /* Not really needed, but the other OS update flags here also */
+ if (if_getflags(ifp) == -1)
+ return LINK_UNKNOWN;
+
strlcpy(ifmr.ifm_name, ifp->name, sizeof(ifmr.ifm_name));
if (ioctl(ifp->ctx->pf_inet_fd, SIOCGIFMEDIA, &ifmr) == -1 ||
!(ifmr.ifm_status & IFM_AVALID))
@@ -1002,7 +1006,10 @@
if (ia->addr_flags & IN6_IFF_TENTATIVE)
ifa.ifra_flags |= IN6_IFF_TENTATIVE;
#endif
-#if !defined(IPV6CTL_ACCEPT_RTADV) && !defined(ND6_IFF_ACCEPT_RTADV)
+#if (defined(__NetBSD__) || defined(__OpenBSD__)) && \
+ (defined(IPV6CTL_ACCEPT_RTADV) || defined(ND6_IFF_ACCEPT_RTADV))
+ /* These kernels don't accept userland setting IN6_IFF_AUTOCONF */
+#else
if (ia->flags & IPV6_AF_AUTOCONF)
ifa.ifra_flags |= IN6_IFF_AUTOCONF;
#endif
diff -r 8a756e53a70f -r 86519dfb3d68 external/bsd/dhcpcd/dist/src/if-options.c
--- a/external/bsd/dhcpcd/dist/src/if-options.c Thu Jul 02 13:57:40 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/if-options.c Thu Jul 02 13:59:19 2020 +0000
@@ -55,6 +55,10 @@
#include "logerr.h"
#include "sa.h"
+#define IN_CONFIG_BLOCK(ifo) ((ifo)->options & DHCPCD_FORKED)
+#define SET_CONFIG_BLOCK(ifo) ((ifo)->options |= DHCPCD_FORKED)
+#define CLEAR_CONFIG_BLOCK(ifo) ((ifo)->options &= ~DHCPCD_FORKED)
+
const struct option cf_options[] = {
{"background", no_argument, NULL, 'b'},
{"script", required_argument, NULL, 'c'},
@@ -158,6 +162,7 @@
{"inactive", no_argument, NULL, O_INACTIVE},
{"mudurl", required_argument, NULL, O_MUDURL},
{"link_rcvbuf", required_argument, NULL, O_LINK_RCVBUF},
+ {"poll", optional_argument, NULL, O_POLL},
{NULL, 0, NULL, '\0'}
};
@@ -673,7 +678,7 @@
break;
case 'c':
ARG_REQUIRED;
- if (ifname != NULL) {
+ if (IN_CONFIG_BLOCK(ifo)) {
logerrx("%s: per interface scripts"
" are no longer supported",
ifname);
@@ -743,7 +748,7 @@
ARG_REQUIRED;
/* per interface logging is not supported
* don't want to overide the commandline */
- if (ifname == NULL && ctx->logfile == NULL) {
+ if (!IN_CONFIG_BLOCK(ifo) && ctx->logfile == NULL) {
logclose();
ctx->logfile = strdup(arg);
logopen(ctx->logfile);
@@ -946,7 +951,7 @@
break;
case 'z':
ARG_REQUIRED;
- if (ifname == NULL)
+ if (!IN_CONFIG_BLOCK(ifo))
ctx->ifav = splitv(&ctx->ifac, ctx->ifav, arg);
break;
case 'A':
@@ -1192,7 +1197,7 @@
break;
case 'Z':
ARG_REQUIRED;
- if (ifname == NULL)
+ if (!IN_CONFIG_BLOCK(ifo))
ctx->ifdv = splitv(&ctx->ifdc, ctx->ifdv, arg);
break;
case '1':
@@ -1296,7 +1301,7 @@
#endif
case O_IAID:
ARG_REQUIRED;
- if (ifname == NULL) {
+ if (!IN_CONFIG_BLOCK(ifo)) {
logerrx("IAID must belong in an interface block");
return -1;
}
@@ -1338,7 +1343,7 @@
logwarnx("%s: IA_PD not compiled in", ifname);
return -1;
#else
- if (ifname == NULL) {
+ if (!IN_CONFIG_BLOCK(ifo)) {
logerrx("IA PD must belong in an "
"interface block");
return -1;
@@ -1346,7 +1351,7 @@
i = D6_OPTION_IA_PD;
#endif
}
Home |
Main Index |
Thread Index |
Old Index