From nobody Tue Jul 7 06:38:56 2026 X-Original-To: dev-commits-src-branches@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 4gvWlj0KMyz6l13d for ; Tue, 07 Jul 2026 06:38:57 +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 4gvWlh5lYBz42F8 for ; Tue, 07 Jul 2026 06:38:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783406336; 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=ydHGA6gwmAA/aSFASSEjrctI2Fe9td3qY7X3/wLi8JE=; b=DmfEgPKPG3mNmuh5i1n6UGhG8VBZZ5tIa/wkzOX+qNlwHbI98xDJ98EMWeBuOh7FCMhy0L Z+WGdEYEos+rBBtmhc2v2+C3HSQXzCBAqymn74fNRQrIr+JCTdkq4fOuhVad5CiJgdalLK LbUgLmMAD91Ca7HqvdPAHBi5coBvOeWOjDktPlt3tsc117D6pcnlqP5ylbRMT5qi7WMX4E 7L+bJx7ZE6OXuXxRzDmzC3Myn6RD3lg+29qez88uaywMhr8I1v++yfcCdqtShMRUE3tdKC aqRxC6k9u3+1QMfVC7mozzStM4YH0lEJvQpf485Lk8ozOTn4+ya8bRIZcQN32A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1783406336; a=rsa-sha256; cv=none; b=Bbw2WvgW/AW0EW8y2tV3+L6DGd7xBt1vxIS6G1SzZwD02bSnxbHQHhYZX7tSWUl5avJYYb 2iX/npcrOjFx6XL+YH9/G6hg0b6hfdaOqthEuE3QkTVs7df6U0lZVWHjgjlw1kKcU2z7Nt mWp34mDUdLL/Xoi6UhPjvuQs9imUS0mOvtBuqNpqb7x6oX+1bfO4Gx6qLW9bOp7LHyPtSs +8m8dBji61MSdzidmeJQm0KhfRNRiTscX2hHQ4owIqk6hexbqefB+TMkcX3GlpLjke7Lzr L4PfpFb2Ke168U10eKLQidO+6rjcc8EDN3xzhyl2KdpJNQoxVWdm3iC2nG8TEg== 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=1783406336; 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=ydHGA6gwmAA/aSFASSEjrctI2Fe9td3qY7X3/wLi8JE=; b=dm6fXSIFrmi2HWk/KgAggmtGTSsHRSzjit9Sbf+WSPRCnUJ/suCqTPtoaqmC/NMHHEqQ+6 KrZMnXYXBnvEFYH17+KcuLhmujbHuAvzTA/BnX0Geg0eh3pn5aEDFLNjQNq13AFFysq5Gg daE5SzFZv7ORQzFvJLfjN6Wa6cuBhHrUKl4frbXinpNtvMYe9HkR3xCjKOrVttgMtXkMET 03oR3C4dTj1DxsIZepKQwZJ0PXWTUxKf84Q9T/6z++M8nnk3fe/j+KM5u5TIWMg0FDPeby hAbpD+GoFpIJSalIqGRa6t7Zaxlf18uj6tZjku0TwYIAjJjjiPaveW8h/1WSBA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gvWlh4Dlgz85g for ; Tue, 07 Jul 2026 06:38:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 370fd by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 07 Jul 2026 06:38:56 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 973d1f2b12ab - stable/14 - local-unbound-setup: Support IPv6-only systems List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 973d1f2b12aba78d153095640820e865c1d112e1 Auto-Submitted: auto-generated Date: Tue, 07 Jul 2026 06:38:56 +0000 Message-Id: <6a4c9f00.370fd.61510526@gitrepo.freebsd.org> The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=973d1f2b12aba78d153095640820e865c1d112e1 commit 973d1f2b12aba78d153095640820e865c1d112e1 Author: Dag-Erling Smørgrav AuthorDate: 2026-06-26 14:43:26 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-07-07 06:38:16 +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 (cherry picked from commit f0a861efbafeb81428d5e8c23dac9da73fe14007) --- 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 c15ce96e1cfe..e7c35db44141 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-system-cert: yes" 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