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/e66d71894d59
branches:  trunk
changeset: 1008755:e66d71894d59
user:      roy <roy%NetBSD.org@localhost>
date:      Thu Apr 02 12:41:47 2020 +0000

description:
Sync

diffstat:

 external/bsd/dhcpcd/dist/hooks/20-resolv.conf      |    4 +-
 external/bsd/dhcpcd/dist/hooks/30-hostname         |  161 ----
 external/bsd/dhcpcd/dist/hooks/50-ntp.conf         |    2 +-
 external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in |    2 +-
 external/bsd/dhcpcd/dist/src/bpf.c                 |  139 ++-
 external/bsd/dhcpcd/dist/src/dhcp.c                |  671 ++++++++++-------
 external/bsd/dhcpcd/dist/src/dhcp6.c               |  770 ++++++++++----------
 external/bsd/dhcpcd/dist/src/dhcpcd.8.in           |   32 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.c              |  637 +++++++++++-----
 external/bsd/dhcpcd/dist/src/if-bsd.c              |  349 +++++++-
 external/bsd/dhcpcd/dist/src/if-options.c          |  133 ++-
 external/bsd/dhcpcd/dist/src/ipv6.c                |  174 ++--
 external/bsd/dhcpcd/dist/src/ipv6.h                |   11 +-
 external/bsd/dhcpcd/dist/src/ipv6nd.c              |  392 ++++++----
 external/bsd/dhcpcd/dist/src/logerr.c              |   54 +-
 external/bsd/dhcpcd/dist/src/script.c              |  255 ++++--
 16 files changed, 2227 insertions(+), 1559 deletions(-)

diffs (truncated from 6765 to 300 lines):

diff -r 78c86114c860 -r e66d71894d59 external/bsd/dhcpcd/dist/hooks/20-resolv.conf
--- a/external/bsd/dhcpcd/dist/hooks/20-resolv.conf     Thu Apr 02 12:38:54 2020 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/20-resolv.conf     Thu Apr 02 12:41:47 2020 +0000
@@ -42,7 +42,7 @@
                # Build the nameserver list
                srvs=$(cd "$resolv_conf_dir"; \
                        key_get_value "nameserver " ${interfaces})
-               for x in $(uniqify ${srvs}); do
+               for x in $(uniqify $srvs); do
                        servers="${servers}nameserver $x$NL"
                done
        fi
@@ -152,6 +152,7 @@
                fi
        fi
        if [ -n "$new_domain_search" ]; then
+               new_domain_search=$(uniqify $new_domain_search)
                if valid_domainname_list $new_domain_search; then
                        conf="${conf}search $new_domain_search$NL"
                elif ! $warn; then
@@ -159,6 +160,7 @@
                            "$new_domain_search"
                fi
        fi
+       new_domain_name_servers=$(uniqify $new_domain_name_servers)
        for x in ${new_domain_name_servers}; do
                conf="${conf}nameserver $x$NL"
        done
diff -r 78c86114c860 -r e66d71894d59 external/bsd/dhcpcd/dist/hooks/30-hostname
--- a/external/bsd/dhcpcd/dist/hooks/30-hostname        Thu Apr 02 12:38:54 2020 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-# Set the hostname from DHCP data if required
-
-# A hostname can either be a short hostname or a FQDN.
-# hostname_fqdn=true
-# hostname_fqdn=false
-# hostname_fqdn=server
-
-# A value of server means just what the server says, don't manipulate it.
-# This could lead to an inconsistent hostname on a DHCPv4 and DHCPv6 network
-# where the DHCPv4 hostname is short and the DHCPv6 has an FQDN.
-# DHCPv6 has no hostname option.
-# RFC4702 section 3.1 says FQDN should be prefered over hostname.
-#
-# As such, the default is hostname_fqdn=true so that a consistent hostname
-# is always assigned.
-: ${hostname_fqdn:=true}
-
-# If we used to set the hostname, but relinquish control of it, we should
-# reset to the default value.
-: ${hostname_default=localhost}
-
-# Some systems don't have hostname(1)
-_hostname()
-{
-       if [ -z "${1+x}" ]; then
-               if type hostname >/dev/null 2>&1; then
-                       hostname
-               elif [ -r /proc/sys/kernel/hostname ]; then
-                       read name </proc/sys/kernel/hostname && echo "$name"
-               elif sysctl kern.hostname >/dev/null 2>&1; then
-                       sysctl -n kern.hostname
-               elif sysctl kernel.hostname >/dev/null 2>&1; then
-                       sysctl -n kernel.hostname
-               else
-                       return 1
-               fi
-               return $?
-       fi
-
-       # Always prefer hostname(1) if we have it
-       if type hostname >/dev/null 2>&1; then
-               hostname "$1"
-       elif [ -w /proc/sys/kernel/hostname ]; then
-               echo "$1" >/proc/sys/kernel/hostname
-       elif sysctl kern.hostname >/dev/null 2>&1; then
-               sysctl -w "kern.hostname=$1"
-       elif sysctl kernel.hostname >/dev/null 2>&1; then
-               sysctl -w "kernel.hostname=$1"
-       else
-               # We know this will fail, but it will now fail
-               # with an error to stdout
-               hostname "$1"
-       fi
-}
-
-set_hostname_vars()
-{
-       hfqdn=false
-       hshort=false
-       case "$hostname_fqdn" in
-       [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1)        hfqdn=true;;
-       ""|[Ss][Ee][Rr][Vv][Ee][Rr])            ;;
-       *)                                      hshort=true;;
-       esac
-}
-
-need_hostname()
-{
-       # Always load the hostname variable for future use
-       hostname="$(_hostname)"
-       case "$hostname" in
-       ""|"(none)"|localhost|localhost.localdomain|"$hostname_default")
-               return 0;;
-       esac
-
-       case "$force_hostname" in
-       [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) return 0;;
-       esac
-
-       set_hostname_vars
-
-       if [ -n "$old_fqdn" ]; then
-               if ${hfqdn} || ! ${hshort}; then
-                       [ "$hostname" = "$old_fqdn" ]
-               else
-                       [ "$hostname" = "${old_fqdn%%.*}" ]
-               fi
-       elif [ -n "$old_host_name" ]; then
-               if ${hfqdn}; then
-                       if [ -n "$old_domain_name" ] &&
-                          [ "$old_host_name" = "${old_host_name#*.}" ]
-                       then
-                               [ "$hostname" = \
-                                   "$old_host_name.$old_domain_name" ]
-                       else
-                               [ "$hostname" = "$old_host_name" ]
-                       fi
-               elif ${hshort}; then
-                       [ "$hostname" = "${old_host_name%%.*}" ]
-               else
-                       [ "$hostname" = "$old_host_name" ]
-               fi
-       else
-               # No old hostname
-               false
-       fi
-}
-
-try_hostname()
-{
-       [ "$hostname" = "$1" ] && return 0
-       if valid_domainname "$1"; then
-               syslog info "Setting hostname: $1"
-               _hostname "$1"
-       else
-               syslog err "Invalid hostname: $1"
-       fi
-}
-
-set_hostname()
-{
-       need_hostname || return
-
-       set_hostname_vars
-
-       if [ -n "$new_fqdn" ]; then
-               if ${hfqdn} || ! ${hshort}; then
-                       try_hostname "$new_fqdn"
-               else
-                       try_hostname "${new_fqdn%%.*}"
-               fi
-       elif [ -n "$new_host_name" ]; then
-               if ${hfqdn}; then
-                       if [ -n "$new_domain_name" ] &&
-                          [ "$new_host_name" = "${new_host_name#*.}" ]
-                       then
-                               try_hostname "$new_host_name.$new_domain_name"
-                       else
-                               try_hostname "$new_host_name"
-                       fi
-               elif ${hshort}; then
-                       try_hostname "${new_host_name%%.*}"
-               else
-                       try_hostname "$new_host_name"
-               fi
-       elif [ -n "${hostname_default+x}" ]; then
-               try_hostname "$hostname_default"
-       fi
-}
-
-# For ease of use, map DHCP6 names onto our DHCP4 names
-case "$reason" in
-BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
-       new_fqdn="$new_dhcp6_fqdn"
-       old_fqdn="$old_dhcp6_fqdn"
-       ;;
-esac
-
-if $if_up; then
-       set_hostname
-fi
diff -r 78c86114c860 -r e66d71894d59 external/bsd/dhcpcd/dist/hooks/50-ntp.conf
--- a/external/bsd/dhcpcd/dist/hooks/50-ntp.conf        Thu Apr 02 12:38:54 2020 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/50-ntp.conf        Thu Apr 02 12:41:47 2020 +0000
@@ -41,7 +41,7 @@
        esac
 fi
 
-# Debian has a seperate file for DHCP config to avoid stamping on
+# 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
        [ -e /var/lib/ntp ] || mkdir /var/lib/ntp
diff -r 78c86114c860 -r e66d71894d59 external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in
--- a/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in        Thu Apr 02 12:38:54 2020 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in        Thu Apr 02 12:41:47 2020 +0000
@@ -8,7 +8,7 @@
 signature="$signature_base $from $ifname"
 signature_base_end="# End of dhcpcd"
 signature_end="$signature_base_end $from $ifname"
-state_dir=@RUNDIR@/dhcpcd
+state_dir=@RUNDIR@/hook-state
 _detected_init=false
 
 : ${if_up:=false}
diff -r 78c86114c860 -r e66d71894d59 external/bsd/dhcpcd/dist/src/bpf.c
--- a/external/bsd/dhcpcd/dist/src/bpf.c        Thu Apr 02 12:38:54 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/bpf.c        Thu Apr 02 12:41:47 2020 +0000
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * dhcpcd: BPF arp and bootp filtering
- * Copyright (c) 2006-2019 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2020 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -93,6 +93,38 @@
        }
 }
 
+void *
+bpf_frame_header_src(const struct interface *ifp, void *fh, size_t *len)
+{
+       uint8_t *f = fh;
+
+       switch (ifp->family) {
+       case ARPHRD_ETHER:
+               *len = sizeof(((struct ether_header *)0)->ether_shost);
+               return f + offsetof(struct ether_header, ether_shost);
+       default:
+               *len = 0;
+               errno = ENOTSUP;
+               return NULL;
+       }
+}
+
+void *
+bpf_frame_header_dst(const struct interface *ifp, void *fh, size_t *len)
+{
+       uint8_t *f = fh;
+
+       switch (ifp->family) {
+       case ARPHRD_ETHER:
+               *len = sizeof(((struct ether_header *)0)->ether_dhost);
+               return f + offsetof(struct ether_header, ether_dhost);
+       default:
+               *len = 0;
+               errno = ENOTSUP;
+               return NULL;
+       }
+}
+
 static const uint8_t etherbcastaddr[] =
     { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 
@@ -215,7 +247,6 @@
 bpf_read(struct interface *ifp, int fd, void *data, size_t len,
     unsigned int *flags)
 {
-       ssize_t fl = (ssize_t)bpf_frame_header_len(ifp);
        ssize_t bytes;
        struct ipv4_state *state = IPV4_STATE(ifp);
 
@@ -250,10 +281,10 @@
                        *flags |= BPF_BCAST;
                else
                        *flags &= ~BPF_BCAST;
-               payload += fl;
-               bytes = (ssize_t)packet.bh_caplen - fl;
-               if ((size_t)bytes > len)
+               if (packet.bh_caplen > len)
                        bytes = (ssize_t)len;
+               else
+                       bytes = (ssize_t)packet.bh_caplen;
                memcpy(data, payload, (size_t)bytes);
 next:
                state->buffer_pos += BPF_WORDALIGN(packet.bh_hdrlen +
@@ -464,6 +495,8 @@
        struct bpf_insn *bp;
        struct iarp_state *state;
        uint16_t arp_len;
+       struct arp_state *astate;
+       size_t naddrs;
 
        if (fd == -1)
                return 0;
@@ -490,58 +523,60 @@



Home | Main Index | Thread Index | Old Index