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-10.0.1 with the foll...



details:   https://anonhg.NetBSD.org/src/rev/ae72a3ab8628
branches:  roy
changeset: 374396:ae72a3ab8628
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Apr 21 16:52:28 2023 +0000

description:
Update to dhcpcd-10.0.1 with the following changes:

 * privsep: keep resources open rather than open/close
 * dhcp6: OPTION_NTP_SERVER is now preferred over OPTION_SNTP_SERVER
 * Misc bug fixes mainly around privsep for many platforms.
 * Fix for reading the some BSD routing table entries.
 * Fix reading authtokens from config.

Big new release, mainly around better privsep process management
which allows us to detect when they exit unexpectedly.

diffstat:

 external/bsd/dhcpcd/dist/LICENSE                  |    2 +-
 external/bsd/dhcpcd/dist/README.md                |   10 +-
 external/bsd/dhcpcd/dist/hooks/10-wpa_supplicant  |    4 +-
 external/bsd/dhcpcd/dist/hooks/20-resolv.conf     |    2 +-
 external/bsd/dhcpcd/dist/hooks/29-lookup-hostname |    6 +-
 external/bsd/dhcpcd/dist/hooks/30-hostname        |    4 +-
 external/bsd/dhcpcd/dist/hooks/50-ntp.conf        |    6 +-
 external/bsd/dhcpcd/dist/src/arp.c                |   34 +-
 external/bsd/dhcpcd/dist/src/arp.h                |    2 +-
 external/bsd/dhcpcd/dist/src/auth.c               |    2 +-
 external/bsd/dhcpcd/dist/src/auth.h               |    2 +-
 external/bsd/dhcpcd/dist/src/bpf.c                |   38 +-
 external/bsd/dhcpcd/dist/src/bpf.h                |    2 +-
 external/bsd/dhcpcd/dist/src/common.c             |    2 +-
 external/bsd/dhcpcd/dist/src/common.h             |    2 +-
 external/bsd/dhcpcd/dist/src/control.c            |  198 ++--
 external/bsd/dhcpcd/dist/src/control.h            |    2 +-
 external/bsd/dhcpcd/dist/src/defs.h               |    4 +-
 external/bsd/dhcpcd/dist/src/dev.h                |    2 +-
 external/bsd/dhcpcd/dist/src/dhcp-common.c        |    2 +-
 external/bsd/dhcpcd/dist/src/dhcp-common.h        |    2 +-
 external/bsd/dhcpcd/dist/src/dhcp.c               |   81 +-
 external/bsd/dhcpcd/dist/src/dhcp.h               |    2 +-
 external/bsd/dhcpcd/dist/src/dhcp6.c              |  102 +-
 external/bsd/dhcpcd/dist/src/dhcp6.h              |    3 +-
 external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c    |    2 +-
 external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h    |    2 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.c             |  184 ++-
 external/bsd/dhcpcd/dist/src/dhcpcd.h             |   19 +-
 external/bsd/dhcpcd/dist/src/duid.c               |   13 +-
 external/bsd/dhcpcd/dist/src/duid.h               |    2 +-
 external/bsd/dhcpcd/dist/src/eloop.c              |  943 ++++++++++++++++-----
 external/bsd/dhcpcd/dist/src/eloop.h              |   33 +-
 external/bsd/dhcpcd/dist/src/if-bsd.c             |   82 +-
 external/bsd/dhcpcd/dist/src/if-options.c         |   74 +-
 external/bsd/dhcpcd/dist/src/if-options.h         |    5 +-
 external/bsd/dhcpcd/dist/src/if.c                 |   13 +-
 external/bsd/dhcpcd/dist/src/if.h                 |   31 +-
 external/bsd/dhcpcd/dist/src/ipv4.c               |    2 +-
 external/bsd/dhcpcd/dist/src/ipv4.h               |    2 +-
 external/bsd/dhcpcd/dist/src/ipv4ll.c             |    2 +-
 external/bsd/dhcpcd/dist/src/ipv4ll.h             |    2 +-
 external/bsd/dhcpcd/dist/src/ipv6.c               |  109 +-
 external/bsd/dhcpcd/dist/src/ipv6.h               |    2 +-
 external/bsd/dhcpcd/dist/src/ipv6nd.c             |   98 +-
 external/bsd/dhcpcd/dist/src/ipv6nd.h             |    4 +-
 external/bsd/dhcpcd/dist/src/logerr.c             |    2 +-
 external/bsd/dhcpcd/dist/src/logerr.h             |    2 +-
 external/bsd/dhcpcd/dist/src/route.c              |    5 +-
 external/bsd/dhcpcd/dist/src/route.h              |    2 +-
 external/bsd/dhcpcd/dist/src/sa.c                 |    2 +-
 external/bsd/dhcpcd/dist/src/sa.h                 |    2 +-
 external/bsd/dhcpcd/dist/src/script.c             |    2 +-
 external/bsd/dhcpcd/dist/src/script.h             |    2 +-
 54 files changed, 1454 insertions(+), 705 deletions(-)

diffs (truncated from 4117 to 300 lines):

diff -r 22179ee1c670 -r ae72a3ab8628 external/bsd/dhcpcd/dist/LICENSE
--- a/external/bsd/dhcpcd/dist/LICENSE  Fri Oct 22 13:21:58 2021 +0000
+++ b/external/bsd/dhcpcd/dist/LICENSE  Fri Apr 21 16:52:28 2023 +0000
@@ -1,4 +1,4 @@
-Copyright (c) 2006-2021 Roy Marples <roy%marples.name@localhost>
+Copyright (c) 2006-2023 Roy Marples <roy%marples.name@localhost>
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
diff -r 22179ee1c670 -r ae72a3ab8628 external/bsd/dhcpcd/dist/README.md
--- a/external/bsd/dhcpcd/dist/README.md        Fri Oct 22 13:21:58 2021 +0000
+++ b/external/bsd/dhcpcd/dist/README.md        Fri Apr 21 16:52:28 2023 +0000
@@ -1,11 +1,11 @@
 # dhcpcd
 
 dhcpcd is a
-[DHCP](http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol) and a
-[DHCPv6](http://en.wikipedia.org/wiki/DHCPv6) client.
-It's also an IPv4LL (aka [ZeroConf](http://en.wikipedia.org/wiki/Zeroconf))
+[DHCP](https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol) and a
+[DHCPv6](https://en.wikipedia.org/wiki/DHCPv6) client.
+It's also an IPv4LL (aka [ZeroConf](https://en.wikipedia.org/wiki/Zeroconf))
 client.
-In layman's terms, dhcpcd runs on your machine and silently configures your
+In layperson's terms, dhcpcd runs on your machine and silently configures your
 computer to work on the attached networks without trouble and mostly without
 configuration.
 
@@ -93,4 +93,4 @@ dhcpcd-9 defaults the run directory to `
 We no longer supply a ChangeLog.
 However, you're more than welcome to read the
 [commit log](https://roy.marples.name/git/dhcpcd/log) and
-[archived release announcements](http://roy.marples.name/archives/dhcpcd-discuss/).
+[archived release announcements](https://roy.marples.name/archives/dhcpcd-discuss/).
diff -r 22179ee1c670 -r ae72a3ab8628 external/bsd/dhcpcd/dist/hooks/10-wpa_supplicant
--- a/external/bsd/dhcpcd/dist/hooks/10-wpa_supplicant  Fri Oct 22 13:21:58 2021 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/10-wpa_supplicant  Fri Apr 21 16:52:28 2023 +0000
@@ -102,8 +102,8 @@ wpa_supplicant_stop()
 }
 
 if [ "$ifwireless" = "1" ] && \
-    type wpa_supplicant >/dev/null 2>&1 && \
-    type wpa_cli >/dev/null 2>&1
+    command -v wpa_supplicant >/dev/null 2>&1 && \
+    command -v wpa_cli >/dev/null 2>&1
 then
        case "$reason" in
        PREINIT)        wpa_supplicant_start;;
diff -r 22179ee1c670 -r ae72a3ab8628 external/bsd/dhcpcd/dist/hooks/20-resolv.conf
--- a/external/bsd/dhcpcd/dist/hooks/20-resolv.conf     Fri Oct 22 13:21:58 2021 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/20-resolv.conf     Fri Apr 21 16:52:28 2023 +0000
@@ -11,7 +11,7 @@ nocarrier_roaming_dir="$state_dir/roamin
 NL="
 "
 : ${resolvconf:=resolvconf}
-if type "$resolvconf" >/dev/null 2>&1; then
+if command -v "$resolvconf" >/dev/null 2>&1; then
        have_resolvconf=true
 else
        have_resolvconf=false
diff -r 22179ee1c670 -r ae72a3ab8628 external/bsd/dhcpcd/dist/hooks/29-lookup-hostname
--- a/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname Fri Oct 22 13:21:58 2021 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname Fri Apr 21 16:52:28 2023 +0000
@@ -4,20 +4,20 @@ lookup_hostname()
 {
        [ -z "$new_ip_address" ] && return 1
        # Silly ISC programs love to send error text to stdout
-       if type dig >/dev/null 2>&1; then
+       if command -v dig >/dev/null 2>&1; then
                h=$(dig +short -x $new_ip_address)
                if [ $? = 0 ]; then
                        echo "$h" | sed 's/\.$//'
                        return 0
                fi
-       elif type host >/dev/null 2>&1; then
+       elif command -v host >/dev/null 2>&1; then
                h=$(host $new_ip_address)
                if [ $? = 0 ]; then 
                        echo "$h" \
                        | sed 's/.* domain name pointer \(.*\)./\1/'
                        return 0
                fi
-       elif type getent >/dev/null 2>&1; then
+       elif command -v getent >/dev/null 2>&1; then
                h=$(getent hosts $new_ip_address)
                if [ $? = 0 ]; then
                        echo "$h" | sed 's/[^ ]* *\([^ ]*\).*/\1/'
diff -r 22179ee1c670 -r ae72a3ab8628 external/bsd/dhcpcd/dist/hooks/30-hostname
--- a/external/bsd/dhcpcd/dist/hooks/30-hostname        Fri Oct 22 13:21:58 2021 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/30-hostname        Fri Apr 21 16:52:28 2023 +0000
@@ -25,7 +25,7 @@
        if [ -z "${1+x}" ]; then
                if [ -r /proc/sys/kernel/hostname ]; then
                        read name </proc/sys/kernel/hostname && echo "$name"
-               elif type hostname >/dev/null 2>/dev/null; then
+               elif command -v hostname >/dev/null 2>/dev/null; then
                        hostname
                elif sysctl kern.hostname >/dev/null 2>&1; then
                        sysctl -n kern.hostname
@@ -39,7 +39,7 @@
 
        if [ -w /proc/sys/kernel/hostname ]; then
                echo "$1" >/proc/sys/kernel/hostname
-       elif [ -n "$1" ] && type hostname >/dev/null 2>&1; then
+       elif [ -n "$1" ] && command -v hostname >/dev/null 2>&1; then
                hostname "$1"
        elif sysctl kern.hostname >/dev/null 2>&1; then
                sysctl -w "kern.hostname=$1" >/dev/null
diff -r 22179ee1c670 -r ae72a3ab8628 external/bsd/dhcpcd/dist/hooks/50-ntp.conf
--- a/external/bsd/dhcpcd/dist/hooks/50-ntp.conf        Fri Oct 22 13:21:58 2021 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/50-ntp.conf        Fri Apr 21 16:52:28 2023 +0000
@@ -43,7 +43,7 @@ fi
 
 # Debian has a separate file for DHCP config to avoid stamping on
 # the master.
-if [ "$ntp_service" = ntpd ] && type invoke-rc.d >/dev/null 2>&1; then
+if [ "$ntp_service" = ntpd ] && command -v invoke-rc.d >/dev/null 2>&1; then
        [ -e /var/lib/ntp ] || mkdir /var/lib/ntp
        : ${ntp_service:=ntp}
        : ${NTP_DHCP_CONF:=/var/lib/ntp/ntp.conf.dhcp}
@@ -113,7 +113,7 @@ add_ntp_conf()
        [ -e "$cf" ] && rm "$cf"
        [ -d "$ntp_conf_dir" ] || mkdir -p "$ntp_conf_dir"
        if [ -n "$new_ntp_servers" ]; then
-               for x in $new_ntp_servers; do
+               for x in $(uniqify $new_ntp_servers); do
                        echo "server $x" >> "$cf"
                done
        fi
@@ -131,7 +131,7 @@ remove_ntp_conf()
 # For ease of use, map DHCP6 names onto our DHCP4 names
 case "$reason" in
 BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
-       new_ntp_servers="$new_dhcp6_sntp_servers"
+       new_ntp_servers="$new_dhcp6_sntp_servers $new_dhcp6_ntp_server_addr $new_dhcp6_ntp_server_fqdn"
 ;;
 esac
 
diff -r 22179ee1c670 -r ae72a3ab8628 external/bsd/dhcpcd/dist/src/arp.c
--- a/external/bsd/dhcpcd/dist/src/arp.c        Fri Oct 22 13:21:58 2021 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.c        Fri Apr 21 16:52:28 2023 +0000
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd - ARP handler
- * Copyright (c) 2006-2021 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2023 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -232,6 +232,9 @@ arp_packet(struct interface *ifp, uint8_
        const struct iarp_state *state;
        struct arp_state *astate, *astaten;
        uint8_t *hw_s, *hw_t;
+#ifndef KERNEL_RFC5227
+       bool is_probe;
+#endif /* KERNEL_RFC5227 */
 
        /* Copy the frame header source and destination out */
        memset(&arm, 0, sizeof(arm));
@@ -284,6 +287,23 @@ arp_packet(struct interface *ifp, uint8_
        memcpy(&arm.tha, hw_t, ar.ar_hln);
        memcpy(&arm.tip.s_addr, hw_t + ar.ar_hln, ar.ar_pln);
 
+#ifndef KERNEL_RFC5227
+       /* During ARP probe the 'sender hardware address' MUST contain the hardware
+        * address of the interface sending the packet. RFC5227, 1.1 */
+       is_probe = ar.ar_op == htons(ARPOP_REQUEST) && IN_IS_ADDR_UNSPECIFIED(&arm.sip) &&
+           bpf_flags & BPF_BCAST;
+       if (is_probe && falen > 0 && (falen != ar.ar_hln ||
+           memcmp(&arm.sha, &arm.fsha, ar.ar_hln))) {
+               char abuf[HWADDR_LEN * 3];
+               char fbuf[HWADDR_LEN * 3];
+               hwaddr_ntoa(&arm.sha, ar.ar_hln, abuf, sizeof(abuf));
+               hwaddr_ntoa(&arm.fsha, falen, fbuf, sizeof(fbuf));
+               logwarnx("%s: invalid ARP probe, sender hw address mismatch (%s, %s)",
+                   ifp->name, abuf, fbuf);
+               return;
+       }
+#endif /* KERNEL_RFC5227 */
+
        /* Match the ARP probe to our states.
         * Ignore Unicast Poll, RFC1122. */
        state = ARP_CSTATE(ifp);
@@ -299,7 +319,7 @@ arp_packet(struct interface *ifp, uint8_
 }
 
 static void
-arp_read(void *arg)
+arp_read(void *arg, unsigned short events)
 {
        struct arp_state *astate = arg;
        struct bpf *bpf = astate->bpf;
@@ -308,6 +328,9 @@ arp_read(void *arg)
        ssize_t bytes;
        struct in_addr addr = astate->addr;
 
+       if (events != ELE_READ)
+               logerrx("%s: unexpected event 0x%04x", __func__, events);
+
        /* Some RAW mechanisms are generic file descriptors, not sockets.
         * This means we have no kernel call to just get one packet,
         * so we have to process the entire buffer. */
@@ -532,7 +555,7 @@ arp_new(struct interface *ifp, const str
        struct arp_state *astate;
 
        if ((state = ARP_STATE(ifp)) == NULL) {
-               ifp->if_data[IF_DATA_ARP] = malloc(sizeof(*state));
+               ifp->if_data[IF_DATA_ARP] = malloc(sizeof(*state));
                state = ARP_STATE(ifp);
                if (state == NULL) {
                        logerr(__func__);
@@ -567,8 +590,9 @@ arp_new(struct interface *ifp, const str
                        free(astate);
                        return NULL;
                }
-               eloop_event_add(ifp->ctx->eloop, astate->bpf->bpf_fd,
-                   arp_read, astate);
+               if (eloop_event_add(ifp->ctx->eloop, astate->bpf->bpf_fd, ELE_READ,
+                   arp_read, astate) == -1)
+                       logerr("%s: eloop_event_add", __func__);
        }
 
 
diff -r 22179ee1c670 -r ae72a3ab8628 external/bsd/dhcpcd/dist/src/arp.h
--- a/external/bsd/dhcpcd/dist/src/arp.h        Fri Oct 22 13:21:58 2021 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.h        Fri Apr 21 16:52:28 2023 +0000
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2021 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2023 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
diff -r 22179ee1c670 -r ae72a3ab8628 external/bsd/dhcpcd/dist/src/auth.c
--- a/external/bsd/dhcpcd/dist/src/auth.c       Fri Oct 22 13:21:58 2021 +0000
+++ b/external/bsd/dhcpcd/dist/src/auth.c       Fri Apr 21 16:52:28 2023 +0000
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2021 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2023 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
diff -r 22179ee1c670 -r ae72a3ab8628 external/bsd/dhcpcd/dist/src/auth.h
--- a/external/bsd/dhcpcd/dist/src/auth.h       Fri Oct 22 13:21:58 2021 +0000
+++ b/external/bsd/dhcpcd/dist/src/auth.h       Fri Apr 21 16:52:28 2023 +0000
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2021 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2023 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
diff -r 22179ee1c670 -r ae72a3ab8628 external/bsd/dhcpcd/dist/src/bpf.c
--- a/external/bsd/dhcpcd/dist/src/bpf.c        Fri Oct 22 13:21:58 2021 +0000
+++ b/external/bsd/dhcpcd/dist/src/bpf.c        Fri Apr 21 16:52:28 2023 +0000
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd: BPF arp and bootp filtering
- * Copyright (c) 2006-2021 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2023 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -45,7 +45,6 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <paths.h>
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
@@ -155,6 +154,11 @@ bpf_open(const struct interface *ifp,
        struct bpf_version pv = { .bv_major = 0, .bv_minor = 0 };
        struct ifreq ifr = { .ifr_flags = 0 };
        int ibuf_len = 0;
+#ifdef O_CLOEXEC
+#define BPF_OPEN_FLAGS O_RDWR | O_NONBLOCK | O_CLOEXEC
+#else
+#define BPF_OPEN_FLAGS O_RDWR | O_NONBLOCK
+#endif
 #ifdef BIOCIMMEDIATE
        unsigned int flags;
 #endif
@@ -167,25 +171,19 @@ bpf_open(const struct interface *ifp,
                return NULL;
        bpf->bpf_ifp = ifp;
 
-#ifdef _PATH_BPF
-       bpf->bpf_fd = open(_PATH_BPF, O_RDWR | O_NONBLOCK
-#ifdef O_CLOEXEC
-               | O_CLOEXEC



Home | Main Index | Thread Index | Old Index