From nobody Fri Jun 26 14:43:37 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gmz2220dBz6jbkt for ; Fri, 26 Jun 2026 14:43:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gmz220z58z3bS8 for ; Fri, 26 Jun 2026 14:43:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782485018; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NsVgk/FVrYS+pl7prZKUYMnYBNplf4Z+O9c7Bc1wqBA=; b=WtCIpIkJyUxIT797svQwtcOqgNp29+zi7Jk+WrC34shyJqqHQBwTC+UdP6h4OE1m2nsd0+ chsr1QmHXo/DNWD+LByYxLkbIbMgba3L0A0vT759bWLFS1jKJqkrkU/yL629I5LRA4LDcs vCu0YUsuhfsmkDmUhbM4qlEgZf7qBcMRBd5l/HbJY0Ge0WdTXUCogEPow1F8glhnxml6PB kPKSz8w7a4Th8TcZMxaWhmCcVgptJdkGcnDYAW3GFs+strUzsrpS65rU3lVCvi8+Z/Wwyf vp3On+b351c9etHzvTIjJClEiRj0Slinf7tN0SKeJeamzu0jJ9prj7rI3fM84g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782485018; a=rsa-sha256; cv=none; b=uYEd65Oa3PIoWC3CcuII6h1ptfh4BevPOnpQ2Cbxu5K129VV7xqZNcH3rUKZ6bjk1RGMKr RYrDFyxKJvHrwY/uvwM1JfnB5jnSoVYDRpT9WK7L1at7g+MpqFU6ch9KgdztqTUoCpPbm6 elfGTft1kucOgrKLR3+PYo4aFbSdDNZU4b22QRGF/C5qb1aLThBZGCrjp3sm+XNB5i3xwm 6nROFnExEmrVvUOvHZ6KCx85oZrSku4CDCdIo4KUthFxovMll2RNGEOOiNoqX290nXTrvU 3cSk0qWGUBh+W8AL9p4/LG3b75Mf+DHq9LmciE4Otlb4buyoFc4Z42IfTOiKdQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782485018; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NsVgk/FVrYS+pl7prZKUYMnYBNplf4Z+O9c7Bc1wqBA=; b=AhhUv5O0HwSniBDsVC57+/nu+Il1FOLj9n8GXLqlr1A8+zZ1rZEFeFK5JuR1N+sNdnZWhe nitxJit5k6EVmiVTF003+KUGfOGVHp5is4csiiKimzwwQ8+YyhsmkIgtw2SQThRteyXCJH E8R4AqCcjh65pKaCWxSzxmMY7yjX9cqzn6rxQy5mzQCWTiHVk8OFFpEVn0kv3TukNcFaZB JgL0lUsqIP2XvhrdJSne5fSh29h31envW3GERlz8MP1ZAhlA7mGyUF/s/MzzPFFo8ub4c+ GnWUJAwz2JqqBt+nD/vpZYqhbgKLE6axKfhagwSJhSySPKp+vIcnyquoa/Bnng== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gmz2202gjzhxR for ; Fri, 26 Jun 2026 14:43:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1f234 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 26 Jun 2026 14:43:37 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: f0a861efbafe - main - local-unbound-setup: Support IPv6-only systems List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f0a861efbafeb81428d5e8c23dac9da73fe14007 Auto-Submitted: auto-generated Date: Fri, 26 Jun 2026 14:43:37 +0000 Message-Id: <6a3e9019.1f234.5366f33f@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=f0a861efbafeb81428d5e8c23dac9da73fe14007 commit f0a861efbafeb81428d5e8c23dac9da73fe14007 Author: Dag-Erling Smørgrav AuthorDate: 2026-06-26 14:43:26 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-06-26 14:43:26 +0000 local-unbound-setup: Support IPv6-only systems * In the server configuration, disable protocols not supported by the kernel. * In resolv.conf, instead of only using 127.0.0.1, use either 127.0.0.1, ::1, or both depending on which protocols the kernel supports. MFC after: 1 week Reviewed by: jlduran Differential Revision: https://reviews.freebsd.org/D57840 --- usr.sbin/unbound/setup/local-unbound-setup.sh | 50 +++++++++++++++++++++------ 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/usr.sbin/unbound/setup/local-unbound-setup.sh b/usr.sbin/unbound/setup/local-unbound-setup.sh index ec3aeb673ecc..6b217ec574cd 100755 --- a/usr.sbin/unbound/setup/local-unbound-setup.sh +++ b/usr.sbin/unbound/setup/local-unbound-setup.sh @@ -72,6 +72,19 @@ RE_forward_addr="((${RE_ipv4}|${RE_ipv6})(@${RE_port})?)" RE_forward_name="(${RE_dnsname}(@${RE_port})?)" RE_forward_tls="(${RE_forward_addr}(#${RE_dnsname})?)" +# +# Check if a kernel feature is available +# +has_feature() { + local name=$1 v + eval "v=\$kern_features_${name}" + if [ -z "$v" ] ; then + v="$(sysctl -qn "kern.features.${name}")" + eval "kern_features_${name}=$((v))" + fi + return $((!v)) +} + # # Set default values for unset configuration variables. # @@ -136,13 +149,12 @@ get_nameservers() { # # Scan through /etc/resolv.conf looking for uncommented nameserver -# lines. Comment out any that don't point to localhost. Finally, -# append a nameserver line that points to localhost, if there wasn't -# one already, and enable the edns0 option. +# lines and comment out any that don't point to localhost. Finally, +# append the correct nameserver lines and enable the edns0 option. # gen_resolv_conf() { - local localhost=no - local edns0=no + local localhost4=false localhost6=false + local edns0=false while read line ; do local bareline=${line%%\#*} local key=${bareline%%[[:space:]]*} @@ -150,8 +162,17 @@ gen_resolv_conf() { case ${key} in nameserver) case ${value} in - 127.0.0.1|::1|localhost|localhost.*) - localhost=yes + 127.0.0.1) + localhost4=true + if ! has_feature inet ; then + continue + fi + ;; + ::1) + localhost6=true + if ! has_feature inet6 ; then + continue + fi ;; *) echo -n "# " @@ -161,17 +182,20 @@ gen_resolv_conf() { options) case ${value} in *edns0*) - edns0=yes + edns0=true ;; esac ;; esac echo "${line}" done - if [ "${localhost}" = "no" ] ; then + if ! $localhost4 && has_feature inet ; then echo "nameserver 127.0.0.1" fi - if [ "${edns0}" = "no" ] ; then + if ! $localhost6 && has_feature inet6 ; then + echo "nameserver ::1" + fi + if ! $edns0 ; then echo "options edns0" fi } @@ -261,6 +285,12 @@ gen_unbound_conf() { if [ "${use_tls}" = "yes" ] ; then echo " tls-cert-bundle: /etc/ssl/cert.pem" fi + if ! has_feature inet ; then + echo " do-ip4: no" + fi + if ! has_feature inet6 ; then + echo " do-ip6: no" + fi echo " so-sndbuf: 0" echo "" if [ -f "${forward_conf}" ] ; then