git: d52de9a3448f - main - defaultroute: Fix dual-stack and IPv6-only handling
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 04 Jun 2026 08:50:50 UTC
The branch main has been updated by pouria:
URL: https://cgit.FreeBSD.org/src/commit/?id=d52de9a3448f0233a11e0b4de557e403ace71748
commit d52de9a3448f0233a11e0b4de557e403ace71748
Author: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
AuthorDate: 2026-06-04 07:58:07 +0000
Commit: Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-06-04 08:49:13 +0000
defaultroute: Fix dual-stack and IPv6-only handling
Since IPv6-only setups are becoming more common, and IPv6
connectivity is often sufficient for tasks such as DNS
resolution and NTP time synchronization, update defaultroute
rc.d script to support IPv6-only environments.
Reviewed by: pouria, ae
Differential Revision: https://reviews.freebsd.org/D56797
---
libexec/rc/rc.d/defaultroute | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/libexec/rc/rc.d/defaultroute b/libexec/rc/rc.d/defaultroute
index b96f91d36118..5368dca4cf62 100755
--- a/libexec/rc/rc.d/defaultroute
+++ b/libexec/rc/rc.d/defaultroute
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Wait for the default route to be up if DHCP is in use
+# Wait for the default route to be up if DHCPv4 or IPv6 SLAAC is in use
#
#
@@ -22,7 +22,7 @@ defaultroute_carrier()
local carrier nocarrier
carrier=1
- for _if in ${dhcp_interfaces}; do
+ for _if in ${dhcp_interfaces} ${autoconf_interfaces}; do
output=`/sbin/ifconfig ${_if}`
nocarrier=`expr "${output}" : '.*[[:blank:]]status: \(no carrier\)'`
[ -z "${nocarrier}" ] && carrier=0
@@ -32,22 +32,30 @@ defaultroute_carrier()
defaultroute_start()
{
- local nl waited
+ local have_inet have_inet6 nl waited
- afexists inet || return 0
+ # Check for IPv4/IPv6 support
+ have_inet=0
+ afexists inet && have_inet=1
+ have_inet6=0
+ afexists inet6 && have_inet6=1
+ [ ${have_inet} -eq 0 ] && [ ${have_inet6} -eq 0 ] && return
- # Return without waiting if we don't have dhcp interfaces or
- # if none of the dhcp interfaces is plugged in.
- dhcp_interfaces=`list_net_interfaces dhcp`
- [ -z "${dhcp_interfaces}" ] && return
+ # Return without waiting if we don't have dhcp or autoconf interfaces,
+ # or if none of them is plugged in.
+ [ ${have_inet} -ne 0 ] && dhcp_interfaces=`list_net_interfaces dhcp`
+ [ ${have_inet6} -ne 0 ] && autoconf_interfaces=`list_net_interfaces autoconf`
+ [ -z "${dhcp_interfaces}" -a -z "${autoconf_interfaces}" ] && return
# Wait for a default route
waited=0
while [ ${waited} -lt ${defaultroute_delay} ]; do
- defif=`get_default_if -inet`
- if [ -n "${defif}" ]; then
+ [ ${have_inet} -ne 0 ] && defif=`get_default_if -inet`
+ [ ${have_inet6} -ne 0 ] && defif6=`get_default_if -inet6`
+ if [ -n "${defif}" ] || [ -n "${defif6}" ]; then
if [ ${waited} -ne 0 ]; then
- echo -n "($defif)"
+ [ -n "${defif}" ] && echo -n "($defif)=>inet "
+ [ -n "${defif6}" ] && echo -n "($defif6)=>inet6"
nl=1
fi
break