Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/roy]: src/external/bsd/dhcpcd/dist/src Update to dhcpcd-9.3.1 with the f...
details: https://anonhg.NetBSD.org/src/rev/e757946d5b33
branches: roy
changeset: 940644:e757946d5b33
user: roy <roy%NetBSD.org@localhost>
date: Mon Oct 12 14:07:55 2020 +0000
description:
Update to dhcpcd-9.3.1 with the following changes:
* dhcpcd: carrier handling issue fixed from 9.3.0
* dhcpcd: log if interface type is unsupported in debug
* duid: memory leak fixed if UUID wanted but none available
* privsep: fix receiving inet and no BPF running
* privsep: allow gettimeofday for SECCOMP
* privsep: fix stderr redirection again
diffstat:
external/bsd/dhcpcd/dist/src/arp.c | 2 +-
external/bsd/dhcpcd/dist/src/defs.h | 2 +-
external/bsd/dhcpcd/dist/src/dhcp.c | 8 +-
external/bsd/dhcpcd/dist/src/dhcp6.c | 12 +-
external/bsd/dhcpcd/dist/src/dhcpcd.c | 214 ++++++++++++++---------------
external/bsd/dhcpcd/dist/src/dhcpcd.h | 1 -
external/bsd/dhcpcd/dist/src/duid.c | 5 +-
external/bsd/dhcpcd/dist/src/if-bsd.c | 11 +-
external/bsd/dhcpcd/dist/src/if-options.h | 2 +-
external/bsd/dhcpcd/dist/src/if.c | 34 +++-
external/bsd/dhcpcd/dist/src/if.h | 1 +
external/bsd/dhcpcd/dist/src/ipv6.c | 2 +-
external/bsd/dhcpcd/dist/src/ipv6nd.c | 4 +-
external/bsd/dhcpcd/dist/src/logerr.c | 16 +-
external/bsd/dhcpcd/dist/src/script.c | 1 -
15 files changed, 167 insertions(+), 148 deletions(-)
diffs (truncated from 712 to 300 lines):
diff -r b04147b6f49d -r e757946d5b33 external/bsd/dhcpcd/dist/src/arp.c
--- a/external/bsd/dhcpcd/dist/src/arp.c Mon Oct 05 16:01:13 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.c Mon Oct 12 14:07:55 2020 +0000
@@ -506,7 +506,7 @@
struct ipv4_addr *iap;
TAILQ_FOREACH(ifp, ctx->ifaces, next) {
- if (!ifp->active || ifp->carrier <= LINK_DOWN)
+ if (!ifp->active || !if_is_link_up(ifp))
continue;
iap = ipv4_iffindaddr(ifp, ia, NULL);
if (iap == NULL)
diff -r b04147b6f49d -r e757946d5b33 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h Mon Oct 05 16:01:13 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h Mon Oct 12 14:07:55 2020 +0000
@@ -29,7 +29,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "9.3.0"
+#define VERSION "9.3.1"
#ifndef PRIVSEP_USER
# define PRIVSEP_USER "_" PACKAGE
diff -r b04147b6f49d -r e757946d5b33 external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c Mon Oct 05 16:01:13 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c Mon Oct 12 14:07:55 2020 +0000
@@ -1712,7 +1712,7 @@
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 @@
(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 @@
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 @@
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)
{
diff -r b04147b6f49d -r e757946d5b33 external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c Mon Oct 05 16:01:13 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c Mon Oct 12 14:07:55 2020 +0000
@@ -1237,7 +1237,7 @@
};
char uaddr[INET6_ADDRSTRLEN];
- if (!callback && ifp->carrier <= LINK_DOWN)
+ if (!callback && !if_is_link_up(ifp))
return 0;
if (!IN6_IS_ADDR_UNSPECIFIED(&state->unicast)) {
@@ -1298,7 +1298,7 @@
+ (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 @@
}
}
- if (ifp->carrier <= LINK_DOWN)
+ if (!if_is_link_up(ifp))
return 0;
/* Update the elapsed time */
@@ -2906,7 +2906,7 @@
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 @@
sla = &ia->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 @@
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)
{
diff -r b04147b6f49d -r e757946d5b33 external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c Mon Oct 05 16:01:13 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c Mon Oct 12 14:07:55 2020 +0000
@@ -97,9 +97,6 @@
const size_t dhcpcd_signals_ignore_len = __arraycount(dhcpcd_signals_ignore);
#endif
-#define IF_UPANDRUNNING(a) \
- (((a)->flags & (IFF_UP | IFF_RUNNING)) == (IFF_UP | IFF_RUNNING))
-
const char *dhcpcd_default_script = SCRIPT;
static void
@@ -412,7 +409,7 @@
}
static void
-stop_interface(struct interface *ifp)
+stop_interface(struct interface *ifp, const char *reason)
{
struct dhcpcd_ctx *ctx;
@@ -421,10 +418,7 @@
ifp->options->options |= DHCPCD_STOPPING;
dhcpcd_drop(ifp, 1);
- if (ifp->options->options & DHCPCD_DEPARTED)
- script_runreason(ifp, "DEPARTED");
- else
- script_runreason(ifp, "STOPPED");
+ script_runreason(ifp, reason == NULL ? "STOPPED" : reason);
/* Delete all timeouts for the interfaces */
eloop_q_timeout_delete(ctx->eloop, ELOOP_QUEUE_ALL, NULL, ifp);
@@ -704,110 +698,108 @@
void
dhcpcd_handlecarrier(struct interface *ifp, int carrier, unsigned int flags)
{
- bool nolink = ifp->options == NULL ||
- !(ifp->options->options & DHCPCD_LINK);
+ bool was_link_up = if_is_link_up(ifp);
+ ifp->carrier = carrier;
ifp->flags = flags;
- if (carrier == LINK_UNKNOWN) {
- if (ifp->wireless)
- carrier = LINK_DOWN;
- else
- carrier = IF_UPANDRUNNING(ifp) ? LINK_UP : LINK_DOWN;
- }
- if (carrier == LINK_DOWN || (ifp->flags & IFF_UP) == 0) {
- if (ifp->carrier != LINK_DOWN) {
+ if (!if_is_link_up(ifp)) {
+ if (!was_link_up || !ifp->active)
+ return;
+ loginfox("%s: carrier lost", ifp->name);
+ script_runreason(ifp, "NOCARRIER");
#ifdef NOCARRIER_PRESERVE_IP
- if (ifp->flags & IFF_UP &&
- (ifp->options == NULL ||
- !(ifp->options->options & DHCPCD_ANONYMOUS)))
- ifp->carrier = LINK_DOWN_IFFUP;
- else
-#endif
- ifp->carrier = LINK_DOWN;
- if (!ifp->active || nolink)
- return;
- loginfox("%s: carrier lost", ifp->name);
- script_runreason(ifp, "NOCARRIER");
-#ifdef NOCARRIER_PRESERVE_IP
- if (ifp->flags & IFF_UP &&
- !(ifp->options->options & DHCPCD_ANONYMOUS))
- {
+ if (ifp->flags & IFF_UP &&
+ !(ifp->options->options & DHCPCD_ANONYMOUS))
+ {
#ifdef ARP
- arp_drop(ifp);
+ arp_drop(ifp);
#endif
#ifdef INET
- dhcp_abort(ifp);
+ dhcp_abort(ifp);
#endif
#ifdef DHCP6
- dhcp6_abort(ifp);
+ dhcp6_abort(ifp);
#endif
- } else
+ } else
#endif
- dhcpcd_drop(ifp, 0);
- if (ifp->options->options & DHCPCD_ANONYMOUS) {
- bool was_up = ifp->flags & IFF_UP;
+ dhcpcd_drop(ifp, 0);
+ if (ifp->options->options & DHCPCD_ANONYMOUS) {
+ bool is_up = ifp->flags & IFF_UP;
+
+ if (is_up)
+ if_down(ifp);
+ if (if_randomisemac(ifp) == -1 && errno != ENXIO)
+ logerr(__func__);
+ if (is_up)
+ if_up(ifp);
+ }
+ return;
+ }
- if (was_up)
- if_down(ifp);
- if (if_randomisemac(ifp) == -1 && errno != ENXIO)
- logerr(__func__);
- if (was_up)
- if_up(ifp);
- }
- }
- } else if (carrier == LINK_UP && ifp->flags & IFF_UP) {
- if (ifp->carrier != LINK_UP) {
- ifp->carrier = LINK_UP;
- if (ifp->active)
- loginfox("%s: carrier acquired", ifp->name);
+ /*
+ * At this point carrier is NOT DOWN and we have IFF_UP.
+ * We should treat LINK_UNKNOWN as up as the driver may not support
+ * link state changes.
+ * The consideration of any other information about carrier should
+ * be handled in the OS specific if_carrier() function.
+ */
+ if (was_link_up)
+ return;
+
+ if (ifp->active) {
+ if (carrier == LINK_UNKNOWN)
+ loginfox("%s: carrier unknown, assuming up", ifp->name);
+ else
+ loginfox("%s: carrier acquired", ifp->name);
+ }
+
#if !defined(__linux__) && !defined(__NetBSD__)
- /* BSD does not emit RTM_NEWADDR or RTM_CHGADDR when the
- * hardware address changes so we have to go
- * through the disovery process to work it out. */
- dhcpcd_handleinterface(ifp->ctx, 0, ifp->name);
+ /* BSD does not emit RTM_NEWADDR or RTM_CHGADDR when the
+ * hardware address changes so we have to go
+ * through the disovery process to work it out. */
+ dhcpcd_handleinterface(ifp->ctx, 0, ifp->name);
#endif
- if (ifp->wireless) {
- uint8_t ossid[IF_SSIDLEN];
- size_t olen;
+
+ if (ifp->wireless) {
+ uint8_t ossid[IF_SSIDLEN];
+ size_t olen;
- olen = ifp->ssid_len;
- memcpy(ossid, ifp->ssid, ifp->ssid_len);
- if_getssid(ifp);
+ olen = ifp->ssid_len;
+ memcpy(ossid, ifp->ssid, ifp->ssid_len);
+ if_getssid(ifp);
- /* If we changed SSID network, drop leases */
- if ((ifp->ssid_len != olen ||
- memcmp(ifp->ssid, ossid, ifp->ssid_len)) &&
- ifp->active)
- {
- dhcpcd_reportssid(ifp);
+ /* If we changed SSID network, drop leases */
+ if ((ifp->ssid_len != olen ||
+ memcmp(ifp->ssid, ossid, ifp->ssid_len)) && ifp->active)
+ {
+ dhcpcd_reportssid(ifp);
#ifdef NOCARRIER_PRESERVE_IP
- dhcpcd_drop(ifp, 0);
+ dhcpcd_drop(ifp, 0);
#endif
#ifdef IPV4LL
Home |
Main Index |
Thread Index |
Old Index