Module Name: src
Committed By: martin
Date: Mon Apr 9 16:46:34 UTC 2018
Modified Files:
src/external/bsd/dhcpcd/dist [netbsd-8]: configure
src/external/bsd/dhcpcd/dist/hooks [netbsd-8]: 10-wpa_supplicant
15-timezone 20-resolv.conf 29-lookup-hostname 30-hostname
50-ntp.conf 50-yp.conf 50-ypbind.in dhcpcd-run-hooks.8.in
dhcpcd-run-hooks.in
src/external/bsd/dhcpcd/dist/src [netbsd-8]: arp.c common.h defs.h
dhcp.c dhcp.h dhcp6.c dhcp6.h dhcpcd.8.in dhcpcd.c dhcpcd.conf.5.in
dhcpcd.h if-bsd.c if-linux.c if-options.c if-options.h if-sun.c
if.c if.h ipv4.c ipv4.h ipv6.c ipv6.h ipv6nd.c ipv6nd.h logerr.h
route.c route.h
src/external/bsd/dhcpcd/dist/src/dev [netbsd-8]: udev.c
src/external/bsd/dhcpcd/dist/tests/eloop-bench [netbsd-8]:
eloop-bench.c
src/external/bsd/dhcpcd/include [netbsd-8]: config.h
src/external/bsd/dhcpcd/sbin/dhcpcd [netbsd-8]: Makefile
Log Message:
Catch up to current in external/bsd/dhcpcd/, requested by roy in ticket #707:
external/bsd/dhcpcd/dist/configure up to 1.1.1.7
external/bsd/dhcpcd/dist/hooks/10-wpa_supplicant up to 1.1.1.2
external/bsd/dhcpcd/dist/hooks/15-timezone up to 1.1.1.2
external/bsd/dhcpcd/dist/hooks/20-resolv.conf up to 1.1.1.2
external/bsd/dhcpcd/dist/hooks/29-lookup-hostname up to 1.1.1.2
external/bsd/dhcpcd/dist/hooks/30-hostname up to 1.1.1.2
external/bsd/dhcpcd/dist/hooks/50-ntp.conf up to 1.1.1.2
external/bsd/dhcpcd/dist/hooks/50-yp.conf up to 1.1.1.2
external/bsd/dhcpcd/dist/hooks/50-ypbind.in up to 1.1.1.2
external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in up to 1.1.1.4
external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in up to 1.1.1.4
external/bsd/dhcpcd/dist/src/arp.c up to 1.1.1.6
external/bsd/dhcpcd/dist/src/common.h up to 1.1.1.4
external/bsd/dhcpcd/dist/src/defs.h up to 1.1.1.11
external/bsd/dhcpcd/dist/src/dhcp.c up to 1.9
external/bsd/dhcpcd/dist/src/dhcp.h up to 1.1.1.5
external/bsd/dhcpcd/dist/src/dhcp6.c up to 1.1.1.10
external/bsd/dhcpcd/dist/src/dhcp6.h up to 1.1.1.4
external/bsd/dhcpcd/dist/src/dhcpcd.8.in up to 1.1.1.8
external/bsd/dhcpcd/dist/src/dhcpcd.c up to 1.10
external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in up to 1.1.1.7
external/bsd/dhcpcd/dist/src/dhcpcd.h up to 1.1.1.5
external/bsd/dhcpcd/dist/src/if-bsd.c up to 1.1.1.7
external/bsd/dhcpcd/dist/src/if-linux.c up to 1.1.1.8
external/bsd/dhcpcd/dist/src/if-options.c up to 1.8
external/bsd/dhcpcd/dist/src/if-options.h up to 1.1.1.7
external/bsd/dhcpcd/dist/src/if-sun.c up to 1.1.1.4
external/bsd/dhcpcd/dist/src/if.c up to 1.1.1.8
external/bsd/dhcpcd/dist/src/if.h up to 1.1.1.5
external/bsd/dhcpcd/dist/src/ipv4.c up to 1.1.1.9
external/bsd/dhcpcd/dist/src/ipv4.h up to 1.1.1.4
external/bsd/dhcpcd/dist/src/ipv6.c up to 1.1.1.8
external/bsd/dhcpcd/dist/src/ipv6.h up to 1.1.1.6
external/bsd/dhcpcd/dist/src/ipv6nd.c up to 1.1.1.7
external/bsd/dhcpcd/dist/src/ipv6nd.h up to 1.1.1.5
external/bsd/dhcpcd/dist/src/logerr.h up to 1.1.1.3
external/bsd/dhcpcd/dist/src/route.c up to 1.1.1.6
external/bsd/dhcpcd/dist/src/route.h up to 1.1.1.4
external/bsd/dhcpcd/dist/src/dev/udev.c up to 1.1.1.2
external/bsd/dhcpcd/dist/tests/eloop-bench/eloop-bench.c up to 1.1.1.3
external/bsd/dhcpcd/include/config.h up to 1.3
external/bsd/dhcpcd/sbin/dhcpcd/Makefile up to 1.43
Import dhcpcd-7.0.1 with the following changes:
* hooks: remove use of local builtin for better portability
* dhcpcd: don't log errors working out carrier for departed interfaces
* ipv4: allow configuration of static broadcast address
* if: don't set MTU during interface discovery
* if: don't activate non matching interfaces to commandline ones
* eloop-bench: fix hangs when using a large number of cycles
* dhcp: don't bind when we've just probed an address to inform
Import dhcpcd-7.0.2 with the following changes:
* Added support for setproctitle(3)
* Kernel RA is no longer disabled when IPv6 is disabled in dhcpcd
* DHCPv6 PD is no longer stopped if no Routers are found
* If the DHCP leased address is deleted, enter the reboot state
* DHCPv6 unicast is no longer performed when not in master mode
* dhcpcd will now detect netlink/route socket overflows ad re-sync
Import dhcpcd-7.0.3 with the following changes:
* dhcp6: fix a null termination overflow on status messages
* options: static routes can be setup in global context again
* routes: dhcpcd added host routes are now reported correctly
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.3.2.1 -r1.1.1.3.2.2 \
src/external/bsd/dhcpcd/dist/configure
cvs rdiff -u -r1.1.1.1 -r1.1.1.1.8.1 \
src/external/bsd/dhcpcd/dist/hooks/10-wpa_supplicant \
src/external/bsd/dhcpcd/dist/hooks/15-timezone \
src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf \
src/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname \
src/external/bsd/dhcpcd/dist/hooks/30-hostname \
src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf \
src/external/bsd/dhcpcd/dist/hooks/50-yp.conf \
src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in
cvs rdiff -u -r1.1.1.1.8.1 -r1.1.1.1.8.2 \
src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in \
src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in
cvs rdiff -u -r1.1.1.2.8.1 -r1.1.1.2.8.2 \
src/external/bsd/dhcpcd/dist/src/arp.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.1.1.1.8.1 -r1.1.1.1.8.2 \
src/external/bsd/dhcpcd/dist/src/common.h \
src/external/bsd/dhcpcd/dist/src/dhcp.h \
src/external/bsd/dhcpcd/dist/src/dhcp6.h \
src/external/bsd/dhcpcd/dist/src/ipv4.h \
src/external/bsd/dhcpcd/dist/src/ipv6nd.h \
src/external/bsd/dhcpcd/dist/src/logerr.h \
src/external/bsd/dhcpcd/dist/src/route.h
cvs rdiff -u -r1.1.1.4.2.1 -r1.1.1.4.2.2 \
src/external/bsd/dhcpcd/dist/src/defs.h \
src/external/bsd/dhcpcd/dist/src/dhcp6.c \
src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in \
src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in
cvs rdiff -u -r1.1.1.3.8.2 -r1.1.1.3.8.3 \
src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.4.2.1 -r1.4.2.2 src/external/bsd/dhcpcd/dist/src/dhcpcd.c \
src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.1.1.3.2.1 -r1.1.1.3.2.2 \
src/external/bsd/dhcpcd/dist/src/dhcpcd.h \
src/external/bsd/dhcpcd/dist/src/if-bsd.c \
src/external/bsd/dhcpcd/dist/src/if-linux.c \
src/external/bsd/dhcpcd/dist/src/if-options.h \
src/external/bsd/dhcpcd/dist/src/if.c \
src/external/bsd/dhcpcd/dist/src/ipv4.c \
src/external/bsd/dhcpcd/dist/src/ipv6.c \
src/external/bsd/dhcpcd/dist/src/route.c
cvs rdiff -u -r1.1.1.2.2.1 -r1.1.1.2.2.2 \
src/external/bsd/dhcpcd/dist/src/if-sun.c \
src/external/bsd/dhcpcd/dist/src/if.h \
src/external/bsd/dhcpcd/dist/src/ipv6.h
cvs rdiff -u -r1.1.1.1 -r1.1.1.1.8.1 \
src/external/bsd/dhcpcd/dist/src/dev/udev.c
cvs rdiff -u -r1.1.1.1.8.1 -r1.1.1.1.8.2 \
src/external/bsd/dhcpcd/dist/tests/eloop-bench/eloop-bench.c
cvs rdiff -u -r1.1.8.1 -r1.1.8.2 src/external/bsd/dhcpcd/include/config.h
cvs rdiff -u -r1.40.4.1 -r1.40.4.2 \
src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/dhcpcd/dist/configure
diff -u src/external/bsd/dhcpcd/dist/configure:1.1.1.3.2.1 src/external/bsd/dhcpcd/dist/configure:1.1.1.3.2.2
--- src/external/bsd/dhcpcd/dist/configure:1.1.1.3.2.1 Sat Jan 13 21:35:29 2018
+++ src/external/bsd/dhcpcd/dist/configure Mon Apr 9 16:46:34 2018
@@ -20,6 +20,7 @@ BUILD=
HOST=
HOSTCC=
TARGET=
+INCLUDEDIR=
DEBUG=
FORK=
STATIC=
@@ -71,6 +72,7 @@ for x do
--mandir) MANDIR=$var;;
--datadir) DATADIR=$var;;
--with-ccopts|CFLAGS) CFLAGS=$var;;
+ -I|--includedir) INCLUDEDIR="$INCLUDEDIR${INCLUDEDIR:+ }-I$var";;
CC) CC=$var;;
CPPFLAGS) CPPFLAGS=$var;;
PKG_CONFIG) PKG_CONFIG=$var;;
@@ -264,7 +266,7 @@ for x in SYSCONFDIR SBINDIR LIBDIR LIBEX
echo "$x=$t $v" >>$CONFIG_MK
unset t
[ $l -gt 2 ] && t=" "
- echo "#define $x$t \"$v\"" >>$CONFIG_H
+ echo "#define $x$t \"$v\"" >>$CONFIG_H
done
echo "LIBDIR= $LIBDIR" >>$CONFIG_MK
echo "MANDIR= $MANDIR" >>$CONFIG_MK
@@ -307,6 +309,9 @@ if [ -n "$CPPFLAGS" ]; then
echo "CPPFLAGS=" >>$CONFIG_MK
echo "CPPFLAGS+= $CPPFLAGS" >>$CONFIG_MK
fi
+if [ -n "$INCLUDEDIR" ]; then
+ echo "CPPFLAGS+= $INCLUDEDIR" >>$CONFIG_MK
+fi
if [ -n "$LDFLAGS" ]; then
echo "LDFLAGS=" >>$CONFIG_MK
echo "LDFLAGS+= $LDFLAGS" >>$CONFIG_MK
@@ -542,7 +547,7 @@ int main(void) {
EOF
if $XCC _nl80211.c -o _nl80211 2>&3; then
echo "yes"
- echo "#define HAVE_NL80211_H" >>$CONFIG_H
+ echo "#define HAVE_NL80211_H" >>$CONFIG_H
else
echo "no"
echo "DHCPCD_SRCS+= if-linux-wext.c" >>$CONFIG_MK
@@ -559,7 +564,7 @@ int main(void) {
EOF
if $XCC _IN6_ADDR_GEN_MODE_NONE.c -o _IN6_ADDR_GEN_MODE_NONE 2>&3; then
echo "yes"
- echo "#define HAVE_IN6_ADDR_GEN_MODE_NONE" >>$CONFIG_H
+ echo "#define HAVE_IN6_ADDR_GEN_MODE_NONE" >>$CONFIG_H
else
echo "no"
fi
@@ -575,7 +580,7 @@ int main(void) {
EOF
if $XCC _ifam_pid.c -o _ifam_pid 2>&3; then
echo "yes"
- echo "#define HAVE_IFAM_PID" >>$CONFIG_H
+ echo "#define HAVE_IFAM_PID" >>$CONFIG_H
else
echo "no"
fi
@@ -591,7 +596,7 @@ int main(void) {
EOF
if $XCC _ifam_addrflags.c -o _ifam_addrflags 2>&3; then
echo "yes"
- echo "#define HAVE_IFAM_ADDRFLAGS" >>$CONFIG_H
+ echo "#define HAVE_IFAM_ADDRFLAGS" >>$CONFIG_H
else
echo "no"
fi
@@ -636,7 +641,7 @@ int main(void) {
EOF
if $XCC _getifaddrs_addrflags.c -o _getifaddrs_addrflags $LIBSOCKET 2>&3; then
echo "yes"
- echo "#define HAVE_IFADDRS_ADDRFLAGS" >>$CONFIG_H
+ echo "#define HAVE_IFADDRS_ADDRFLAGS" >>$CONFIG_H
else
echo "no"
fi
@@ -788,12 +793,33 @@ if [ "$PIDFILE_LOCK" = no ]; then
echo "COMPAT_SRCS+= compat/pidfile.c" >>$CONFIG_MK
echo "#include \"compat/pidfile.h\"" >>$CONFIG_H
else
- echo "#define HAVE_UTIL_H" >>$CONFIG_H
+ echo "#define HAVE_UTIL_H" >>$CONFIG_H
if [ -n "$LIBUTIL" ]; then
echo "LDADD+= $LIBUTIL" >>$CONFIG_MK
fi
fi
+if [ -z "$SETPROCTITLE" ]; then
+ printf "Testing for setproctitle ... "
+ cat << EOF >_setproctitle.c
+#include <stdlib.h>
+int main(void) {
+ setproctitle("foo");
+ return 0;
+}
+EOF
+ if $XCC _setproctitle.c -o _setproctitle 2>&3; then
+ SETPROCTITLE=yes
+ else
+ SETPROCTITLE=no
+ fi
+ echo "$SETPROCTITLE"
+ rm -f _setproctitle.c _setproctitle
+fi
+if [ "$SETPROCTITLE" = yes ]; then
+ echo "#define HAVE_SETPROCTITLE" >>$CONFIG_H
+fi
+
if [ -z "$STRTOI" ]; then
printf "Testing for strtoi ... "
cat <<EOF >_strtoi.c
@@ -913,7 +939,7 @@ if [ "$TAILQ_FOREACH_SAFE" = no -o "$TAI
fi
echo "#include \"compat/queue.h\"">>$CONFIG_H
else
- echo "#define HAVE_SYS_QUEUE_H" >>$CONFIG_H
+ echo "#define HAVE_SYS_QUEUE_H" >>$CONFIG_H
fi
if [ -z "$REALLOCARRAY" ]; then
@@ -939,7 +965,7 @@ if [ "$REALLOCARRAY" = no ]; then
echo "#include \"compat/reallocarray.h\"">>$CONFIG_H
fi
# Set this for eloop
-echo "#define HAVE_REALLOCARRAY" >>$CONFIG_H
+echo "#define HAVE_REALLOCARRAY" >>$CONFIG_H
if [ -z "$POLL" ]; then
printf "Testing for kqueue1 ... "
@@ -995,7 +1021,7 @@ int main(void) {
EOF
if $XCC _epoll.c -o _epoll 2>&3; then
POLL=epoll
- echo "#define HAVE_EPOLL" >>$CONFIG_MK
+ echo "#define HAVE_EPOLL" >>$CONFIG_MK
echo "yes"
else
echo "no"
@@ -1022,23 +1048,23 @@ EOF
fi
case "$POLL" in
kqueue1)
- echo "#define HAVE_KQUEUE" >>$CONFIG_H
- echo "#define HAVE_KQUEUE1" >>$CONFIG_H
+ echo "#define HAVE_KQUEUE" >>$CONFIG_H
+ echo "#define HAVE_KQUEUE1" >>$CONFIG_H
;;
kqueue)
- echo "#define HAVE_KQUEUE" >>$CONFIG_H
+ echo "#define HAVE_KQUEUE" >>$CONFIG_H
;;
epoll)
- echo "#define HAVE_EPOLL" >>$CONFIG_H
+ echo "#define HAVE_EPOLL" >>$CONFIG_H
;;
pollts)
- echo "#define HAVE_POLLTS" >>$CONFIG_H
+ echo "#define HAVE_POLLTS" >>$CONFIG_H
;;
ppoll)
- echo "#define HAVE_PPOLL" >>$CONFIG_H
+ echo "#define HAVE_PPOLL" >>$CONFIG_H
;;
pselect)
- echo "#define HAVE_PSELECT" >>$CONFIG_H
+ echo "#define HAVE_PSELECT" >>$CONFIG_H
;;
*)
echo "No suitable polling function is available, not even pselect" >&2
@@ -1085,7 +1111,7 @@ EOF
rm -f _fls64.c _fls64
fi
if [ "$FLS64" = yes ]; then
- echo "#define HAVE_SYS_BITOPS_H" >>$CONFIG_H
+ echo "#define HAVE_SYS_BITOPS_H" >>$CONFIG_H
fi
if [ -z "$MD5" ]; then
@@ -1123,7 +1149,7 @@ if [ "$MD5" = no ]; then
echo "MD5_SRC= compat/crypt/md5.c" >>$CONFIG_MK
else
echo "MD5_SRC=" >>$CONFIG_MK
- echo "#define HAVE_MD5_H" >>$CONFIG_H
+ echo "#define HAVE_MD5_H" >>$CONFIG_H
[ -n "$MD5_LIB" ] && echo "LDADD+= $MD5_LIB" >>$CONFIG_MK
fi
@@ -1214,12 +1240,12 @@ if [ "$SHA2" = no ]; then
echo "SHA256_SRC= compat/crypt/sha256.c" >>$CONFIG_MK
else
echo "SHA256_SRC=" >>$CONFIG_MK
- echo "#define SHA2_H <$SHA2_H>" >>$CONFIG_H
+ echo "#define SHA2_H <$SHA2_H>" >>$CONFIG_H
if [ "$SHA2_RENAMED" = yes ]; then
- echo "#define SHA256_CTX SHA2_CTX" >>$CONFIG_H
- echo "#define SHA256_Init SHA256Init" >>$CONFIG_H
- echo "#define SHA256_Update SHA256Update" >>$CONFIG_H
- echo "#define SHA256_Final SHA256Final" >>$CONFIG_H
+ echo "#define SHA256_CTX SHA2_CTX" >>$CONFIG_H
+ echo "#define SHA256_Init SHA256Init" >>$CONFIG_H
+ echo "#define SHA256_Update SHA256Update" >>$CONFIG_H
+ echo "#define SHA256_Final SHA256Final" >>$CONFIG_H
fi
[ -n "$SHA2_LIB" ] && echo "LDADD+= $SHA2_LIB" >>$CONFIG_MK
fi
@@ -1237,7 +1263,7 @@ int main(void) {
EOF
if $XCC _hmac.c $MD5_LIB -o _hmac 2>&3; then
HMAC=yes
- echo "#define HAVE_HMAC_H" >>$CONFIG_H
+ echo "#define HAVE_HMAC_H" >>$CONFIG_H
else
# Remove this test if NetBSD-8 ships with
# hmac in it's own header and not stdlib.h
@@ -1259,9 +1285,9 @@ EOF
fi
if [ "$HMAC" = no ]; then
echo "#include \"compat/crypt/hmac.h\"" >>$CONFIG_H
- echo "HMAC_SRC= compat/crypt/hmac.c" >>$CONFIG_MK
+ echo "HMAC_SRC= compat/crypt/hmac.c" >>$CONFIG_MK
else
- # echo "#define HAVE_HMAC_H" >>$CONFIG_H
+ # echo "#define HAVE_HMAC_H" >>$CONFIG_H
echo "HMAC_SRC=" >>$CONFIG_MK
fi
@@ -1325,6 +1351,9 @@ if [ "$DEV" = yes ]; then
echo "CPPFLAGS+= -DPLUGIN_DEV" >>$CONFIG_MK
echo "MKDIRS+= dev" >>$CONFIG_MK
+ # So the plugins have access to logerr
+ echo "LDFLAGS+= -Wl,-export-dynamic" >>$CONFIG_MK
+
printf "Testing for dlopen ... "
cat <<EOF >_dlopen.c
#include <dlfcn.h>
Index: src/external/bsd/dhcpcd/dist/hooks/10-wpa_supplicant
diff -u src/external/bsd/dhcpcd/dist/hooks/10-wpa_supplicant:1.1.1.1 src/external/bsd/dhcpcd/dist/hooks/10-wpa_supplicant:1.1.1.1.8.1
--- src/external/bsd/dhcpcd/dist/hooks/10-wpa_supplicant:1.1.1.1 Fri Mar 31 20:51:16 2017
+++ src/external/bsd/dhcpcd/dist/hooks/10-wpa_supplicant Mon Apr 9 16:46:34 2018
@@ -20,8 +20,6 @@ fi
wpa_supplicant_ctrldir()
{
- local dir
-
dir=$(key_get_value "[[:space:]]*ctrl_interface=" \
"$wpa_supplicant_conf")
dir=$(trim "$dir")
@@ -37,8 +35,6 @@ wpa_supplicant_ctrldir()
wpa_supplicant_start()
{
- local dir err errn
-
# If the carrier is up, don't bother checking anything
[ "$ifcarrier" = "up" ] && return 0
@@ -72,8 +68,6 @@ wpa_supplicant_start()
wpa_supplicant_reconfigure()
{
- local dir err errn
-
dir=$(wpa_supplicant_ctrldir)
[ -z "$dir" ] && return 1
if ! wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1; then
@@ -92,8 +86,6 @@ wpa_supplicant_reconfigure()
wpa_supplicant_stop()
{
- local dir err errn
-
dir=$(wpa_supplicant_ctrldir)
[ -z "$dir" ] && return 1
wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1 || return 0
Index: src/external/bsd/dhcpcd/dist/hooks/15-timezone
diff -u src/external/bsd/dhcpcd/dist/hooks/15-timezone:1.1.1.1 src/external/bsd/dhcpcd/dist/hooks/15-timezone:1.1.1.1.8.1
--- src/external/bsd/dhcpcd/dist/hooks/15-timezone:1.1.1.1 Fri Mar 31 20:51:16 2017
+++ src/external/bsd/dhcpcd/dist/hooks/15-timezone Mon Apr 9 16:46:34 2018
@@ -4,10 +4,9 @@
set_zoneinfo()
{
- local zoneinfo_dir= zone_file=
-
[ -z "$new_tzdb_timezone" ] && return 0
+ zoneinfo_dir=
for d in \
/usr/share/zoneinfo \
/usr/lib/zoneinfo \
Index: src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf
diff -u src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.1.1.1 src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.1.1.1.8.1
--- src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.1.1.1 Fri Mar 31 20:51:16 2017
+++ src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf Mon Apr 9 16:46:34 2018
@@ -13,8 +13,7 @@ NL="
build_resolv_conf()
{
- local cf="$state_dir/resolv.conf.$ifname"
- local interfaces= header= search= srvs= servers= x=
+ cf="$state_dir/resolv.conf.$ifname"
# Build a list of interfaces
interfaces=$(list_interfaces "$resolv_conf_dir")
@@ -77,7 +76,6 @@ build_resolv_conf()
# regarding DNS option lifetime in ND messages.
eval_nd_dns()
{
-
eval ltime=\$nd${i}_rdnss${j}_lifetime
if [ -z "$ltime" -o "$ltime" = 0 ]; then
rdnss=
@@ -101,8 +99,8 @@ eval_nd_dns()
add_resolv_conf()
{
- local x= conf="$signature$NL" warn=true
- local i j ltime rdnss dnssl new_rdnss new_dnssl
+ conf="$signature$NL"
+ warn=true
# Loop to extract the ND DNS options using our indexed shell values
i=1
Index: src/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname
diff -u src/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname:1.1.1.1 src/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname:1.1.1.1.8.1
--- src/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname:1.1.1.1 Fri Mar 31 20:51:16 2017
+++ src/external/bsd/dhcpcd/dist/hooks/29-lookup-hostname Mon Apr 9 16:46:34 2018
@@ -3,7 +3,6 @@
lookup_hostname()
{
[ -z "$new_ip_address" ] && return 1
- local h=
# Silly ISC programs love to send error text to stdout
if type dig >/dev/null 2>&1; then
h=$(dig +short -x $new_ip_address)
Index: src/external/bsd/dhcpcd/dist/hooks/30-hostname
diff -u src/external/bsd/dhcpcd/dist/hooks/30-hostname:1.1.1.1 src/external/bsd/dhcpcd/dist/hooks/30-hostname:1.1.1.1.8.1
--- src/external/bsd/dhcpcd/dist/hooks/30-hostname:1.1.1.1 Fri Mar 31 20:51:16 2017
+++ src/external/bsd/dhcpcd/dist/hooks/30-hostname Mon Apr 9 16:46:34 2018
@@ -22,8 +22,6 @@
# Some systems don't have hostname(1)
_hostname()
{
- local name=
-
if [ -z "${1+x}" ]; then
if type hostname >/dev/null 2>&1; then
hostname
@@ -55,10 +53,19 @@ _hostname()
fi
}
-need_hostname()
+set_hostname_vars()
{
- local hfqdn=false hshort=false
+ 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
@@ -70,11 +77,7 @@ need_hostname()
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) return 0;;
esac
- case "$hostname_fqdn" in
- [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) hfqdn=true;;
- ""|[Ss][Ee][Rr][Vv][Ee][Rr]) ;;
- *) hshort=true;;
- esac
+ set_hostname_vars
if [ -n "$old_fqdn" ]; then
if ${hfqdn} || ! ${hsort}; then
@@ -105,7 +108,6 @@ need_hostname()
try_hostname()
{
-
[ "$hostname" = "$1" ] && return 0
if valid_domainname "$1"; then
syslog info "Setting hostname: $1"
@@ -117,15 +119,9 @@ try_hostname()
set_hostname()
{
- local hfqdn=false hshort=false
-
need_hostname || return
- case "$hostname_fqdn" in
- [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) hfqdn=true;;
- ""|[Ss][Ee][Rr][Vv][Ee][Rr]) ;;
- *) hshort=true;;
- esac
+ set_hostname_vars
if [ -n "$new_fqdn" ]; then
if ${hfqdn} || ! ${hshort}; then
Index: src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf
diff -u src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf:1.1.1.1 src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf:1.1.1.1.8.1
--- src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf:1.1.1.1 Fri Mar 31 20:51:16 2017
+++ src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf Mon Apr 9 16:46:34 2018
@@ -57,12 +57,12 @@ NL="
build_ntp_conf()
{
- local cf="$state_dir/ntp.conf.$ifname"
- local interfaces= header= srvs= servers= x=
+ cf="$state_dir/ntp.conf.$ifname"
# Build a list of interfaces
interfaces=$(list_interfaces "$ntp_conf_dir")
+ servers=
if [ -n "$interfaces" ]; then
# Build the header
for x in ${interfaces}; do
@@ -107,7 +107,7 @@ build_ntp_conf()
add_ntp_conf()
{
- local cf="$ntp_conf_dir/$ifname" x=
+ cf="$ntp_conf_dir/$ifname"
[ -e "$cf" ] && rm "$cf"
[ -d "$ntp_conf_dir" ] || mkdir -p "$ntp_conf_dir"
Index: src/external/bsd/dhcpcd/dist/hooks/50-yp.conf
diff -u src/external/bsd/dhcpcd/dist/hooks/50-yp.conf:1.1.1.1 src/external/bsd/dhcpcd/dist/hooks/50-yp.conf:1.1.1.1.8.1
--- src/external/bsd/dhcpcd/dist/hooks/50-yp.conf:1.1.1.1 Fri Mar 31 20:51:16 2017
+++ src/external/bsd/dhcpcd/dist/hooks/50-yp.conf Mon Apr 9 16:46:34 2018
@@ -9,9 +9,10 @@ ypbind_pid()
make_yp_conf()
{
[ -z "$new_nis_domain" -a -z "$new_nis_servers" ] && return 0
- local cf=/etc/yp.conf."$ifname" prefix= x= pid=
+ cf=/etc/yp.conf."$ifname"
rm -f "$cf"
echo "$signature" > "$cf"
+ prefix=
if [ -n "$new_nis_domain" ]; then
if ! valid_domainname "$new_nis_domain"; then
syslog err "Invalid NIS domain name: $new_nis_domain"
@@ -43,7 +44,7 @@ restore_yp_conf()
{
[ -n "$old_nis_domain" ] && domainname ""
restore_conf /etc/yp.conf || return 0
- local pid="$(ypbind_pid)"
+ pid="$(ypbind_pid)"
if [ -n "$pid" ]; then
kill -HUP "$pid"
fi
Index: src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in
diff -u src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in:1.1.1.1 src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in:1.1.1.1.8.1
--- src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in:1.1.1.1 Fri Mar 31 20:51:16 2017
+++ src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in Mon Apr 9 16:46:34 2018
@@ -10,8 +10,6 @@ ypbind_dir="$state_dir/ypbind"
best_domain()
{
- local i=
-
for i in "$ypbind_dir/$interface_order".*; do
if [ -f "$i" ]; then
cat "$i"
@@ -29,9 +27,9 @@ make_yp_binding()
if [ -z "$ypdomain_dir" ]; then
false
else
- local cf="$ypdomain_dir/$new_nis_domain$ypdomain_suffix"
+ cf="$ypdomain_dir/$new_nis_domain$ypdomain_suffix"
if [ -n "$new_nis_servers" ]; then
- local ncf="$cf.$ifname" x=
+ ncf="$cf.$ifname"
rm -f "$ncf"
for x in $new_nis_servers; do
echo "$x" >>"$ncf"
@@ -42,7 +40,7 @@ make_yp_binding()
fi
fi
- local nd="$(best_domain)"
+ nd="$(best_domain)"
if [ $? = 0 -a "$nd" != "$(domainname)" ]; then
domainname "$nd"
if [ -n "$ypbind_restart_cmd" ]; then
@@ -53,9 +51,8 @@ make_yp_binding()
restore_yp_binding()
{
-
rm -f "$ypbind_dir/$ifname"
- local nd="$(best_domain)"
+ nd="$(best_domain)"
# We need to stop ypbind if there is no best domain
# otherwise it will just stall as we cannot set domainname
# to blank :/
Index: src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in
diff -u src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in:1.1.1.1.8.1 src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in:1.1.1.1.8.2
--- src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in:1.1.1.1.8.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in Mon Apr 9 16:46:34 2018
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd November 3, 2017
+.Dd February 20, 2018
.Dt DHCPCD-RUN-HOOKS 8
.Os
.Sh NAME
@@ -47,6 +47,19 @@ ntp or ypbind.
A test hook is also supplied that simply echos the dhcp variables to the
console from DISCOVER message.
.Pp
+The hooks scripts are loaded into the current shell rather than executed
+in their own process.
+This allows each hook script, such as
+.Pa @SYSCONFDIR@/dhcpcd.enter-hook
+to customise environment variables or provide alternative functions to hooks
+further down the chain.
+As such, using the shell builtins
+.Ic exit ,
+.Ic exec
+or similar will cause
+.Nm
+to exit at that point.
+.Pp
Each time
.Nm
is invoked,
Index: src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in
diff -u src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.1.1.1.8.1 src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.1.1.1.8.2
--- src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.1.1.1.8.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in Mon Apr 9 16:46:34 2018
@@ -18,7 +18,7 @@ _detected_init=false
# Ensure that all arguments are unique
uniqify()
{
- local result= i=
+ result=
for i do
case " $result " in
*" $i "*);;
@@ -34,7 +34,7 @@ uniqify()
# Otherwise we just use what we have.
list_interfaces()
{
- local i= x= ifaces=
+ ifaces=
for i in $interface_order; do
for x in "$1"/$i.*; do
[ -f "$x" ] && ifaces="$ifaces${ifaces:+ }${x##*/}"
@@ -49,8 +49,7 @@ list_interfaces()
# Trim function
trim()
{
- local var="$*"
-
+ var="$*"
var=${var#"${var%%[![:space:]]*}"}
var=${var%"${var##*[![:space:]]}"}
if [ -z "$var" ]; then
@@ -65,9 +64,9 @@ trim()
# but sed may not always be available at the time.
key_get_value()
{
- local key="$1" value= x= line=
-
+ key="$1"
shift
+
if type sed >/dev/null 2>&1; then
sed -n "s/^$key//p" $@
else
@@ -85,7 +84,9 @@ key_get_value()
# but sed may not always be available at the time.
remove_markers()
{
- local m1="$1" m2="$2" x= line= in_marker=0
+ m1="$1"
+ m2="$2"
+ in_marker=0
shift; shift
if type sed >/dev/null 2>&1; then
@@ -106,7 +107,6 @@ remove_markers()
# Compare two files.
comp_file()
{
-
[ -e "$1" -a -e "$2" ] || return 1
if type cmp >/dev/null 2>&1; then
@@ -123,7 +123,6 @@ comp_file()
# If different, replace first with second otherwise remove second.
change_file()
{
-
if [ -e "$1" ]; then
if comp_file "$1" "$2"; then
rm -f "$2"
@@ -139,7 +138,6 @@ change_file()
# If different, copy or link depending on target type
copy_file()
{
-
if [ -h "$2" ]; then
[ "$(readlink "$2")" = "$1" ] && return 1
ln -sf "$1" "$2"
@@ -152,7 +150,6 @@ copy_file()
# Save a config file
save_conf()
{
-
if [ -f "$1" ]; then
rm -f "$1-pre.$interface"
cat "$1" > "$1-pre.$interface"
@@ -162,7 +159,6 @@ save_conf()
# Restore a config file
restore_conf()
{
-
[ -f "$1-pre.$interface" ] || return 1
cat "$1-pre.$interface" > "$1"
rm -f "$1-pre.$interface"
@@ -171,7 +167,7 @@ restore_conf()
# Write a syslog entry
syslog()
{
- local lvl="$1"
+ lvl="$1"
if [ "$lvl" = debug ]; then
${syslog_debug} || return 0
@@ -190,8 +186,7 @@ syslog()
# Check for a valid name as per RFC952 and RFC1123 section 2.1
valid_domainname()
{
- local name="$1" label
-
+ name="$1"
[ -z "$name" -o ${#name} -gt 255 ] && return 1
while [ -n "$name" ]; do
@@ -209,8 +204,6 @@ valid_domainname()
valid_domainname_list()
{
- local name
-
for name do
valid_domainname "$name" || return $?
done
@@ -228,7 +221,7 @@ detect_init()
[ -n "$_service_cmd" ] && return 0
- if ${_detected_init}; then
+ if $_detected_init; then
[ -n "$_service_cmd" ]
return $?
fi
@@ -236,7 +229,7 @@ detect_init()
# Detect the running init system.
# As systemd and OpenRC can be installed on top of legacy init
# systems we try to detect them first.
- local status="@STATUSARG@"
+ status="@STATUSARG@"
: ${status:=status}
if [ -x /bin/systemctl -a -S /run/systemd/private ]; then
_service_exists="/bin/systemctl --quiet is-enabled \$1.service"
@@ -297,7 +290,6 @@ detect_init()
# Check a system service exists
service_exists()
{
-
if [ -z "$_service_exists" ]; then
detect_init || return 1
fi
@@ -307,7 +299,6 @@ service_exists()
# Send a command to a system service
service_cmd()
{
-
if [ -z "$_service_cmd" ]; then
detect_init || return 1
fi
@@ -317,7 +308,6 @@ service_cmd()
# Send a command to a system service if it is running
service_status()
{
-
if [ -z "$_service_cmd" ]; then
detect_init || return 1
fi
@@ -331,12 +321,10 @@ service_status()
# Handy macros for our hooks
service_command()
{
-
service_exists $1 && service_cmd $1 $2
}
service_condcommand()
{
-
service_exists $1 && service_status $1 && service_cmd $1 $2
}
Index: src/external/bsd/dhcpcd/dist/src/arp.c
diff -u src/external/bsd/dhcpcd/dist/src/arp.c:1.1.1.2.8.1 src/external/bsd/dhcpcd/dist/src/arp.c:1.1.1.2.8.2
--- src/external/bsd/dhcpcd/dist/src/arp.c:1.1.1.2.8.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/arp.c Mon Apr 9 16:46:34 2018
@@ -561,28 +561,28 @@ arp_drop(struct interface *ifp)
void
arp_handleifa(int cmd, struct ipv4_addr *addr)
{
-#ifdef IN_IFF_DUPLICATED
struct iarp_state *state;
struct arp_state *astate, *asn;
- /* If the address is deleted, the ARP state should be freed by the
- * state owner, such as DHCP or IPv4LL. */
- if (cmd != RTM_NEWADDR || (state = ARP_STATE(addr->iface)) == NULL)
+ state = ARP_STATE(addr->iface);
+ if (state == NULL)
return;
TAILQ_FOREACH_SAFE(astate, &state->arp_states, next, asn) {
- if (astate->addr.s_addr == addr->addr.s_addr) {
- if (addr->addr_flags & IN_IFF_DUPLICATED) {
- if (astate->conflicted_cb)
- astate->conflicted_cb(astate, NULL);
- } else if (!(addr->addr_flags & IN_IFF_NOTUSEABLE)) {
- if (astate->probed_cb)
- astate->probed_cb(astate);
- }
+ if (astate->addr.s_addr != addr->addr.s_addr)
+ continue;
+ if (cmd == RTM_DELADDR)
+ arp_free(astate);
+#ifdef IN_IFF_DUPLICATED
+ if (cmd != RTM_NEWADDR)
+ continue;
+ if (addr->addr_flags & IN_IFF_DUPLICATED) {
+ if (astate->conflicted_cb)
+ astate->conflicted_cb(astate, NULL);
+ } else if (!(addr->addr_flags & IN_IFF_NOTUSEABLE)) {
+ if (astate->probed_cb)
+ astate->probed_cb(astate);
}
- }
-#else
- UNUSED(cmd);
- UNUSED(addr);
#endif
+ }
}
Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.1.1.2.8.1 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.1.1.2.8.2
--- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.1.1.2.8.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c Mon Apr 9 16:46:34 2018
@@ -377,25 +377,26 @@ static void
ipv6nd_reachable(struct ra *rap, int flags)
{
+ if (rap->lifetime == 0)
+ return;
+
if (flags & IPV6ND_REACHABLE) {
- if (rap->lifetime && rap->expired) {
- loginfox("%s: %s is reachable again",
- rap->iface->name, rap->sfrom);
- rap->expired = 0;
- rt_build(rap->iface->ctx, AF_INET6);
- /* XXX Not really an RA */
- script_runreason(rap->iface, "ROUTERADVERT");
- }
+ if (rap->expired == 0)
+ return;
+ loginfox("%s: %s is reachable again",
+ rap->iface->name, rap->sfrom);
+ rap->expired = 0;
} else {
- if (rap->lifetime && !rap->expired) {
- logwarnx("%s: %s is unreachable, expiring it",
- rap->iface->name, rap->sfrom);
- rap->expired = 1;
- rt_build(rap->iface->ctx, AF_INET6);
- /* XXX Not really an RA */
- script_runreason(rap->iface, "ROUTERADVERT");
- }
+ if (rap->expired != 0)
+ return;
+ logwarnx("%s: %s is unreachable, expiring it",
+ rap->iface->name, rap->sfrom);
+ rap->expired = 1;
}
+
+ rt_build(rap->iface->ctx, AF_INET6);
+ /* XXX Not really an RA */
+ script_runreason(rap->iface, "ROUTERADVERT");
}
void
@@ -869,7 +870,9 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx,
rap->expired = 0;
rap->hasdns = 0;
- ipv6_settempstale(ifp);
+#ifdef IPV6_AF_TEMPORARY
+ ipv6_markaddrsstale(ifp, IPV6_AF_TEMPORARY);
+#endif
TAILQ_FOREACH(ap, &rap->addrs, next) {
ap->flags |= IPV6_AF_STALE;
}
@@ -1291,7 +1294,7 @@ ipv6nd_env(char **env, const char *prefi
}
void
-ipv6nd_handleifa(int cmd, struct ipv6_addr *addr)
+ipv6nd_handleifa(int cmd, struct ipv6_addr *addr, pid_t pid)
{
struct ra *rap;
@@ -1303,7 +1306,7 @@ ipv6nd_handleifa(int cmd, struct ipv6_ad
TAILQ_FOREACH(rap, addr->iface->ctx->ra_routers, next) {
if (rap->iface != addr->iface)
continue;
- ipv6_handleifa_addrs(cmd, &rap->addrs, addr);
+ ipv6_handleifa_addrs(cmd, &rap->addrs, addr, pid);
}
}
@@ -1313,7 +1316,7 @@ ipv6nd_expirera(void *arg)
struct interface *ifp;
struct ra *rap, *ran;
struct timespec now, lt, expire, next;
- uint8_t expired, valid, validone;
+ uint8_t expired, anyvalid, valid, validone;
struct ipv6_addr *ia;
ifp = arg;
@@ -1321,11 +1324,11 @@ ipv6nd_expirera(void *arg)
expired = 0;
timespecclear(&next);
- validone = 0;
+ anyvalid = 0;
TAILQ_FOREACH_SAFE(rap, ifp->ctx->ra_routers, next, ran) {
if (rap->iface != ifp)
continue;
- valid = 0;
+ valid = validone = 0;
if (rap->lifetime) {
lt.tv_sec = (time_t)rap->lifetime;
lt.tv_nsec = 0;
@@ -1351,9 +1354,12 @@ ipv6nd_expirera(void *arg)
* the kernel can expire, so we need to handle it ourself.
* Also, some OS don't support address lifetimes (Solaris). */
TAILQ_FOREACH(ia, &rap->addrs, next) {
- if (ia->prefix_vltime == ND6_INFINITE_LIFETIME ||
- ia->prefix_vltime == 0)
+ if (ia->prefix_vltime == 0)
continue;
+ if (ia->prefix_vltime == ND6_INFINITE_LIFETIME) {
+ validone = 1;
+ continue;
+ }
lt.tv_sec = (time_t)ia->prefix_vltime;
lt.tv_nsec = 0;
timespecadd(&ia->acquired, <, &expire);
@@ -1375,6 +1381,7 @@ ipv6nd_expirera(void *arg)
if (!timespecisset(&next) ||
timespeccmp(&next, <, >))
next = lt;
+ validone = 1;
}
}
@@ -1385,10 +1392,10 @@ ipv6nd_expirera(void *arg)
/* No valid lifetimes are left on the RA, so we might
* as well punt it. */
- if (!valid && TAILQ_FIRST(&rap->addrs) == NULL)
+ if (!valid && !validone)
ipv6nd_free_ra(rap);
else
- validone = 1;
+ anyvalid = 1;
}
if (timespecisset(&next))
@@ -1400,7 +1407,7 @@ ipv6nd_expirera(void *arg)
}
/* No valid routers? Kill any DHCPv6. */
- if (!validone)
+ if (!anyvalid)
dhcp6_dropnondelegates(ifp);
}
@@ -1501,15 +1508,8 @@ ipv6nd_handlena(struct dhcpcd_ctx *ctx,
return;
}
- if (is_solicited && is_router && rap->lifetime) {
- if (rap->expired) {
- rap->expired = 0;
- loginfox("%s: %s reachable (%s)",
- ifp->name, taddr, ctx->sfrom);
- rt_build(ifp->ctx, AF_INET6);
- script_runreason(rap->iface, "ROUTERADVERT"); /* XXX */
- }
- }
+ if (is_solicited && is_router && rap->lifetime)
+ ipv6nd_reachable(rap, IPV6ND_REACHABLE);
}
static void
Index: src/external/bsd/dhcpcd/dist/src/common.h
diff -u src/external/bsd/dhcpcd/dist/src/common.h:1.1.1.1.8.1 src/external/bsd/dhcpcd/dist/src/common.h:1.1.1.1.8.2
--- src/external/bsd/dhcpcd/dist/src/common.h:1.1.1.1.8.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/common.h Mon Apr 9 16:46:34 2018
@@ -118,12 +118,6 @@
# ifndef __packed
# define __packed __attribute__((__packed__))
# endif
-# ifndef __sysloglike
-# ifndef __syslog_attribute_
-# define __syslog__ __printf__
-# endif
-# define __sysloglike(a, b) __attribute__((format(__syslog__, a, b)))
-# endif
# ifndef __unused
# define __unused __attribute__((__unused__))
# endif
@@ -131,9 +125,6 @@
# ifndef __packed
# define __packed
# endif
-# ifndef __sysloglike
-# define __sysloglike
-# endif
# ifndef __unused
# define __unused
# endif
@@ -150,7 +141,7 @@
# define __CTASSERT99(x, a, b) __CTASSERT0(x, __CONCAT(__ctassert,a), \
__CONCAT(_,b))
# endif
-# define __CTASSERT0(x, y, z) __CTASSERT1(x, y, z)
+# define __CTASSERT0(x, y, z) __CTASSERT1(x, y, z)
# define __CTASSERT1(x, y, z) typedef char y ## z[/*CONSTCOND*/(x) ? 1 : -1] __unused
#endif
Index: src/external/bsd/dhcpcd/dist/src/dhcp.h
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.h:1.1.1.1.8.1 src/external/bsd/dhcpcd/dist/src/dhcp.h:1.1.1.1.8.2
--- src/external/bsd/dhcpcd/dist/src/dhcp.h:1.1.1.1.8.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp.h Mon Apr 9 16:46:34 2018
@@ -254,7 +254,7 @@ int dhcp_get_routes(struct rt_head *, st
ssize_t dhcp_env(char **, const char *, const struct bootp *, size_t,
const struct interface *);
-void dhcp_handleifa(int, struct ipv4_addr *);
+void dhcp_handleifa(int, struct ipv4_addr *, pid_t pid);
void dhcp_drop(struct interface *, const char *);
void dhcp_start(struct interface *);
void dhcp_abort(struct interface *);
Index: src/external/bsd/dhcpcd/dist/src/dhcp6.h
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.h:1.1.1.1.8.1 src/external/bsd/dhcpcd/dist/src/dhcp6.h:1.1.1.1.8.2
--- src/external/bsd/dhcpcd/dist/src/dhcp6.h:1.1.1.1.8.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.h Mon Apr 9 16:46:34 2018
@@ -229,7 +229,7 @@ void dhcp6_renew(struct interface *);
ssize_t dhcp6_env(char **, const char *, const struct interface *,
const struct dhcp6_message *, size_t);
void dhcp6_free(struct interface *);
-void dhcp6_handleifa(int, struct ipv6_addr *);
+void dhcp6_handleifa(int, struct ipv6_addr *, pid_t);
int dhcp6_dadcompleted(const struct interface *);
void dhcp6_drop(struct interface *, const char *);
void dhcp6_dropnondelegates(struct interface *ifp);
Index: src/external/bsd/dhcpcd/dist/src/ipv4.h
diff -u src/external/bsd/dhcpcd/dist/src/ipv4.h:1.1.1.1.8.1 src/external/bsd/dhcpcd/dist/src/ipv4.h:1.1.1.1.8.2
--- src/external/bsd/dhcpcd/dist/src/ipv4.h:1.1.1.1.8.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/ipv4.h Mon Apr 9 16:46:34 2018
@@ -79,6 +79,7 @@ struct ipv4_addr {
struct in_addr brd;
struct interface *iface;
int addr_flags;
+ unsigned int flags;
char saddr[INET_ADDRSTRLEN + 3];
#ifdef ALIAS_ADDR
char alias[IF_NAMESIZE];
@@ -86,6 +87,8 @@ struct ipv4_addr {
};
TAILQ_HEAD(ipv4_addrhead, ipv4_addr);
+#define IPV4_AF_STALE (1U << 0)
+
#define IPV4_ADDR_EQ(a1, a2) ((a1) && (a1)->addr.s_addr == (a2)->addr.s_addr)
#define IPV4_MASK1_EQ(a1, a2) ((a1) && (a1)->mask.s_addr == (a2)->mask.s_addr)
#define IPV4_MASK_EQ(a1, a2) (IPV4_ADDR_EQ(a1, a2) && IPV4_MASK1_EQ(a1, a2))
@@ -129,9 +132,11 @@ struct ipv4_addr *ipv4_iffindlladdr(stru
struct ipv4_addr *ipv4_findaddr(struct dhcpcd_ctx *, const struct in_addr *);
struct ipv4_addr *ipv4_findmaskaddr(struct dhcpcd_ctx *,
const struct in_addr *);
+void ipv4_markaddrsstale(struct interface *);
+void ipv4_deletestaleaddrs(struct interface *);
void ipv4_handleifa(struct dhcpcd_ctx *, int, struct if_head *, const char *,
const struct in_addr *, const struct in_addr *, const struct in_addr *,
- int);
+ int, pid_t);
void ipv4_free(struct interface *);
#else
Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.h
diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.h:1.1.1.1.8.1 src/external/bsd/dhcpcd/dist/src/ipv6nd.h:1.1.1.1.8.2
--- src/external/bsd/dhcpcd/dist/src/ipv6nd.h:1.1.1.1.8.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/ipv6nd.h Mon Apr 9 16:46:34 2018
@@ -97,7 +97,7 @@ ssize_t ipv6nd_free(struct interface *);
void ipv6nd_expirera(void *arg);
int ipv6nd_hasra(const struct interface *);
int ipv6nd_hasradhcp(const struct interface *);
-void ipv6nd_handleifa(int, struct ipv6_addr *);
+void ipv6nd_handleifa(int, struct ipv6_addr *, pid_t);
int ipv6nd_dadcompleted(const struct interface *);
void ipv6nd_expire(struct interface *, uint32_t);
void ipv6nd_drop(struct interface *);
Index: src/external/bsd/dhcpcd/dist/src/logerr.h
diff -u src/external/bsd/dhcpcd/dist/src/logerr.h:1.1.1.1.8.1 src/external/bsd/dhcpcd/dist/src/logerr.h:1.1.1.1.8.2
--- src/external/bsd/dhcpcd/dist/src/logerr.h:1.1.1.1.8.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/logerr.h Mon Apr 9 16:46:34 2018
@@ -34,7 +34,7 @@
#if __GNUC__ > 2 || defined(__INTEL_COMPILER)
#define __printflike(a, b) __attribute__((format(printf, a, b)))
#else
-#define __printflike
+#define __printflike(a, b)
#endif
#endif /* !__printflike */
Index: src/external/bsd/dhcpcd/dist/src/route.h
diff -u src/external/bsd/dhcpcd/dist/src/route.h:1.1.1.1.8.1 src/external/bsd/dhcpcd/dist/src/route.h:1.1.1.1.8.2
--- src/external/bsd/dhcpcd/dist/src/route.h:1.1.1.1.8.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/route.h Mon Apr 9 16:46:34 2018
@@ -86,8 +86,11 @@ void rt_dispose(struct dhcpcd_ctx *);
struct rt * rt_find(struct rt_head *, const struct rt *);
void rt_free(struct rt *);
void rt_freeif(struct interface *);
+void rt_headclear0(struct dhcpcd_ctx *, struct rt_head *, int);
void rt_headclear(struct rt_head *, int);
void rt_headfreeif(struct rt_head *);
+struct rt * rt_new0(struct dhcpcd_ctx *);
+void rt_setif(struct rt *, struct interface *);
struct rt * rt_new(struct interface *);
void rt_recvrt(int, const struct rt *);
void rt_build(struct dhcpcd_ctx *, int);
Index: src/external/bsd/dhcpcd/dist/src/defs.h
diff -u src/external/bsd/dhcpcd/dist/src/defs.h:1.1.1.4.2.1 src/external/bsd/dhcpcd/dist/src/defs.h:1.1.1.4.2.2
--- src/external/bsd/dhcpcd/dist/src/defs.h:1.1.1.4.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/defs.h Mon Apr 9 16:46:34 2018
@@ -28,7 +28,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "7.0.0"
+#define VERSION "7.0.3"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.1.1.4.2.1 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.1.1.4.2.2
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.1.1.4.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c Mon Apr 9 16:46:34 2018
@@ -777,6 +777,15 @@ dhcp6_makemessage(struct interface *ifp)
return -1;
}
+ /* In non master mode we listen and send from fixed addresses.
+ * We should try and match an address we have to unicast to,
+ * but for now this is the safest policy. */
+ if (unicast != NULL && !(ifp->ctx->options & DHCPCD_MASTER)) {
+ logdebugx("%s: ignoring unicast option as not master",
+ ifp->name);
+ unicast = NULL;
+ }
+
#ifdef AUTH
auth_len = 0;
if (ifo->auth.options & DHCPCD_AUTH_SEND) {
@@ -1092,6 +1101,8 @@ dhcp6_sendmessage(struct interface *ifp,
uint8_t neg;
const char *broad_uni;
const struct in6_addr alldhcp = IN6ADDR_LINKLOCAL_ALLDHCP_INIT;
+ struct ipv6_addr *lla;
+ int s;
if (!callback && ifp->carrier == LINK_DOWN)
return 0;
@@ -1104,12 +1115,13 @@ dhcp6_sendmessage(struct interface *ifp,
#endif
state = D6_STATE(ifp);
+ lla = ipv6_linklocal(ifp);
/* We need to ensure we have sufficient scope to unicast the address */
/* XXX FIXME: We should check any added addresses we have like from
* a Router Advertisement */
if (IN6_IS_ADDR_UNSPECIFIED(&state->unicast) ||
(state->state == DH6S_REQUEST &&
- (!IN6_IS_ADDR_LINKLOCAL(&state->unicast) || !ipv6_linklocal(ifp))))
+ (!IN6_IS_ADDR_LINKLOCAL(&state->unicast) || lla == NULL)))
{
dst.sin6_addr = alldhcp;
broad_uni = "broadcasting";
@@ -1251,7 +1263,16 @@ logsend:
ctx->sndhdr.msg_controllen = 0;
}
- if (sendmsg(ctx->dhcp6_fd, &ctx->sndhdr, 0) == -1) {
+ if (ctx->dhcp6_fd != -1)
+ s = ctx->dhcp6_fd;
+ else if (lla != NULL && lla->dhcp6_fd != -1)
+ s = lla->dhcp6_fd;
+ else {
+ logerrx("%s: no socket to send from", ifp->name);
+ return -1;
+ }
+
+ if (sendmsg(s, &ctx->sndhdr, 0) == -1) {
logerr("%s: %s: sendmsg", __func__, ifp->name);
/* Allow DHCPv6 to continue .... the errors
* would be rate limited by the protocol.
@@ -1826,6 +1847,7 @@ dhcp6_checkstatusok(const struct interfa
{
uint8_t *opt;
uint16_t opt_len, code;
+ size_t mlen;
void * (*f)(void *, size_t, uint16_t, uint16_t *), *farg;
char buf[32], *sbuf;
const char *status;
@@ -1851,8 +1873,8 @@ dhcp6_checkstatusok(const struct interfa
/* Anything after the code is a message. */
opt += sizeof(code);
- opt_len = (uint16_t)(opt_len - sizeof(code));
- if (opt_len == 0) {
+ mlen = opt_len - sizeof(code);
+ if (mlen == 0) {
sbuf = NULL;
if (code < sizeof(dhcp6_statuses) / sizeof(char *))
status = dhcp6_statuses[code];
@@ -1861,12 +1883,12 @@ dhcp6_checkstatusok(const struct interfa
status = buf;
}
} else {
- if ((sbuf = malloc((size_t)opt_len + 1)) == NULL) {
+ if ((sbuf = malloc(mlen + 1)) == NULL) {
logerr(__func__);
return -1;
}
- memcpy(sbuf, opt, opt_len);
- sbuf[len] = '\0';
+ memcpy(sbuf, opt, mlen);
+ sbuf[mlen] = '\0';
status = sbuf;
}
@@ -3551,19 +3573,16 @@ dhcp6_listen(struct dhcpcd_ctx *ctx, str
if (ia != NULL) {
memcpy(&sa.sin6_addr, &ia->addr, sizeof(sa.sin6_addr));
sa.sin6_scope_id = ia->iface->index;
- } else if (!(ctx->options & DHCPCD_MASTER))
- /* This socket is only used for sending. */
- return s;
+ }
if (bind(s, (struct sockaddr *)&sa, sizeof(sa)) == -1)
goto errexit;
- if (ia == NULL) {
- n = 1;
- if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO,
- &n, sizeof(n)) == -1)
- goto errexit;
- } else {
+ n = 1;
+ if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &n, sizeof(n)) == -1)
+ goto errexit;
+
+ if (ia != NULL) {
ia->dhcp6_fd = s;
eloop_event_add(ctx->eloop, s, dhcp6_recvaddr, ia);
}
@@ -3577,18 +3596,6 @@ errexit:
return -1;
}
-static int
-dhcp6_open(struct dhcpcd_ctx *ctx)
-{
-
- /* Open an unbound socket to send from. */
- ctx->dhcp6_fd = dhcp6_listen(ctx, NULL);
- if (ctx->dhcp6_fd != -1 && (ctx->options & DHCPCD_MASTER))
- eloop_event_add(ctx->eloop, ctx->dhcp6_fd, dhcp6_recvctx, ctx);
-
- return ctx->dhcp6_fd;
-}
-
#ifndef SMALL
static void
dhcp6_activateinterfaces(struct interface *ifp)
@@ -3623,13 +3630,18 @@ static void
dhcp6_start1(void *arg)
{
struct interface *ifp = arg;
+ struct dhcpcd_ctx *ctx = ifp->ctx;
struct if_options *ifo = ifp->options;
struct dhcp6_state *state;
size_t i;
const struct dhcp_compat *dhc;
- if (ifp->ctx->dhcp6_fd == -1 && dhcp6_open(ifp->ctx) == -1)
- return;
+ if (ctx->dhcp6_fd == -1 && ctx->options & DHCPCD_MASTER) {
+ ctx->dhcp6_fd = dhcp6_listen(ctx, NULL);
+ if (ctx->dhcp6_fd == -1)
+ return;
+ eloop_event_add(ctx->eloop, ctx->dhcp6_fd, dhcp6_recvctx, ctx);
+ }
state = D6_STATE(ifp);
/* If no DHCPv6 options are configured,
@@ -3858,22 +3870,20 @@ dhcp6_free(struct interface *ifp)
void
dhcp6_dropnondelegates(struct interface *ifp)
{
-#ifndef SMALL
- struct dhcp6_state *state;
- struct ipv6_addr *ia;
- if ((state = D6_STATE(ifp)) == NULL)
+#ifndef SMALL
+ if (dhcp6_hasprefixdelegation(ifp))
return;
- TAILQ_FOREACH(ia, &state->addrs, next) {
- if (ia->flags & (IPV6_AF_DELEGATED | IPV6_AF_DELEGATEDPFX))
- return;
- }
#endif
+ if (D6_CSTATE(ifp) == NULL)
+ return;
+
+ loginfox("%s: dropping DHCPv6 due to no valid routers", ifp->name);
dhcp6_drop(ifp, "EXPIRE6");
}
void
-dhcp6_handleifa(int cmd, struct ipv6_addr *ia)
+dhcp6_handleifa(int cmd, struct ipv6_addr *ia, pid_t pid)
{
struct dhcp6_state *state;
struct interface *ifp = ia->iface;
@@ -3888,7 +3898,7 @@ dhcp6_handleifa(int cmd, struct ipv6_add
dhcp6_listen(ia->iface->ctx, ia);
if ((state = D6_STATE(ifp)) != NULL)
- ipv6_handleifa_addrs(cmd, &state->addrs, ia);
+ ipv6_handleifa_addrs(cmd, &state->addrs, ia, pid);
}
ssize_t
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.1.1.4.2.1 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.1.1.4.2.2
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.1.1.4.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in Mon Apr 9 16:46:34 2018
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 7, 2017
+.Dd January 8, 2018
.Dt DHCPCD 8
.Os
.Sh NAME
@@ -47,7 +47,7 @@
.Op Fl Q , Fl Fl require Ar option
.Op Fl r , Fl Fl request Ar address
.Op Fl S , Fl Fl static Ar value
-.Op Fl s , Fl Fl inform Ar address Ns Op Ar /cidr
+.Op Fl s , Fl Fl inform Ar address Ns Op Ar /cidr Ns Op Ar /broadcast_address
.Op Fl Fl inform6
.Op Fl t , Fl Fl timeout Ar seconds
.Op Fl u , Fl Fl userclass Ar class
@@ -444,7 +444,7 @@ If no
is given then the first address currently assigned to the
.Ar interface
is used.
-.It Fl s , Fl Fl inform Ar address Ns Op Ar /cidr
+.It Fl s , Fl Fl inform Ar address Ns Op Ar /cidr Ns Op Ar /broadcast_address
Behaves like
.Fl r , Fl Fl request
as above, but sends a DHCP INFORM instead of DISCOVER/REQUEST.
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in:1.1.1.4.2.1 src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in:1.1.1.4.2.2
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in:1.1.1.4.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in Mon Apr 9 16:46:34 2018
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 9, 2017
+.Dd February 2, 2018
.Dt DHCPCD.CONF 5
.Os
.Sh NAME
@@ -225,7 +225,7 @@ If no
is given then the first address currently assigned to the
.Ar interface
is used.
-.It Ic inform Op Ar address Ns Op Ar /cidr
+.It Ic inform Op Ar address Ns Op Ar /cidr Ns Op Ar /broadcast_address
Behaves like
.Ic request
as above, but sends a DHCP INFORM instead of DISCOVER/REQUEST.
@@ -480,9 +480,9 @@ See
.%T "RFC 3927"
.Re
.It Ic noipv6
-Don't attempt to configure an IPv6 address.
+Don't solicit or accept IPv6 Router Advertisements and DHCPv6.
.It Ic noipv6rs
-Disable solicitation and receipt of IPv6 Router Advertisements.
+Don't solicit or accept IPv6 Router Advertisements.
.It Ic nolink
Don't receive link messages about carrier status.
You should only set this for buggy interface drivers.
@@ -602,8 +602,8 @@ If you set
.Nm dhcpcd
will continue auto-configuation as normal.
.Pp
-Here is an example which configures two static address, an IPv4 router, DNS
-and disables IPv6 auto-configuration.
+Here is an example which configures two static address, overriding the default
+IPv4 broadcast address, an IPv4 router, DNS and disables IPv6 auto-configuration.
You could also use the
.Ic inform6
command here if you wished to obtain more information via DHCPv6.
@@ -613,6 +613,7 @@ option instead of setting a static addre
.D1 interface eth0
.D1 noipv6rs
.D1 static ip_address=192.168.0.10/24
+.D1 static broadcast_address=192.168.0.63
.D1 static ip6_address=fd51:42f8:caae:d92e::ff/64
.D1 static routers=192.168.0.1
.D1 static domain_name_servers=192.168.0.1 fd51:42f8:caae:d92e::1
Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.1.1.3.8.2 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.1.1.3.8.3
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.1.1.3.8.2 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c Mon Apr 9 16:46:34 2018
@@ -1462,8 +1462,11 @@ get_lease(struct interface *ifp,
if (ifp->options->options & (DHCPCD_STATIC | DHCPCD_INFORM)) {
if (ifp->options->req_addr.s_addr != INADDR_ANY) {
lease->mask = ifp->options->req_mask;
- lease->brd.s_addr =
- lease->addr.s_addr | ~lease->mask.s_addr;
+ if (ifp->options->req_brd.s_addr != INADDR_ANY)
+ lease->brd = ifp->options->req_brd;
+ else
+ lease->brd.s_addr =
+ lease->addr.s_addr | ~lease->mask.s_addr;
} else {
const struct ipv4_addr *ia;
@@ -2076,7 +2079,7 @@ dhcp_arp_probed(struct arp_state *astate
logdebugx("%s: DAD completed for %s",
ifp->name, inet_ntoa(astate->addr));
- if (state->state != DHS_INFORM)
+ if (!(ifo->options & DHCPCD_INFORM))
dhcp_bind(ifp);
#ifndef IN_IFF_TENTATIVE
else {
@@ -3650,6 +3653,7 @@ dhcp_start1(void *arg)
state = D_STATE(ifp);
clock_gettime(CLOCK_MONOTONIC, &state->started);
+ state->interval = 0;
free(state->offer);
state->offer = NULL;
state->offer_len = 0;
@@ -3888,7 +3892,7 @@ dhcp_abort(struct interface *ifp)
}
void
-dhcp_handleifa(int cmd, struct ipv4_addr *ia)
+dhcp_handleifa(int cmd, struct ipv4_addr *ia, pid_t pid)
{
struct interface *ifp;
struct dhcp_state *state;
@@ -3902,12 +3906,13 @@ dhcp_handleifa(int cmd, struct ipv4_addr
if (cmd == RTM_DELADDR) {
if (state->addr == ia) {
- loginfox("%s: deleted IP address %s",
- ifp->name, ia->saddr);
+ loginfox("%s: pid %d deleted IP address %s",
+ ifp->name, pid, ia->saddr);
state->addr = NULL;
/* Don't clear the added state as we need
* to drop the lease. */
dhcp_drop(ifp, "EXPIRE");
+ dhcp_start1(ifp);
}
return;
}
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.4.2.1 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.4.2.2
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.4.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Mon Apr 9 16:46:34 2018
@@ -437,19 +437,15 @@ configure_interface1(struct interface *i
ifo->options &=
~(DHCPCD_IPV6RS | DHCPCD_DHCP6 | DHCPCD_WAITIP6);
- /* We want to disable kernel interface RA as early as possible. */
+ /* We want to setup INET6 on the interface as soon as possible. */
if (ifp->active == IF_ACTIVE_USER &&
- !(ifp->ctx->options & DHCPCD_DUMPLEASE))
+ ifo->options & DHCPCD_IPV6 &&
+ !(ifp->ctx->options & (DHCPCD_DUMPLEASE | DHCPCD_TEST)))
{
- int ra_global, ra_iface;
-
/* If not doing any DHCP, disable the RDNSS requirement. */
if (!(ifo->options & (DHCPCD_DHCP | DHCPCD_DHCP6)))
ifo->options &= ~DHCPCD_IPV6RA_REQRDNSS;
- ra_global = if_checkipv6(ifp->ctx, NULL);
- ra_iface = if_checkipv6(ifp->ctx, ifp);
- if (ra_global == -1 || ra_iface == -1)
- ifo->options &= ~DHCPCD_IPV6RS;
+ if_setup_inet6(ifp);
}
#endif
@@ -581,7 +577,7 @@ dhcpcd_selectprofile(struct interface *i
} else
*ifp->profile = '\0';
- free_options(ifp->options);
+ free_options(ifp->ctx, ifp->options);
ifp->options = ifo;
if (profile) {
add_options(ifp->ctx, ifp->name, ifp->options,
@@ -712,8 +708,10 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *
eloop_timeout_delete(ifp->ctx->eloop, dhcpcd_pollup, ifp);
if (carrier == LINK_UNKNOWN) {
- if (errno != ENOTTY) /* For example a PPP link on BSD */
+ if (errno != ENOTTY && errno != ENXIO) {
+ /* Don't log an error if interface departed */
logerr("%s: %s", ifp->name, __func__);
+ }
} else if (carrier == LINK_DOWN || (ifp->flags & IFF_UP) == 0) {
if (ifp->carrier != LINK_DOWN) {
if (ifp->carrier == LINK_UP)
@@ -957,29 +955,14 @@ dhcpcd_activateinterface(struct interfac
}
}
-static void
-dhcpcd_handlelink(void *arg)
-{
- struct dhcpcd_ctx *ctx;
-
- ctx = arg;
- if (if_handlelink(ctx) == -1) {
- logerr(__func__);
- eloop_event_delete(ctx->eloop, ctx->link_fd);
- close(ctx->link_fd);
- ctx->link_fd = -1;
- }
-}
-
int
dhcpcd_handleinterface(void *arg, int action, const char *ifname)
{
struct dhcpcd_ctx *ctx;
struct ifaddrs *ifaddrs;
struct if_head *ifs;
- struct interface *ifp, *iff, *ifn;
+ struct interface *ifp, *iff;
const char * const argv[] = { ifname };
- int i;
ctx = arg;
if (action == -1) {
@@ -998,60 +981,43 @@ dhcpcd_handleinterface(void *arg, int ac
return 0;
}
- i = -1;
ifs = if_discover(ctx, &ifaddrs, -1, UNCONST(argv));
if (ifs == NULL) {
logerr(__func__);
return -1;
}
- TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) {
- if (strcmp(ifp->name, ifname) != 0)
- continue;
-
- /* If running off an interface list, check it's in it. */
- if (ctx->ifc || ctx->options & DHCPCD_INACTIVE) {
- for (i = 0; i < ctx->ifc; i++)
- if (strcmp(ctx->ifv[i], ifname) == 0)
- break;
- if (i >= ctx->ifc) {
- ifp->active = IF_INACTIVE;
- ifp->carrier = LINK_UNKNOWN;
- }
- }
+ ifp = if_find(ifs, ifname);
+ if (ifp == NULL) {
+ /* This can happen if an interface is quickly added
+ * and then removed. */
+ errno = ENOENT;
+ return -1;
+ }
+ /* Check if we already have the interface */
+ iff = if_find(ctx->ifaces, ifp->name);
- i = 0;
- /* Check if we already have the interface */
- iff = if_find(ctx->ifaces, ifp->name);
- if (iff) {
- if (iff->active)
- logdebugx("%s: interface updated", iff->name);
- /* The flags and hwaddr could have changed */
- iff->flags = ifp->flags;
- iff->hwlen = ifp->hwlen;
- if (ifp->hwlen != 0)
- memcpy(iff->hwaddr, ifp->hwaddr, iff->hwlen);
- } else {
- TAILQ_REMOVE(ifs, ifp, next);
- TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next);
- if (!ifp->active)
- continue;
+ if (iff != NULL) {
+ if (iff->active)
+ logdebugx("%s: interface updated", iff->name);
+ /* The flags and hwaddr could have changed */
+ iff->flags = ifp->flags;
+ iff->hwlen = ifp->hwlen;
+ if (ifp->hwlen != 0)
+ memcpy(iff->hwaddr, ifp->hwaddr, iff->hwlen);
+ } else {
+ TAILQ_REMOVE(ifs, ifp, next);
+ TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next);
+ if (ifp->active) {
logdebugx("%s: interface added", ifp->name);
dhcpcd_initstate(ifp, 0);
run_preinit(ifp);
- iff = ifp;
}
- if (action > 0 && iff->active)
- dhcpcd_prestartinterface(iff);
+ iff = ifp;
}
- if_learnaddrs(ctx, ifs, &ifaddrs);
-
- /* Now we have learned addresses, start the interface */
- TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) {
- if (strcmp(ifp->name, ifname) != 0)
- continue;
- iff = if_find(ctx->ifaces, ifp->name);
- if (action > 0 && iff->active)
+ if (action > 0) {
+ if_learnaddrs(ctx, ifs, &ifaddrs);
+ if (iff->active)
dhcpcd_prestartinterface(iff);
}
@@ -1062,9 +1028,84 @@ dhcpcd_handleinterface(void *arg, int ac
}
free(ifs);
- if (i == -1)
- errno = ENOENT;
- return i;
+ return 1;
+}
+
+static void
+dhcpcd_handlelink(void *arg)
+{
+ struct dhcpcd_ctx *ctx = arg;
+
+ if (if_handlelink(ctx) == -1) {
+ if (errno == ENOBUFS || errno == ENOMEM) {
+ dhcpcd_linkoverflow(ctx);
+ return;
+ }
+ logerr(__func__);
+ }
+}
+
+static void
+dhcpcd_checkcarrier(void *arg)
+{
+ struct interface *ifp = arg;
+
+ dhcpcd_handlecarrier(ifp->ctx, LINK_UNKNOWN, ifp->flags, ifp->name);
+}
+
+void
+dhcpcd_linkoverflow(struct dhcpcd_ctx *ctx)
+{
+ struct if_head *ifaces;
+ struct ifaddrs *ifaddrs;
+ struct interface *ifp, *ifn, *ifp1;
+
+ logerrx("route socket overflowed - learning interface state");
+
+ /* Close the existing socket and open a new one.
+ * This is easier than draining the kernel buffer of an
+ * in-determinate size. */
+ eloop_event_delete(ctx->eloop, ctx->link_fd);
+ close(ctx->link_fd);
+ if_closesockets_os(ctx);
+ if (if_opensockets_os(ctx) == -1) {
+ logerr("%s: if_opensockets", __func__);
+ eloop_exit(ctx->eloop, EXIT_FAILURE);
+ return;
+ }
+ eloop_event_add(ctx->eloop, ctx->link_fd, dhcpcd_handlelink, ctx);
+
+ /* Work out the current interfaces. */
+ ifaces = if_discover(ctx, &ifaddrs, ctx->ifc, ctx->ifv);
+
+ /* Punt departed interfaces */
+ TAILQ_FOREACH_SAFE(ifp, ctx->ifaces, next, ifn) {
+ if (if_find(ifaces, ifp->name) != NULL)
+ continue;
+ dhcpcd_handleinterface(ctx, -1, ifp->name);
+ }
+
+ /* Add new interfaces */
+ TAILQ_FOREACH_SAFE(ifp, ifaces, next, ifn) {
+ ifp1 = if_find(ctx->ifaces, ifp->name);
+ if (ifp1 != NULL) {
+ /* If the interface already exists,
+ * check carrier state. */
+ eloop_timeout_add_sec(ctx->eloop, 0,
+ dhcpcd_checkcarrier, ifp1);
+ continue;
+ }
+ TAILQ_REMOVE(ifaces, ifp, next);
+ TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next);
+ if (ifp->active)
+ eloop_timeout_add_sec(ctx->eloop, 0,
+ dhcpcd_prestartinterface, ifp);
+ }
+
+ /* Update address state. */
+ if_markaddrsstale(ctx->ifaces);
+ if_learnaddrs(ctx, ctx->ifaces, &ifaddrs);
+ if_deletestaleaddrs(ctx->ifaces);
}
void
@@ -1124,7 +1165,7 @@ reload_config(struct dhcpcd_ctx *ctx)
if (ctx->options & DHCPCD_DAEMONISED)
ifo->options |= DHCPCD_DAEMONISED;
ctx->options = ifo->options;
- free_options(ifo);
+ free_options(ctx, ifo);
}
static void
@@ -1482,6 +1523,8 @@ main(int argc, char **argv)
#ifdef INET
ctx.udp_fd = -1;
#endif
+ rt_init(&ctx);
+
logopts = LOGERR_ERR|LOGERR_LOG|LOGERR_LOG_DATE|LOGERR_LOG_PID;
i = 0;
while ((opt = getopt_long(argc, argv,
@@ -1576,7 +1619,7 @@ main(int argc, char **argv)
if (i == 2) {
printf("Interface options:\n");
if (optind == argc - 1) {
- free_options(ifo);
+ free_options(&ctx, ifo);
ifo = read_config(&ctx, argv[optind], NULL, NULL);
if (ifo == NULL)
goto exit_failure;
@@ -1835,6 +1878,13 @@ printpidfile:
logdebugx(PACKAGE "-" VERSION " starting");
ctx.options |= DHCPCD_STARTED;
+#ifdef HAVE_SETPROCTITLE
+ setproctitle("%s%s%s",
+ ctx.options & DHCPCD_MASTER ? "[master]" : argv[optind],
+ ctx.options & DHCPCD_IPV4 ? " [ip4]" : "",
+ ctx.options & DHCPCD_IPV6 ? " [ip6]" : "");
+#endif
+
if (if_opensockets(&ctx) == -1) {
logerr("%s: if_opensockets", __func__);
goto exit_failure;
@@ -1880,13 +1930,11 @@ printpidfile:
} else
goto exit_failure;
if (!(ctx.options & DHCPCD_LINK)) {
- logerr("aborting as link detection is disabled");
+ logerrx("aborting as link detection is disabled");
goto exit_failure;
}
}
- rt_init(&ctx);
-
TAILQ_FOREACH(ifp, ctx.ifaces, next) {
if (ifp->active)
dhcpcd_initstate1(ifp, argc, argv, 0);
@@ -1937,7 +1985,7 @@ printpidfile:
handle_exit_timeout, &ctx);
}
}
- free_options(ifo);
+ free_options(&ctx, ifo);
ifo = NULL;
if_sortinterfaces(&ctx);
@@ -1974,6 +2022,7 @@ exit1:
}
free(ctx.ifaces);
}
+ free_options(&ctx, ifo);
rt_dispose(&ctx);
free(ctx.duid);
if (ctx.link_fd != -1) {
@@ -1981,7 +2030,6 @@ exit1:
close(ctx.link_fd);
}
if_closesockets(&ctx);
- free_options(ifo);
free_globals(&ctx);
ipv6_ctxfree(&ctx);
dev_stop(&ctx);
Index: src/external/bsd/dhcpcd/dist/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.4.2.1 src/external/bsd/dhcpcd/dist/src/if-options.c:1.4.2.2
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.4.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/if-options.c Mon Apr 9 16:46:34 2018
@@ -815,8 +815,21 @@ parse_option(struct dhcpcd_ctx *ctx, con
break;
case 's':
if (arg && *arg != '\0') {
- if (parse_addr(&ifo->req_addr, &ifo->req_mask, arg)
- != 0)
+ /* Strip out a broadcast address */
+ p = strchr(arg, '/');
+ if (p != NULL) {
+ p = strchr(p + 1, '/');
+ if (p != NULL)
+ *p = '\0';
+ }
+ i = parse_addr(&ifo->req_addr, &ifo->req_mask, arg);
+ if (p != NULL) {
+ /* Ensure the original string is preserved */
+ *p++ = '/';
+ if (i == 0)
+ i = parse_addr(&ifo->req_brd, NULL, p);
+ }
+ if (i != 0)
return -1;
} else {
ifo->req_addr.s_addr = 0;
@@ -1060,6 +1073,11 @@ parse_option(struct dhcpcd_ctx *ctx, con
{
if (parse_addr(&ifo->req_mask, NULL, p) != 0)
return -1;
+ } else if (strncmp(arg, "broadcast_address=",
+ strlen("broadcast_address=")) == 0)
+ {
+ if (parse_addr(&ifo->req_brd, NULL, p) != 0)
+ return -1;
} else if (strncmp(arg, "routes=", strlen("routes=")) == 0 ||
strncmp(arg, "static_routes=",
strlen("static_routes=")) == 0 ||
@@ -1068,14 +1086,8 @@ parse_option(struct dhcpcd_ctx *ctx, con
strncmp(arg, "ms_classless_static_routes=",
strlen("ms_classless_static_routes=")) == 0)
{
- struct interface *ifp;
struct in_addr addr3;
- ifp = if_find(ctx->ifaces, ifname);
- if (ifp == NULL) {
- logerrx("static routes require an interface");
- return -1;
- }
fp = np = strwhite(p);
if (np == NULL) {
logerrx("all routes need a gateway");
@@ -1089,7 +1101,7 @@ parse_option(struct dhcpcd_ctx *ctx, con
*fp = ' ';
return -1;
}
- if ((rt = rt_new(ifp)) == NULL) {
+ if ((rt = rt_new0(ctx)) == NULL) {
*fp = ' ';
return -1;
}
@@ -1099,16 +1111,9 @@ parse_option(struct dhcpcd_ctx *ctx, con
TAILQ_INSERT_TAIL(&ifo->routes, rt, rt_next);
*fp = ' ';
} else if (strncmp(arg, "routers=", strlen("routers=")) == 0) {
- struct interface *ifp;
-
- ifp = if_find(ctx->ifaces, ifname);
- if (ifp == NULL) {
- logerrx("static routes require an interface");
- return -1;
- }
if (parse_addr(&addr, NULL, p) == -1)
return -1;
- if ((rt = rt_new(ifp)) == NULL)
+ if ((rt = rt_new0(ctx)) == NULL)
return -1;
addr2.s_addr = INADDR_ANY;
sa_in_init(&rt->rt_dest, &addr2);
@@ -2349,7 +2354,7 @@ read_config(struct dhcpcd_ctx *ctx,
buf = malloc(buflen);
if (buf == NULL) {
logerr(__func__);
- free_options(ifo);
+ free_options(ctx, ifo);
return NULL;
}
ldop = edop = NULL;
@@ -2363,7 +2368,7 @@ read_config(struct dhcpcd_ctx *ctx,
if (nbuf == NULL) {
logerr(__func__);
free(buf);
- free_options(ifo);
+ free_options(ctx, ifo);
return NULL;
}
buf = nbuf;
@@ -2527,7 +2532,7 @@ read_config(struct dhcpcd_ctx *ctx,
free(buf);
if (profile && !have_profile) {
- free_options(ifo);
+ free_options(ctx, ifo);
errno = ENOENT;
return NULL;
}
@@ -2572,7 +2577,7 @@ add_options(struct dhcpcd_ctx *ctx, cons
}
void
-free_options(struct if_options *ifo)
+free_options(struct dhcpcd_ctx *ctx, struct if_options *ifo)
{
size_t i;
struct dhcp_opt *opt;
@@ -2594,7 +2599,7 @@ free_options(struct if_options *ifo)
free(ifo->config[i++]);
free(ifo->config);
}
- rt_headclear(&ifo->routes, AF_UNSPEC);
+ rt_headclear0(ctx, &ifo->routes, AF_UNSPEC);
free(ifo->script);
free(ifo->arping);
free(ifo->blacklist);
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.h
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.h:1.1.1.3.2.1 src/external/bsd/dhcpcd/dist/src/dhcpcd.h:1.1.1.3.2.2
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.h:1.1.1.3.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.h Mon Apr 9 16:46:34 2018
@@ -230,6 +230,7 @@ int dhcpcd_ifafwaiting(const struct inte
int dhcpcd_afwaiting(const struct dhcpcd_ctx *);
pid_t dhcpcd_daemonise(struct dhcpcd_ctx *);
+void dhcpcd_linkoverflow(struct dhcpcd_ctx *);
int dhcpcd_handleargs(struct dhcpcd_ctx *, struct fd_list *, int, char **);
void dhcpcd_handlecarrier(struct dhcpcd_ctx *, int, unsigned int, const char *);
int dhcpcd_handleinterface(void *, int, const char *);
Index: src/external/bsd/dhcpcd/dist/src/if-bsd.c
diff -u src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.1.1.3.2.1 src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.1.1.3.2.2
--- src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.1.1.3.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/if-bsd.c Mon Apr 9 16:46:34 2018
@@ -1040,6 +1040,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const str
struct interface *ifp;
const struct sockaddr *rti_info[RTAX_MAX];
int addrflags;
+ pid_t pid;
if ((ifp = if_findindex(ctx->ifaces, ifam->ifam_index)) == NULL)
return;
@@ -1068,6 +1069,9 @@ if_ifa(struct dhcpcd_ctx *ctx, const str
}
#endif
}
+ pid = ifam->ifam_pid;
+#else
+ pid = 0;
#endif
#ifdef HAVE_IFAM_ADDRFLAGS
@@ -1140,7 +1144,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const str
#endif
ipv4_handleifa(ctx, ifam->ifam_type, NULL, ifp->name,
- &addr, &mask, &bcast, addrflags);
+ &addr, &mask, &bcast, addrflags, pid);
break;
}
#endif
@@ -1171,7 +1175,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const str
#endif
ipv6_handleifa(ctx, ifam->ifam_type, NULL,
- ifp->name, &addr6, ipv6_prefixlen(&mask6), addrflags);
+ ifp->name, &addr6, ipv6_prefixlen(&mask6), addrflags, pid);
break;
}
#endif
@@ -1206,6 +1210,11 @@ if_dispatch(struct dhcpcd_ctx *ctx, cons
case RTM_NEWADDR:
if_ifa(ctx, (const void *)rtm);
break;
+#ifdef RTM_DESYNC
+ case RTM_DESYNC:
+ dhcpcd_linkoverflow(ctx);
+ break;
+#endif
}
}
@@ -1219,7 +1228,8 @@ if_handlelink(struct dhcpcd_ctx *ctx)
msg.msg_iov = ctx->iov;
msg.msg_iovlen = 1;
- if ((len = recvmsg_realloc(ctx->link_fd, &msg, 0)) == -1)
+ len = recvmsg_realloc(ctx->link_fd, &msg, 0);
+ if (len == -1)
return -1;
if (len != 0)
if_dispatch(ctx, ctx->iov[0].iov_base);
@@ -1248,7 +1258,8 @@ if_machinearch(char *str, size_t len)
}
#ifdef INET6
-#ifdef IPV6CTL_ACCEPT_RTADV
+#if (defined(IPV6CTL_ACCEPT_RTADV) && !defined(ND6_IFF_ACCEPT_RTADV)) || \
+ defined(IPV6CTL_USETEMPADDR) || defined(IPV6CTL_TEMPVLTIME)
#define get_inet6_sysctl(code) inet6_sysctl(code, 0, 0)
#define set_inet6_sysctl(code, val) inet6_sysctl(code, val, 1)
static int
@@ -1358,21 +1369,21 @@ set_ifxflags(int s, const struct interfa
#ifdef IFXF_NOINET6
flags &= ~IFXF_NOINET6;
#endif
- if (!(ifp->ctx->options & DHCPCD_TEST))
+ /*
+ * If not doing autoconf, don't disable the kernel from doing it.
+ * If we need to, we should have another option actively disable it.
+ */
+ if (ifp->options->options & DHCPCD_IPV6RS)
flags &= ~IFXF_AUTOCONF6;
if (ifr.ifr_flags == flags)
return 0;
- if (ifp->ctx->options & DHCPCD_TEST) {
- errno = EPERM;
- return -1;
- }
ifr.ifr_flags = flags;
return ioctl(s, SIOCSIFXFLAGS, (void *)&ifr);
}
#endif
/* OpenBSD removed ND6 flags entirely, so we need to check for their
- * existnance. */
+ * existance. */
#if defined(ND6_IFF_AUTO_LINKLOCAL) || \
defined(ND6_IFF_PERFORMNUD) || \
defined(ND6_IFF_ACCEPT_RTADV) || \
@@ -1381,147 +1392,107 @@ set_ifxflags(int s, const struct interfa
#define ND6_NDI_FLAGS
#endif
-int
-if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp)
+void
+if_setup_inet6(const struct interface *ifp)
{
struct priv *priv;
- int s, ra;
+ int s;
+#ifdef ND6_NDI_FLAGS
+ struct in6_ndireq nd;
+ int flags;
+#endif
- priv = (struct priv *)ctx->priv;
+ priv = (struct priv *)ifp->ctx->priv;
s = priv->pf_inet6_fd;
- if (ifp) {
#ifdef ND6_NDI_FLAGS
- struct in6_ndireq nd;
- int flags;
-
- memset(&nd, 0, sizeof(nd));
- strlcpy(nd.ifname, ifp->name, sizeof(nd.ifname));
- if (ioctl(s, SIOCGIFINFO_IN6, &nd) == -1)
- return -1;
- flags = (int)nd.ndi.flags;
+ memset(&nd, 0, sizeof(nd));
+ strlcpy(nd.ifname, ifp->name, sizeof(nd.ifname));
+ if (ioctl(s, SIOCGIFINFO_IN6, &nd) == -1)
+ logerr("%s: SIOCGIFINFO_FLAGS", ifp->name);
+ flags = (int)nd.ndi.flags;
#endif
#ifdef ND6_IFF_AUTO_LINKLOCAL
- if (!(ctx->options & DHCPCD_TEST) &&
- flags & ND6_IFF_AUTO_LINKLOCAL)
- {
- logdebugx("%s: disabling Kernel IPv6 auto "
- "link-local support",
- ifp->name);
- flags &= ~ND6_IFF_AUTO_LINKLOCAL;
- }
+ /* Unlike the kernel,
+ * dhcpcd make make a stable private address. */
+ flags &= ~ND6_IFF_AUTO_LINKLOCAL;
#endif
#ifdef ND6_IFF_PERFORMNUD
- if ((flags & ND6_IFF_PERFORMNUD) == 0) {
- /* NUD is kind of essential. */
- flags |= ND6_IFF_PERFORMNUD;
- }
+ /* NUD is kind of essential. */
+ flags |= ND6_IFF_PERFORMNUD;
+#endif
+
+#ifdef ND6_IFF_IFDISABLED
+ /* Ensure the interface is not disabled. */
+ flags &= ~ND6_IFF_IFDISABLED;
#endif
+ /*
+ * If not doing autoconf, don't disable the kernel from doing it.
+ * If we need to, we should have another option actively disable it.
+ */
#ifdef ND6_IFF_ACCEPT_RTADV
- if (!(ctx->options & DHCPCD_TEST) &&
- flags & ND6_IFF_ACCEPT_RTADV)
- {
- logdebugx("%s: disabling Kernel IPv6 RA support",
- ifp->name);
- flags &= ~ND6_IFF_ACCEPT_RTADV;
- }
+ if (ifp->options->options & DHCPCD_IPV6RS)
+ flags &= ~ND6_IFF_ACCEPT_RTADV;
#ifdef ND6_IFF_OVERRIDE_RTADV
- if (!(ctx->options & DHCPCD_TEST) &&
- flags & ND6_IFF_OVERRIDE_RTADV)
- flags &= ~ND6_IFF_OVERRIDE_RTADV;
+ if (ifp->options->options & DHCPCD_IPV6RS)
+ flags |= ND6_IFF_OVERRIDE_RTADV;
#endif
#endif
-#ifdef ND6_IFF_IFDISABLED
- flags &= ~ND6_IFF_IFDISABLED;
-#endif
-
#ifdef ND6_NDI_FLAGS
- if (nd.ndi.flags != (uint32_t)flags) {
- if (ctx->options & DHCPCD_TEST) {
- logwarnx("%s: interface not IPv6 enabled",
- ifp->name);
- return -1;
- }
- nd.ndi.flags = (uint32_t)flags;
- if (ioctl(s, SIOCSIFINFO_FLAGS, &nd) == -1) {
- logerr("%s: SIOCSIFINFO_FLAGS", ifp->name);
- return -1;
- }
- }
+ if (nd.ndi.flags != (uint32_t)flags) {
+ nd.ndi.flags = (uint32_t)flags;
+ if (ioctl(s, SIOCSIFINFO_FLAGS, &nd) == -1)
+ logerr("%s: SIOCSIFINFO_FLAGS", ifp->name);
+ }
#endif
- /* Enabling IPv6 by whatever means must be the
- * last action undertaken to ensure kernel RS and
- * LLADDR auto configuration are disabled where applicable. */
+ /* Enabling IPv6 by whatever means must be the
+ * last action undertaken to ensure kernel RS and
+ * LLADDR auto configuration are disabled where applicable. */
#ifdef SIOCIFAFATTACH
- if (af_attach(s, ifp, AF_INET6) == -1) {
- logerr("%s: af_attach", ifp->name);
- return -1;
- }
+ if (af_attach(s, ifp, AF_INET6) == -1)
+ logerr("%s: af_attach", ifp->name);
#endif
#ifdef SIOCGIFXFLAGS
- if (set_ifxflags(s, ifp) == -1) {
- logerr("%s: set_ifxflags", ifp->name);
- return -1;
- }
+ if (set_ifxflags(s, ifp) == -1)
+ logerr("%s: set_ifxflags", ifp->name);
#endif
-#ifdef ND6_IFF_ACCEPT_RTADV
-#ifdef ND6_IFF_OVERRIDE_RTADV
- switch (flags & (ND6_IFF_ACCEPT_RTADV|ND6_IFF_OVERRIDE_RTADV)) {
- case (ND6_IFF_ACCEPT_RTADV|ND6_IFF_OVERRIDE_RTADV):
- return 1;
- case ND6_IFF_ACCEPT_RTADV:
- return ctx->ra_global;
- default:
- return 0;
+#if defined(IPV6CTL_ACCEPT_RTADV) && !defined(ND6_IFF_ACCEPT_RTADV)
+ /* If we cannot control ra per interface, disable it globally. */
+ if (ifp->options->options & DHCPCD_IPV6RS) {
+ int ra = get_inet6_sysctl(IPV6CTL_ACCEPT_RTADV);
+
+ if (ra == -1) {
+ if (errno != ENOENT)
+ logerr("IPV6CTL_ACCEPT_RTADV");
+ else if (ra != 0)
+ if (set_inet6_sysctl(IPV6CTL_ACCEPT_RTADV, 0) == -1)
+ logerr("IPV6CTL_ACCEPT_RTADV");
}
-#else
- return flags & ND6_IFF_ACCEPT_RTADV ? 1 : 0;
-#endif
-#else
- return ctx->ra_global;
-#endif
}
-
-#ifdef IPV6CTL_ACCEPT_RTADV
- ra = get_inet6_sysctl(IPV6CTL_ACCEPT_RTADV);
- if (ra == -1)
- if (errno == ENOENT)
- ra = 0;
- else
- logerr("IPV6CTL_ACCEPT_RTADV");
- else if (ra != 0 && !(ctx->options & DHCPCD_TEST)) {
- logdebugx("disabling Kernel IPv6 RA support");
- if (set_inet6_sysctl(IPV6CTL_ACCEPT_RTADV, 0) == -1) {
- logerr("IPV6CTL_ACCEPT_RTADV");
- return ra;
- }
- ra = 0;
-#else
- ra = 0;
- if (!(ctx->options & DHCPCD_TEST)) {
#endif
-#if defined(IPV6CTL_ACCEPT_RTADV) || defined(ND6_IFF_ACCEPT_RTADV)
- /* Flush the kernel knowledge of advertised routers
- * and prefixes so the kernel does not expire prefixes
- * and default routes we are trying to own. */
- char dummy[IFNAMSIZ + 8];
- strlcpy(dummy, "lo0", sizeof(dummy));
- if (ioctl(s, SIOCSRTRFLUSH_IN6, (void *)&dummy) == -1)
+#if defined(IPV6CTL_ACCEPT_RTADV) || defined(ND6_IFF_ACCEPT_RTADV)
+ /* Flush the kernel knowledge of advertised routers
+ * and prefixes so the kernel does not expire prefixes
+ * and default routes we are trying to own. */
+ if (ifp->options->options & DHCPCD_IPV6RS) {
+ char ifname[IFNAMSIZ + 8];
+
+ strlcpy(ifname, ifp->name, sizeof(ifname));
+ if (ioctl(s, SIOCSRTRFLUSH_IN6, (void *)&ifname) == -1 &&
+ errno != ENOTSUP)
logwarn("SIOCSRTRFLUSH_IN6");
- if (ioctl(s, SIOCSPFXFLUSH_IN6, (void *)&dummy) == -1)
+ if (ioctl(s, SIOCSPFXFLUSH_IN6, (void *)&ifname) == -1 &&
+ errno != ENOTSUP)
logwarn("SIOCSPFXFLUSH_IN6");
-#endif
}
-
- ctx->ra_global = ra;
- return ra;
+#endif
}
#endif
Index: src/external/bsd/dhcpcd/dist/src/if-linux.c
diff -u src/external/bsd/dhcpcd/dist/src/if-linux.c:1.1.1.3.2.1 src/external/bsd/dhcpcd/dist/src/if-linux.c:1.1.1.3.2.2
--- src/external/bsd/dhcpcd/dist/src/if-linux.c:1.1.1.3.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/if-linux.c Mon Apr 9 16:46:34 2018
@@ -609,7 +609,7 @@ link_addr(struct dhcpcd_ctx *ctx, struct
rta = RTA_NEXT(rta, len);
}
ipv4_handleifa(ctx, nlm->nlmsg_type, NULL, ifp->name,
- &addr, &net, &brd, ifa->ifa_flags);
+ &addr, &net, &brd, ifa->ifa_flags, (pid_t)nlm->nlmsg_pid);
break;
#endif
#ifdef INET6
@@ -625,7 +625,8 @@ link_addr(struct dhcpcd_ctx *ctx, struct
rta = RTA_NEXT(rta, len);
}
ipv6_handleifa(ctx, nlm->nlmsg_type, NULL, ifp->name,
- &addr6, ifa->ifa_prefixlen, ifa->ifa_flags);
+ &addr6, ifa->ifa_prefixlen, ifa->ifa_flags,
+ (pid_t)nlm->nlmsg_pid);
break;
#endif
}
@@ -1680,36 +1681,31 @@ if_disable_autolinklocal(struct dhcpcd_c
static const char *prefix = "/proc/sys/net/ipv6/conf";
-int
-if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp)
+void
+if_setup_inet6(const struct interface *ifp)
{
- const char *ifname;
int ra;
char path[256];
- if (ifp == NULL)
- ifname = "all";
- else if (!(ctx->options & DHCPCD_TEST)) {
- if (if_disable_autolinklocal(ctx, ifp->index) == -1)
- logdebug("%s: if_disable_autolinklocal",
- ifp->name);
- }
- if (ifp)
- ifname = ifp->name;
+ /* The kernel cannot make stable private addresses. */
+ if (if_disable_autolinklocal(ifp->ctx, ifp->index) == -1)
+ logdebug("%s: if_disable_autolinklocal", ifp->name);
+
+ /*
+ * If not doing autoconf, don't disable the kernel from doing it.
+ * If we need to, we should have another option actively disable it.
+ */
+ if (!(ifp->options->options & DHCPCD_IPV6RS))
+ return;
- snprintf(path, sizeof(path), "%s/%s/autoconf", prefix, ifname);
+ snprintf(path, sizeof(path), "%s/%s/autoconf", prefix, ifp->name);
ra = check_proc_int(path);
- if (ra != 1) {
- if (ctx->options & DHCPCD_TEST)
- logwarnx("%s: IPv6 kernel autoconf disabled", ifname);
- } else if (ra != -1 && !(ctx->options & DHCPCD_TEST)) {
- if (write_path(path, "0") == -1) {
+ if (ra != 1 && ra != -1) {
+ if (write_path(path, "0") == -1)
logerr("%s: %s", __func__, path);
- return -1;
- }
}
- snprintf(path, sizeof(path), "%s/%s/accept_ra", prefix, ifname);
+ snprintf(path, sizeof(path), "%s/%s/accept_ra", prefix, ifp->name);
ra = check_proc_int(path);
if (ra == -1) {
logfunc_t *logfunc = errno == ENOENT? logdebug : logwarn;
@@ -1717,16 +1713,10 @@ if_checkipv6(struct dhcpcd_ctx *ctx, con
/* The sysctl probably doesn't exist, but this isn't an
* error as such so just log it and continue */
logfunc("%s", path);
- } else if (ra != 0 && !(ctx->options & DHCPCD_TEST)) {
- logdebugx("%s: disabling kernel IPv6 RA support", ifname);
- if (write_path(path, "0") == -1) {
+ } else if (ra != 0) {
+ if (write_path(path, "0") == -1)
logerr("%s: %s", __func__, path);
- return ra;
- }
- return 0;
}
-
- return ra;
}
#ifdef IPV6_MANAGETEMPADDR
Index: src/external/bsd/dhcpcd/dist/src/if-options.h
diff -u src/external/bsd/dhcpcd/dist/src/if-options.h:1.1.1.3.2.1 src/external/bsd/dhcpcd/dist/src/if-options.h:1.1.1.3.2.2
--- src/external/bsd/dhcpcd/dist/src/if-options.h:1.1.1.3.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/if-options.h Mon Apr 9 16:46:34 2018
@@ -180,6 +180,7 @@ struct if_options {
struct in_addr req_addr;
struct in_addr req_mask;
+ struct in_addr req_brd;
struct rt_head routes;
struct in6_addr req_addr6;
uint8_t req_prefix_len;
@@ -229,6 +230,6 @@ struct if_options *read_config(struct dh
int add_options(struct dhcpcd_ctx *, const char *,
struct if_options *, int, char **);
void free_dhcp_opt_embenc(struct dhcp_opt *);
-void free_options(struct if_options *);
+void free_options(struct dhcpcd_ctx *, struct if_options *);
#endif
Index: src/external/bsd/dhcpcd/dist/src/if.c
diff -u src/external/bsd/dhcpcd/dist/src/if.c:1.1.1.3.2.1 src/external/bsd/dhcpcd/dist/src/if.c:1.1.1.3.2.2
--- src/external/bsd/dhcpcd/dist/src/if.c:1.1.1.3.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/if.c Mon Apr 9 16:46:34 2018
@@ -85,7 +85,7 @@ if_free(struct interface *ifp)
ipv6nd_free(ifp);
ipv6_free(ifp);
rt_freeif(ifp);
- free_options(ifp->options);
+ free_options(ifp->ctx, ifp->options);
free(ifp);
}
@@ -191,6 +191,21 @@ if_hasconf(struct dhcpcd_ctx *ctx, const
}
void
+if_markaddrsstale(struct if_head *ifs)
+{
+ struct interface *ifp;
+
+ TAILQ_FOREACH(ifp, ifs, next) {
+#ifdef INET
+ ipv4_markaddrsstale(ifp);
+#endif
+#ifdef INET6
+ ipv6_markaddrsstale(ifp, 0);
+#endif
+ }
+}
+
+void
if_learnaddrs(struct dhcpcd_ctx *ctx, struct if_head *ifs,
struct ifaddrs **ifaddrs)
{
@@ -234,7 +249,7 @@ if_learnaddrs(struct dhcpcd_ctx *ctx, st
#endif
ipv4_handleifa(ctx, RTM_NEWADDR, ifs, ifa->ifa_name,
&addr->sin_addr, &net->sin_addr,
- brd ? &brd->sin_addr : NULL, addrflags);
+ brd ? &brd->sin_addr : NULL, addrflags, 0);
break;
#endif
#ifdef INET6
@@ -258,7 +273,7 @@ if_learnaddrs(struct dhcpcd_ctx *ctx, st
#endif
ipv6_handleifa(ctx, RTM_NEWADDR, ifs,
ifa->ifa_name, &sin6->sin6_addr,
- ipv6_prefixlen(&net6->sin6_addr), addrflags);
+ ipv6_prefixlen(&net6->sin6_addr), addrflags, 0);
break;
#endif
}
@@ -268,6 +283,21 @@ if_learnaddrs(struct dhcpcd_ctx *ctx, st
*ifaddrs = NULL;
}
+void
+if_deletestaleaddrs(struct if_head *ifs)
+{
+ struct interface *ifp;
+
+ TAILQ_FOREACH(ifp, ifs, next) {
+#ifdef INET
+ ipv4_deletestaleaddrs(ifp);
+#endif
+#ifdef INET6
+ ipv6_deletestaleaddrs(ifp);
+#endif
+ }
+}
+
bool
if_valid_hwaddr(const uint8_t *hwaddr, size_t hwlen)
{
@@ -361,12 +391,17 @@ if_discover(struct dhcpcd_ctx *ctx, stru
}
for (i = 0; i < ctx->ifdc; i++)
- if (!fnmatch(ctx->ifdv[i], spec.devname, 0))
+ if (fnmatch(ctx->ifdv[i], spec.devname, 0) == 0)
break;
if (i < ctx->ifdc)
active = IF_INACTIVE;
+ for (i = 0; i < ctx->ifc; i++)
+ if (fnmatch(ctx->ifv[i], spec.devname, 0) == 0)
+ break;
+ if (ctx->ifc && i == ctx->ifc)
+ active = IF_INACTIVE;
for (i = 0; i < ctx->ifac; i++)
- if (!fnmatch(ctx->ifav[i], spec.devname, 0))
+ if (fnmatch(ctx->ifav[i], spec.devname, 0) == 0)
break;
if (ctx->ifac && i == ctx->ifac)
active = IF_INACTIVE;
@@ -535,15 +570,6 @@ if_discover(struct dhcpcd_ctx *ctx, stru
if_free(ifp);
continue;
}
-
- /* Ensure that the MTU is big enough for DHCP */
- if (if_getmtu(ifp) < MTU_MIN && active &&
- if_setmtu(ifp, MTU_MIN) == -1)
- {
- logerr("%s: if_setmtu", ifp->name);
- if_free(ifp);
- continue;
- }
}
ifp->vlanid = if_vlanid(ifp);
Index: src/external/bsd/dhcpcd/dist/src/ipv4.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv4.c:1.1.1.3.2.1 src/external/bsd/dhcpcd/dist/src/ipv4.c:1.1.1.3.2.2
--- src/external/bsd/dhcpcd/dist/src/ipv4.c:1.1.1.3.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/ipv4.c Mon Apr 9 16:46:34 2018
@@ -289,10 +289,11 @@ inet_dhcproutes(struct rt_head *routes,
TAILQ_FOREACH(r, &ifp->options->routes, rt_next) {
if (sa_is_unspecified(&r->rt_gateway))
break;
- if ((rt = rt_new(ifp)) == NULL)
+ if ((rt = rt_new0(ifp->ctx)) == NULL)
return -1;
- rt->rt_dflags = RTDF_STATIC;
memcpy(rt, r, sizeof(*rt));
+ rt_setif(rt, ifp);
+ rt->rt_dflags = RTDF_STATIC;
TAILQ_INSERT_TAIL(&nroutes, rt, rt_next);
}
} else {
@@ -407,6 +408,7 @@ inet_routerhostroute(struct rt_head *rou
}
if ((rth = rt_new(ifp)) == NULL)
return -1;
+ rth->rt_flags |= RTF_HOST;
sa_in_init(&rth->rt_dest, &gateway->sin_addr);
in.s_addr = INADDR_BROADCAST;
sa_in_init(&rth->rt_netmask, &in);
@@ -589,6 +591,7 @@ ipv4_addaddr(struct interface *ifp, cons
{
struct ipv4_state *state;
struct ipv4_addr *ia;
+ bool is_new = false;
#ifdef ALIAS_ADDR
int replaced, blank;
struct ipv4_addr *replaced_ia;
@@ -607,18 +610,23 @@ ipv4_addaddr(struct interface *ifp, cons
}
}
- if ((ia = malloc(sizeof(*ia))) == NULL) {
- logerr(__func__);
- return NULL;
+ ia = ipv4_iffindaddr(ifp, addr, NULL);
+ if (ia == NULL) {
+ ia = malloc(sizeof(*ia));
+ if (ia == NULL) {
+ logerr(__func__);
+ return NULL;
+ }
+ ia->iface = ifp;
+ ia->addr = *addr;
+#ifdef IN_IFF_TENTATIVE
+ ia->addr_flags = IN_IFF_TENTATIVE;
+#endif
+ is_new = true;
}
- ia->iface = ifp;
- ia->addr = *addr;
ia->mask = *mask;
ia->brd = *bcast;
-#ifdef IN_IFF_TENTATIVE
- ia->addr_flags = IN_IFF_TENTATIVE;
-#endif
snprintf(ia->saddr, sizeof(ia->saddr), "%s/%d",
inet_ntoa(*addr), inet_ntocidr(*mask));
@@ -650,7 +658,8 @@ ipv4_addaddr(struct interface *ifp, cons
}
#endif
- TAILQ_INSERT_TAIL(&state->addrs, ia, next);
+ if (is_new)
+ TAILQ_INSERT_TAIL(&state->addrs, ia, next);
return ia;
}
@@ -762,16 +771,56 @@ ipv4_applyaddr(void *arg)
}
void
+ipv4_markaddrsstale(struct interface *ifp)
+{
+ struct ipv4_state *state;
+ struct ipv4_addr *ia;
+
+ state = IPV4_STATE(ifp);
+ if (state == NULL)
+ return;
+
+ TAILQ_FOREACH(ia, &state->addrs, next) {
+ ia->flags |= IPV4_AF_STALE;
+ }
+}
+
+void
+ipv4_deletestaleaddrs(struct interface *ifp)
+{
+ struct ipv4_state *state;
+ struct ipv4_addr *ia, *ia1;
+
+ state = IPV4_STATE(ifp);
+ if (state == NULL)
+ return;
+
+ TAILQ_FOREACH_SAFE(ia, &state->addrs, next, ia1) {
+ if (!(ia->flags & IPV4_AF_STALE))
+ continue;
+ ipv4_handleifa(ifp->ctx, RTM_DELADDR,
+ ifp->ctx->ifaces, ifp->name,
+ &ia->addr, &ia->mask, &ia->brd, 0, getpid());
+ }
+}
+
+void
ipv4_handleifa(struct dhcpcd_ctx *ctx,
int cmd, struct if_head *ifs, const char *ifname,
const struct in_addr *addr, const struct in_addr *mask,
- const struct in_addr *brd, const int addrflags)
+ const struct in_addr *brd, int addrflags, pid_t pid)
{
struct interface *ifp;
struct ipv4_state *state;
struct ipv4_addr *ia;
bool ia_is_new;
+#if 0
+ logdebugx("%s: %s %s/%d %d", ifname,
+ cmd == RTM_NEWADDR ? "RTM_NEWADDR" : cmd == RTM_DELADDR ? "RTM_DELADDR" : "???",
+ inet_ntoa(*addr), inet_ntocidr(*mask), addrflags);
+#endif
+
if (ifs == NULL)
ifs = ctx->ifaces;
if (ifs == NULL) {
@@ -796,6 +845,7 @@ ipv4_handleifa(struct dhcpcd_ctx *ctx,
ia->iface = ifp;
ia->addr = *addr;
ia->mask = *mask;
+ ia->flags = 0;
ia_is_new = true;
#ifdef ALIAS_ADDR
strlcpy(ia->alias, ifname, sizeof(ia->alias));
@@ -817,6 +867,7 @@ ipv4_handleifa(struct dhcpcd_ctx *ctx,
else
ia->brd.s_addr = INADDR_ANY;
ia->addr_flags = addrflags;
+ ia->flags &= ~IPV4_AF_STALE;
break;
case RTM_DELADDR:
if (ia == NULL)
@@ -831,7 +882,7 @@ ipv4_handleifa(struct dhcpcd_ctx *ctx,
#ifdef ARP
arp_handleifa(cmd, ia);
#endif
- dhcp_handleifa(cmd, ia);
+ dhcp_handleifa(cmd, ia, pid);
}
if (cmd == RTM_DELADDR)
Index: src/external/bsd/dhcpcd/dist/src/ipv6.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6.c:1.1.1.3.2.1 src/external/bsd/dhcpcd/dist/src/ipv6.c:1.1.1.3.2.2
--- src/external/bsd/dhcpcd/dist/src/ipv6.c:1.1.1.3.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/ipv6.c Mon Apr 9 16:46:34 2018
@@ -566,7 +566,7 @@ ipv6_checkaddrflags(void *arg)
/* Simulate the kernel announcing the new address. */
ipv6_handleifa(ia->iface->ctx, RTM_NEWADDR,
ia->iface->ctx->ifaces, ia->iface->name,
- &ia->addr, ia->prefix_len, flags);
+ &ia->addr, ia->prefix_len, flags, 0);
} else {
/* Still tentative? Check again in a bit. */
struct timespec tv;
@@ -1063,7 +1063,7 @@ ipv6_getstate(struct interface *ifp)
void
ipv6_handleifa(struct dhcpcd_ctx *ctx,
int cmd, struct if_head *ifs, const char *ifname,
- const struct in6_addr *addr, uint8_t prefix_len, int addrflags)
+ const struct in6_addr *addr, uint8_t prefix_len, int addrflags, pid_t pid)
{
struct interface *ifp;
struct ipv6_state *state;
@@ -1134,6 +1134,7 @@ ipv6_handleifa(struct dhcpcd_ctx *ctx,
TAILQ_INSERT_TAIL(&state->addrs, ia, next);
}
ia->addr_flags = addrflags;
+ ia->flags &= ~IPV6_AF_STALE;
#ifdef IPV6_MANAGETEMPADDR
if (ia->addr_flags & IN6_IFF_TEMPORARY)
ia->flags |= IPV6_AF_TEMPORARY;
@@ -1174,8 +1175,8 @@ ipv6_handleifa(struct dhcpcd_ctx *ctx,
}
if (ia != NULL) {
- ipv6nd_handleifa(cmd, ia);
- dhcp6_handleifa(cmd, ia);
+ ipv6nd_handleifa(cmd, ia, pid);
+ dhcp6_handleifa(cmd, ia, pid);
/* Done with the ia now, so free it. */
if (cmd == RTM_DELADDR)
@@ -1705,7 +1706,7 @@ ipv6_ctxfree(struct dhcpcd_ctx *ctx)
int
ipv6_handleifa_addrs(int cmd,
- struct ipv6_addrhead *addrs, const struct ipv6_addr *addr)
+ struct ipv6_addrhead *addrs, const struct ipv6_addr *addr, pid_t pid)
{
struct ipv6_addr *ia, *ian;
uint8_t found, alldadcompleted;
@@ -1722,8 +1723,8 @@ ipv6_handleifa_addrs(int cmd,
switch (cmd) {
case RTM_DELADDR:
if (ia->flags & IPV6_AF_ADDED) {
- logwarnx("%s: deleted address %s",
- ia->iface->name, ia->saddr);
+ logwarnx("%s: pid %d deleted address %s",
+ ia->iface->name, pid, ia->saddr);
ia->flags &= ~IPV6_AF_ADDED;
}
if (ia->flags & IPV6_AF_DELEGATED) {
@@ -1972,19 +1973,6 @@ again:
return ia;
}
-void
-ipv6_settempstale(struct interface *ifp)
-{
- struct ipv6_state *state;
- struct ipv6_addr *ia;
-
- state = IPV6_STATE(ifp);
- TAILQ_FOREACH(ia, &state->addrs, next) {
- if (ia->flags & IPV6_AF_TEMPORARY)
- ia->flags |= IPV6_AF_STALE;
- }
-}
-
struct ipv6_addr *
ipv6_settemptime(struct ipv6_addr *ia, int flags)
{
@@ -2106,6 +2094,40 @@ ipv6_regentempifid(void *arg)
}
#endif /* IPV6_MANAGETEMPADDR */
+void
+ipv6_markaddrsstale(struct interface *ifp, unsigned int flags)
+{
+ struct ipv6_state *state;
+ struct ipv6_addr *ia;
+
+ state = IPV6_STATE(ifp);
+ if (state == NULL)
+ return;
+
+ TAILQ_FOREACH(ia, &state->addrs, next) {
+ if (flags == 0 || ia->flags & flags)
+ ia->flags |= IPV6_AF_STALE;
+ }
+}
+
+void
+ipv6_deletestaleaddrs(struct interface *ifp)
+{
+ struct ipv6_state *state;
+ struct ipv6_addr *ia, *ia1;
+
+ state = IPV6_STATE(ifp);
+ if (state == NULL)
+ return;
+
+ TAILQ_FOREACH_SAFE(ia, &state->addrs, next, ia1) {
+ if (ia->flags & IPV6_AF_STALE)
+ ipv6_handleifa(ifp->ctx, RTM_DELADDR,
+ ifp->ctx->ifaces, ifp->name,
+ &ia->addr, ia->prefix_len, 0, getpid());
+ }
+}
+
static struct rt *
inet6_makeroute(struct interface *ifp, const struct ra *rap)
Index: src/external/bsd/dhcpcd/dist/src/route.c
diff -u src/external/bsd/dhcpcd/dist/src/route.c:1.1.1.3.2.1 src/external/bsd/dhcpcd/dist/src/route.c:1.1.1.3.2.2
--- src/external/bsd/dhcpcd/dist/src/route.c:1.1.1.3.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/route.c Mon Apr 9 16:46:34 2018
@@ -101,17 +101,13 @@ rt_desc(const char *cmd, const struct rt
}
void
-rt_headclear(struct rt_head *rts, int af)
+rt_headclear0(struct dhcpcd_ctx *ctx, struct rt_head *rts, int af)
{
struct rt *rt, *rtn;
- struct dhcpcd_ctx *ctx;
if (rts == NULL)
return;
-
- if ((rt = TAILQ_FIRST(rts)) == NULL)
- return;
- ctx = rt->rt_ifp->ctx;
+ assert(ctx != NULL);
assert(&ctx->froutes != rts);
TAILQ_FOREACH_SAFE(rt, rts, rt_next, rtn) {
@@ -124,6 +120,16 @@ rt_headclear(struct rt_head *rts, int af
}
}
+void
+rt_headclear(struct rt_head *rts, int af)
+{
+ struct rt *rt;
+
+ if (rts == NULL || (rt = TAILQ_FIRST(rts)) == NULL)
+ return;
+ rt_headclear0(rt->rt_ifp->ctx, rts, af);
+}
+
static void
rt_headfree(struct rt_head *rts)
{
@@ -146,13 +152,11 @@ rt_dispose(struct dhcpcd_ctx *ctx)
}
struct rt *
-rt_new(struct interface *ifp)
+rt_new0(struct dhcpcd_ctx *ctx)
{
struct rt *rt;
- struct dhcpcd_ctx *ctx;
- assert(ifp != NULL);
- ctx = ifp->ctx;
+ assert(ctx != NULL);
if ((rt = TAILQ_FIRST(&ctx->froutes)) != NULL)
TAILQ_REMOVE(&ctx->froutes, rt, rt_next);
else if ((rt = malloc(sizeof(*rt))) == NULL) {
@@ -160,10 +164,30 @@ rt_new(struct interface *ifp)
return NULL;
}
memset(rt, 0, sizeof(*rt));
+ return rt;
+}
+
+void
+rt_setif(struct rt *rt, struct interface *ifp)
+{
+
+ assert(rt != NULL);
+ assert(ifp != NULL);
rt->rt_ifp = ifp;
#ifdef HAVE_ROUTE_METRIC
rt->rt_metric = ifp->metric;
#endif
+}
+
+struct rt *
+rt_new(struct interface *ifp)
+{
+ struct rt *rt;
+
+ assert(ifp != NULL);
+ if ((rt = rt_new0(ifp->ctx)) == NULL)
+ return NULL;
+ rt_setif(rt, ifp);
return rt;
}
Index: src/external/bsd/dhcpcd/dist/src/if-sun.c
diff -u src/external/bsd/dhcpcd/dist/src/if-sun.c:1.1.1.2.2.1 src/external/bsd/dhcpcd/dist/src/if-sun.c:1.1.1.2.2.2
--- src/external/bsd/dhcpcd/dist/src/if-sun.c:1.1.1.2.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/if-sun.c Mon Apr 9 16:46:34 2018
@@ -684,7 +684,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const str
ipv4_handleifa(ctx,
ifam->ifam_type == RTM_CHGADDR ?
RTM_NEWADDR : ifam->ifam_type,
- NULL, ifalias, &addr, &mask, &bcast, flags);
+ NULL, ifalias, &addr, &mask, &bcast, flags, 0);
break;
}
#endif
@@ -712,7 +712,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const str
ipv6_handleifa(ctx,
ifam->ifam_type == RTM_CHGADDR ?
RTM_NEWADDR : ifam->ifam_type,
- NULL, ifalias, &addr6, ipv6_prefixlen(&mask6), flags);
+ NULL, ifalias, &addr6, ipv6_prefixlen(&mask6), flags, 0);
break;
}
#endif
@@ -1414,11 +1414,9 @@ if_getlifetime6(struct ipv6_addr *addr)
return -1;
}
-int
-if_checkipv6(__unused struct dhcpcd_ctx *ctx,
- __unused const struct interface *ifp)
+void
+if_setup_inet6(__unused const struct interface *ifp)
{
- return 0;
}
#endif
Index: src/external/bsd/dhcpcd/dist/src/if.h
diff -u src/external/bsd/dhcpcd/dist/src/if.h:1.1.1.2.2.1 src/external/bsd/dhcpcd/dist/src/if.h:1.1.1.2.2.2
--- src/external/bsd/dhcpcd/dist/src/if.h:1.1.1.2.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/if.h Mon Apr 9 16:46:34 2018
@@ -116,7 +116,9 @@ int if_setflag(struct interface *ifp, sh
bool if_valid_hwaddr(const uint8_t *, size_t);
struct if_head *if_discover(struct dhcpcd_ctx *, struct ifaddrs **,
int, char * const *);
+void if_markaddrsstale(struct if_head *);
void if_learnaddrs(struct dhcpcd_ctx *, struct if_head *, struct ifaddrs **);
+void if_deletestaleaddrs(struct if_head *);
struct interface *if_find(struct if_head *, const char *);
struct interface *if_findindex(struct if_head *, unsigned int);
struct interface *if_loopback(struct dhcpcd_ctx *);
@@ -187,7 +189,7 @@ int if_addrflags(const struct interface
#endif
#ifdef INET6
-int if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *);
+void if_setup_inet6(const struct interface *);
#ifdef IPV6_MANAGETEMPADDR
int ip6_use_tempaddr(const char *ifname);
int ip6_temp_preferred_lifetime(const char *ifname);
Index: src/external/bsd/dhcpcd/dist/src/ipv6.h
diff -u src/external/bsd/dhcpcd/dist/src/ipv6.h:1.1.1.2.2.1 src/external/bsd/dhcpcd/dist/src/ipv6.h:1.1.1.2.2.2
--- src/external/bsd/dhcpcd/dist/src/ipv6.h:1.1.1.2.2.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/src/ipv6.h Mon Apr 9 16:46:34 2018
@@ -231,14 +231,17 @@ uint8_t ipv6_prefixlen(const struct in6_
int ipv6_userprefix( const struct in6_addr *, short prefix_len,
uint64_t user_number, struct in6_addr *result, short result_len);
void ipv6_checkaddrflags(void *);
+void ipv6_markaddrsstale(struct interface *, unsigned int);
+void ipv6_deletestaleaddrs(struct interface *);
int ipv6_addaddr(struct ipv6_addr *, const struct timespec *);
ssize_t ipv6_addaddrs(struct ipv6_addrhead *addrs);
void ipv6_deleteaddr(struct ipv6_addr *);
void ipv6_freedrop_addrs(struct ipv6_addrhead *, int,
const struct interface *);
void ipv6_handleifa(struct dhcpcd_ctx *ctx, int, struct if_head *,
- const char *, const struct in6_addr *, uint8_t, int);
-int ipv6_handleifa_addrs(int, struct ipv6_addrhead *, const struct ipv6_addr *);
+ const char *, const struct in6_addr *, uint8_t, int, pid_t);
+int ipv6_handleifa_addrs(int, struct ipv6_addrhead *, const struct ipv6_addr *,
+ pid_t);
struct ipv6_addr *ipv6_iffindaddr(struct interface *,
const struct in6_addr *, int);
int ipv6_hasaddr(const struct interface *);
@@ -259,7 +262,6 @@ void ipv6_freedrop(struct interface *, i
#ifdef IPV6_MANAGETEMPADDR
void ipv6_gentempifid(struct interface *);
-void ipv6_settempstale(struct interface *);
struct ipv6_addr *ipv6_createtempaddr(struct ipv6_addr *,
const struct timespec *);
struct ipv6_addr *ipv6_settemptime(struct ipv6_addr *, int);
Index: src/external/bsd/dhcpcd/dist/src/dev/udev.c
diff -u src/external/bsd/dhcpcd/dist/src/dev/udev.c:1.1.1.1 src/external/bsd/dhcpcd/dist/src/dev/udev.c:1.1.1.1.8.1
--- src/external/bsd/dhcpcd/dist/src/dev/udev.c:1.1.1.1 Fri Mar 31 20:51:16 2017
+++ src/external/bsd/dhcpcd/dist/src/dev/udev.c Mon Apr 9 16:46:34 2018
@@ -1,6 +1,6 @@
/*
* dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2015 Roy Marples <[email protected]>
+ * Copyright (c) 2006-2018 Roy Marples <[email protected]>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -35,10 +35,10 @@
#include <libudev.h>
#include <string.h>
-#include <syslog.h>
#include "../common.h"
#include "../dev.h"
+#include "../logerr.h"
static const char udev_name[] = "udev";
static struct udev *udev;
@@ -80,7 +80,7 @@ udev_handle_device(void *ctx)
device = udev_monitor_receive_device(monitor);
if (device == NULL) {
- syslog(LOG_ERR, "libudev: received NULL device");
+ logerrx("libudev: received NULL device");
return -1;
}
@@ -90,7 +90,7 @@ udev_handle_device(void *ctx)
/* udev filter documentation says "usually" so double check */
if (strcmp(subsystem, "net") == 0) {
- syslog(LOG_DEBUG, "%s: libudev: %s", ifname, action);
+ logdebugx("%s: libudev: %s", ifname, action);
if (strcmp(action, "add") == 0 || strcmp(action, "move") == 0)
dhcpcd.handle_interface(ctx, 1, ifname);
else if (strcmp(action, "remove") == 0)
@@ -122,37 +122,36 @@ udev_start(void)
int fd;
if (udev) {
- syslog(LOG_ERR, "udev: already started");
+ logerrx("udev: already started");
return -1;
}
- syslog(LOG_DEBUG, "udev: starting");
+ logdebugx("udev: starting");
udev = udev_new();
if (udev == NULL) {
- syslog(LOG_ERR, "udev_new: %m");
+ logerr("udev_new");
return -1;
}
monitor = udev_monitor_new_from_netlink(udev, "udev");
if (monitor == NULL) {
- syslog(LOG_ERR, "udev_monitor_new_from_netlink: %m");
+ logerr("udev_monitor_new_from_netlink");
goto bad;
}
#ifndef LIBUDEV_NOFILTER
if (udev_monitor_filter_add_match_subsystem_devtype(monitor,
"net", NULL) != 0)
{
- syslog(LOG_ERR,
- "udev_monitor_filter_add_match_subsystem_devtype: %m");
+ logerr("udev_monitor_filter_add_match_subsystem_devtype");
goto bad;
}
#endif
if (udev_monitor_enable_receiving(monitor) != 0) {
- syslog(LOG_ERR, "udev_monitor_enable_receiving: %m");
+ logerr("udev_monitor_enable_receiving");
goto bad;
}
fd = udev_monitor_get_fd(monitor);
if (fd == -1) {
- syslog(LOG_ERR, "udev_monitor_get_fd: %m");
+ logerr("udev_monitor_get_fd");
goto bad;
}
return fd;
Index: src/external/bsd/dhcpcd/dist/tests/eloop-bench/eloop-bench.c
diff -u src/external/bsd/dhcpcd/dist/tests/eloop-bench/eloop-bench.c:1.1.1.1.8.1 src/external/bsd/dhcpcd/dist/tests/eloop-bench/eloop-bench.c:1.1.1.1.8.2
--- src/external/bsd/dhcpcd/dist/tests/eloop-bench/eloop-bench.c:1.1.1.1.8.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/dist/tests/eloop-bench/eloop-bench.c Mon Apr 9 16:46:34 2018
@@ -26,7 +26,9 @@
*/
#include <sys/resource.h>
+
#include <err.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@@ -59,38 +61,37 @@ static void
read_cb(void *arg)
{
struct pipe *p = arg;
- unsigned char c;
- ssize_t l;
+ unsigned char buf[1];
- l = read(p->fd[0], &c, sizeof(c));
- if (l == -1)
+ if (read(p->fd[0], buf, 1) != 1) {
+ warn("%s: read", __func__);
bad++;
- else
- good += (size_t)l;
- if (writes) {
- p = (struct pipe *)arg;
- l = write(p->fd[1], "e", 1);
- if (l != 1)
+ } else
+ good++;
+
+ if (writes != 0) {
+ writes--;
+ if (write(p->fd[1], "e", 1) != 1) {
+ warn("%s: write", __func__);
bad++;
- else {
- writes -= (size_t)l;
- fired += (size_t)l;
- }
+ } else
+ fired++;
}
- if (writes == 0) {
- if (good == fired)
- eloop_exit(e, EXIT_SUCCESS);
+ if (writes == 0 && fired == good) {
+ //printf("fired %zu, good %zu, bad %zu\n", fired, good, bad);
+ eloop_exit(e, good == fired && bad == 0 ?
+ EXIT_SUCCESS : EXIT_FAILURE);
}
}
-static struct timespec *
-runone(void)
+static int
+runone(struct timespec *t)
{
size_t i;
struct pipe *p;
- static struct timespec _ts;
struct timespec ts, te;
+ int result;
writes = nwrites;
fired = good = 0;
@@ -98,28 +99,27 @@ runone(void)
for (i = 0, p = pipes; i < nactive; i++, p++) {
if (write(p->fd[1], "e", 1) != 1)
err(EXIT_FAILURE, "send");
+ writes--;
+ fired++;
}
if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
err(EXIT_FAILURE, "clock_gettime");
- (void) eloop_start(e, NULL);
+ result = eloop_start(e, NULL);
if (clock_gettime(CLOCK_MONOTONIC, &te) == -1)
err(EXIT_FAILURE, "clock_gettime");
- timespecsub(&te, &ts, &_ts);
- return &_ts;
+ timespecsub(&te, &ts, t);
+ return result;
}
int
main(int argc, char **argv)
{
- int c;
+ int c, result, exit_code;
size_t i, nruns = 25;
struct pipe *p;
- struct timespec *ts;
-
- if ((e = eloop_new()) == NULL)
- err(EXIT_FAILURE, "eloop_init");
+ struct timespec ts, te, t;
while ((c = getopt(argc, argv, "a:n:r:w:")) != -1) {
switch (c) {
@@ -140,27 +140,45 @@ main(int argc, char **argv)
}
}
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
+ err(EXIT_FAILURE, "clock_gettime");
+
+ if ((e = eloop_new()) == NULL)
+ err(EXIT_FAILURE, "eloop_init");
+
if (nactive > npipes)
nactive = npipes;
- pipes = malloc(sizeof(*p) * npipes);
+ pipes = calloc(npipes, sizeof(*p));
if (pipes == NULL)
err(EXIT_FAILURE, "malloc");
for (i = 0, p = pipes; i < npipes; i++, p++) {
- if (pipe(p->fd) == -1)
+ if (pipe2(p->fd, O_CLOEXEC | O_NONBLOCK) == -1)
err(EXIT_FAILURE, "pipe");
if (eloop_event_add(e, p->fd[0], read_cb, p) == -1)
err(EXIT_FAILURE, "eloop_event_add");
}
+ printf("active = %zu, pipes = %zu, runs = %zu, writes = %zu\n",
+ nactive, npipes, nruns, nwrites);
+
+ exit_code = EXIT_SUCCESS;
for (i = 0; i < nruns; i++) {
- if ((ts = runone()) == NULL)
- err(EXIT_FAILURE, "runone");
- printf("%lld.%.9ld\n", (long long)ts->tv_sec, ts->tv_nsec);
+ result = runone(&t);
+ if (result != EXIT_SUCCESS)
+ exit_code = result;
+ printf("run %zu took %lld.%.9ld seconds, result %d\n",
+ i + 1, (long long)t.tv_sec, t.tv_nsec, result);
}
eloop_free(e);
free(pipes);
- exit(0);
+
+ if (clock_gettime(CLOCK_MONOTONIC, &te) == -1)
+ err(EXIT_FAILURE, "clock_gettime");
+ timespecsub(&te, &ts, &t);
+ printf("total %lld.%.9ld seconds, result %d\n",
+ (long long)t.tv_sec, t.tv_nsec, exit_code);
+ exit(exit_code);
}
Index: src/external/bsd/dhcpcd/include/config.h
diff -u src/external/bsd/dhcpcd/include/config.h:1.1.8.1 src/external/bsd/dhcpcd/include/config.h:1.1.8.2
--- src/external/bsd/dhcpcd/include/config.h:1.1.8.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/include/config.h Mon Apr 9 16:46:34 2018
@@ -9,6 +9,7 @@
#define HAVE_IFAM_ADDRFLAGS
#define HAVE_IFADDRS_ADDRFLAGS
#define HAVE_UTIL_H
+#define HAVE_SETPROCTITLE
#define HAVE_SYS_QUEUE_H
#define HAVE_REALLOCARRAY
#define HAVE_KQUEUE
Index: src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.40.4.1 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.40.4.2
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.40.4.1 Sat Jan 13 21:35:30 2018
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile Mon Apr 9 16:46:34 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.40.4.1 2018/01/13 21:35:30 snj Exp $
+# $NetBSD: Makefile,v 1.40.4.2 2018/04/09 16:46:34 martin Exp $
#
WARNS?= 6
@@ -75,7 +75,7 @@ ${f}: ${f}.in
.endfor
# XXXGCC5
-.if defined(HAVE_GCC) && ${HAVE_GCC} == 53 && ${ACTIVE_CC} == "gcc"
+.if defined(HAVE_GCC) && ${HAVE_GCC} >= 5 && ${ACTIVE_CC} == "gcc"
COPTS.if-bsd.c+= -Wno-error=sign-conversion
.endif