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 Update to dhcpcd-9.4.0 with the follo...
details: https://anonhg.NetBSD.org/src/rev/0893b9f3100b
branches: ROY
changeset: 948388:0893b9f3100b
user: roy <roy%NetBSD.org@localhost>
date: Mon Dec 28 13:56:25 2020 +0000
description:
Update to dhcpcd-9.4.0 with the following changes:
* DHCP: For anonymous, just use a generic ClientID
* link: Split hardware address randomisation out of anonymous option
* link: Only report hardware changes for active interfaces
* link: Report errors obtaining recv buffer size on overflow
* hooks: Add NOCARRIER_ROAMING reason
* hooks: interface_order now reflects priorities again
diffstat:
external/bsd/dhcpcd/dist/hooks/20-resolv.conf | 23 ++++-
external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in | 11 +-
external/bsd/dhcpcd/dist/src/defs.h | 2 +-
external/bsd/dhcpcd/dist/src/dhcp.c | 18 +---
external/bsd/dhcpcd/dist/src/dhcp6.c | 3 +-
external/bsd/dhcpcd/dist/src/dhcpcd.c | 93 ++++++++++++-------
external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in | 10 +-
external/bsd/dhcpcd/dist/src/if-bsd.c | 15 +++
external/bsd/dhcpcd/dist/src/if-options.c | 4 +
external/bsd/dhcpcd/dist/src/if-options.h | 2 +
external/bsd/dhcpcd/dist/src/if.c | 7 +-
external/bsd/dhcpcd/dist/src/if.h | 9 +-
external/bsd/dhcpcd/dist/src/ipv4ll.c | 2 +-
external/bsd/dhcpcd/dist/src/ipv6nd.c | 2 -
external/bsd/dhcpcd/dist/src/privsep-bpf.c | 3 +-
external/bsd/dhcpcd/dist/src/privsep.c | 4 +-
external/bsd/dhcpcd/dist/src/route.c | 11 ++
external/bsd/dhcpcd/dist/src/route.h | 9 +
external/bsd/dhcpcd/dist/src/script.c | 72 +++++++++-----
19 files changed, 195 insertions(+), 105 deletions(-)
diffs (truncated from 746 to 300 lines):
diff -r c1ca9e2b33af -r 0893b9f3100b external/bsd/dhcpcd/dist/hooks/20-resolv.conf
--- a/external/bsd/dhcpcd/dist/hooks/20-resolv.conf Sun Dec 27 18:25:08 2020 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/20-resolv.conf Mon Dec 28 13:56:25 2020 +0000
@@ -7,9 +7,15 @@
# or dnsmasq. This is important as the libc resolver isn't that powerful.
resolv_conf_dir="$state_dir/resolv.conf"
+nocarrier_roaming_dir="$state_dir/roaming"
NL="
"
: ${resolvconf:=resolvconf}
+if type "$resolvconf" >/dev/null 2>&1; then
+ have_resolvconf=true
+else
+ have_resolvconf=false
+fi
build_resolv_conf()
{
@@ -164,7 +170,7 @@
for x in ${new_domain_name_servers}; do
conf="${conf}nameserver $x$NL"
done
- if type "$resolvconf" >/dev/null 2>&1; then
+ if $have_resolvconf; then
[ -n "$ifmetric" ] && export IF_METRIC="$ifmetric"
printf %s "$conf" | "$resolvconf" -a "$ifname"
return $?
@@ -180,7 +186,7 @@
remove_resolv_conf()
{
- if type "$resolvconf" >/dev/null 2>&1; then
+ if $have_resolvconf; then
"$resolvconf" -d "$ifname" -f
else
if [ -e "$resolv_conf_dir/$ifname" ]; then
@@ -199,7 +205,18 @@
esac
if $if_configured; then
- if $if_up || [ "$reason" = ROUTERADVERT ]; then
+ if $have_resolvconf && [ "$reason" = NOCARRIER_ROAMING ]; then
+ # avoid calling resolvconf -c on CARRIER unless we roam
+ mkdir -p "$nocarrier_roaming_dir"
+ echo " " >"$nocarrier_roaming_dir/$interface"
+ "$resolvconf" -C "$interface.*"
+ elif $have_resolvconf && [ "$reason" = CARRIER ]; then
+ # Not all resolvconf implementations support -c
+ if [ -e "$nocarrier_roaming_dir/$interface" ]; then
+ rm -f "$nocarrier_roaming_dir/$interface"
+ "$resolvconf" -c "$interface.*"
+ fi
+ elif $if_up || [ "$reason" = ROUTERADVERT ]; then
add_resolv_conf
elif $if_down; then
remove_resolv_conf
diff -r c1ca9e2b33af -r 0893b9f3100b external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in
--- a/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in Sun Dec 27 18:25:08 2020 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in Mon Dec 28 13:56:25 2020 +0000
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 24, 2020
+.Dd December 27, 2020
.Dt DHCPCD-RUN-HOOKS 8
.Os
.Sh NAME
@@ -92,6 +92,9 @@
.It Dv NOCARRIER
dhcpcd lost the carrier.
The cable may have been unplugged or association to the wireless point lost.
+.It Dv NOCARRIER_ROAMING
+dhcpcd lost the carrier but the interface configuration is persisted.
+The OS has to support wireless roaming or IP Persistance for this to happen.
.It Dv INFORM | Dv INFORM6
dhcpcd informed a DHCP server about its address and obtained other
configuration details.
@@ -147,10 +150,6 @@
The following variables will then be set, along with any protocol supplied
ones.
.Bl -tag -width xnew_delegated_dhcp6_prefix
-.It Ev $chroot
-the directory where
-.Nm dhcpcd
-is chrooted.
.It Ev $interface
the name of the interface.
.It Ev $protocol
@@ -193,12 +192,14 @@
.Ev interface
is up, otherwise
.Dv false .
+This is more than IFF_UP and may not be equal.
.It Ev $if_down
.Dv true
if the
.Ev interface
is down, otherwise
.Dv false .
+This is more than IFF_UP and may not be equal.
.It Ev $af_waiting
Address family waiting for, as defined in
.Xr dhcpcd.conf 5 .
diff -r c1ca9e2b33af -r 0893b9f3100b external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h Sun Dec 27 18:25:08 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h Mon Dec 28 13:56:25 2020 +0000
@@ -29,7 +29,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "9.3.4"
+#define VERSION "9.4.0"
#ifndef PRIVSEP_USER
# define PRIVSEP_USER "_" PACKAGE
diff -r c1ca9e2b33af -r 0893b9f3100b external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c Sun Dec 27 18:25:08 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c Mon Dec 28 13:56:25 2020 +0000
@@ -3886,20 +3886,9 @@
state->clientid = NULL;
if (ifo->options & DHCPCD_ANONYMOUS) {
- uint8_t duid[DUID_LEN];
- uint8_t duid_len;
-
- duid_len = (uint8_t)duid_make(duid, ifp, DUID_LL);
- if (duid_len != 0) {
- state->clientid = malloc((size_t)duid_len + 6);
- if (state->clientid == NULL)
- goto eexit;
- state->clientid[0] =(uint8_t)(duid_len + 5);
- state->clientid[1] = 255; /* RFC 4361 */
- memcpy(state->clientid + 2, ifo->iaid, 4);
- memset(state->clientid + 2, 0, 4); /* IAID */
- memcpy(state->clientid + 6, duid, duid_len);
- }
+ /* Removing the option could show that we want anonymous.
+ * As such keep it as it's already in the hwaddr field. */
+ goto make_clientid;
} else if (*ifo->clientid) {
state->clientid = malloc((size_t)(ifo->clientid[0] + 1));
if (state->clientid == NULL)
@@ -3917,6 +3906,7 @@
memcpy(state->clientid + 6, ifp->ctx->duid,
ifp->ctx->duid_len);
} else {
+make_clientid:
len = (uint8_t)(ifp->hwlen + 1);
state->clientid = malloc((size_t)len + 1);
if (state->clientid == NULL)
diff -r c1ca9e2b33af -r 0893b9f3100b external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c Sun Dec 27 18:25:08 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c Mon Dec 28 13:56:25 2020 +0000
@@ -2065,7 +2065,8 @@
state->lerror = code;
errno = 0;
- if (code != 0 && ifp->ctx->options & DHCPCD_TEST)
+ /* code cannot be D6_STATUS_OK, so there is a failure */
+ if (ifp->ctx->options & DHCPCD_TEST)
eloop_exit(ifp->ctx->eloop, EXIT_FAILURE);
return (int)code;
diff -r c1ca9e2b33af -r 0893b9f3100b external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c Sun Dec 27 18:25:08 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c Mon Dec 28 13:56:25 2020 +0000
@@ -695,36 +695,55 @@
loginfox("%s: connected to Access Point: %s", ifp->name, pssid);
}
+static void
+dhcpcd_nocarrier_roaming(struct interface *ifp)
+{
+
+ loginfox("%s: carrier lost - roaming", ifp->name);
+
+#ifdef ARP
+ arp_drop(ifp);
+#endif
+#ifdef INET
+ dhcp_abort(ifp);
+#endif
+#ifdef DHCP6
+ dhcp6_abort(ifp);
+#endif
+
+ rt_build(ifp->ctx, AF_UNSPEC);
+ script_runreason(ifp, "NOCARRIER_ROAMING");
+}
+
void
dhcpcd_handlecarrier(struct interface *ifp, int carrier, unsigned int flags)
{
bool was_link_up = if_is_link_up(ifp);
+ bool was_roaming = if_roaming(ifp);
ifp->carrier = carrier;
ifp->flags = flags;
if (!if_is_link_up(ifp)) {
- if (!was_link_up || !ifp->active)
+ if (!ifp->active || (!was_link_up && !was_roaming))
return;
+
+ /*
+ * If the interface is roaming (generally on wireless)
+ * then while we are not up, we are not down either.
+ * Preserve the network state until we either disconnect
+ * or re-connect.
+ */
+ if (!ifp->options->randomise_hwaddr && if_roaming(ifp)) {
+ dhcpcd_nocarrier_roaming(ifp);
+ 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))
- {
-#ifdef ARP
- arp_drop(ifp);
-#endif
-#ifdef INET
- dhcp_abort(ifp);
-#endif
-#ifdef DHCP6
- dhcp6_abort(ifp);
-#endif
- } else
-#endif
- dhcpcd_drop(ifp, 0);
- if (ifp->options->options & DHCPCD_ANONYMOUS) {
+ dhcpcd_drop(ifp, 0);
+
+ if (ifp->options->randomise_hwaddr) {
bool is_up = ifp->flags & IFF_UP;
if (is_up)
@@ -734,6 +753,7 @@
if (is_up)
if_up(ifp);
}
+
return;
}
@@ -774,9 +794,7 @@
memcmp(ifp->ssid, ossid, ifp->ssid_len)) && ifp->active)
{
dhcpcd_reportssid(ifp);
-#ifdef NOCARRIER_PRESERVE_IP
dhcpcd_drop(ifp, 0);
-#endif
#ifdef IPV4LL
ipv4ll_reset(ifp);
#endif
@@ -788,17 +806,17 @@
dhcpcd_initstate(ifp, 0);
script_runreason(ifp, "CARRIER");
+
#ifdef INET6
-#ifdef NOCARRIER_PRESERVE_IP
/* Set any IPv6 Routers we remembered to expire faster than they
* would normally as we maybe on a new network. */
ipv6nd_startexpire(ifp);
-#endif
#ifdef IPV6_MANAGETEMPADDR
/* RFC4941 Section 3.5 */
ipv6_regentempaddrs(ifp);
#endif
#endif
+
dhcpcd_startinterface(ifp);
}
@@ -951,22 +969,22 @@
{
struct interface *ifp = arg;
struct dhcpcd_ctx *ctx = ifp->ctx;
- bool anondown;
+ bool randmac_down;
if (ifp->carrier <= LINK_DOWN &&
- ifp->options->options & DHCPCD_ANONYMOUS &&
+ ifp->options->randomise_hwaddr &&
ifp->flags & IFF_UP)
{
if_down(ifp);
- anondown = true;
+ randmac_down = true;
} else
- anondown = false;
+ randmac_down = false;
if ((!(ctx->options & DHCPCD_MASTER) ||
Home |
Main Index |
Thread Index |
Old Index