summaryrefslogtreecommitdiff
path: root/etc/netstart
diff options
context:
space:
mode:
authorKlemens Nanni <kn@cvs.openbsd.org>2022-11-01 10:45:54 +0000
committerKlemens Nanni <kn@cvs.openbsd.org>2022-11-01 10:45:54 +0000
commit076d55f253b0494b3affafcfbb75da018054ab3e (patch)
tree6850362dad2c338aaeab26961fd90c9dbfd294f5 /etc/netstart
parent080b16b403d0a3087b2a6aafce79a0e79521eac2 (diff)
Do not wait for DAD completion in dry-run mode
1. only do so when running without -n 2. move code to own wait_dad() helper like wait_autoconf_default() has it 3. use local _count as usual in both functions rather than the global count Feedback OK claudio
Diffstat (limited to 'etc/netstart')
-rw-r--r--etc/netstart24
1 files changed, 15 insertions, 9 deletions
diff --git a/etc/netstart b/etc/netstart
index afbeff5cd41..15a584bbd4e 100644
--- a/etc/netstart
+++ b/etc/netstart
@@ -1,6 +1,6 @@
#!/bin/sh -
#
-# $OpenBSD: netstart,v 1.225 2022/10/31 20:14:45 kn Exp $
+# $OpenBSD: netstart,v 1.226 2022/11/01 10:45:53 kn Exp $
# Turn off Strict Bourne shell mode.
set +o sh
@@ -290,15 +290,25 @@ ip6routes() {
# wait for autoconf interfaces
wait_autoconf_default() {
+ local _count=0
+
if ifconfig | grep -q ': flags=.*<.*AUTOCONF.*>'; then
- count=0
- while ((count++ < 20)); do
+ while ((_count++ < 20)); do
route -n show | grep -q ^default && break
sleep .5
done
fi
}
+# Ensure IPv6 Duplicate Address Detection (DAD) is completed.
+wait_dad() {
+ local _count=0
+
+ while ((_count++ < 10 && $(sysctl -n net.inet6.ip6.dad_pending) != 0)); do
+ sleep 1
+ done
+}
+
# Make sure the invoking user has the right privileges. Check for presence of
# id(1) to avoid problems with diskless setups.
if [[ -x /usr/bin/id ]] && (($(id -u) != 0)); then
@@ -397,10 +407,6 @@ $PRINT_ONLY || wait_autoconf_default
# Configure interfaces that rely on routing
ifmstart "tun tap gif etherip gre egre nvgre eoip vxlan pflow wg"
-if $IP6KERNEL; then
- # Ensure IPv6 Duplicate Address Detection (DAD) is completed.
- count=0
- while ((count++ < 10 && $(sysctl -n net.inet6.ip6.dad_pending) != 0)); do
- sleep 1
- done
+if $IP6KERNEL && ! $PRINT_ONLY; then
+ wait_dad
fi