From nobody Fri Jun 26 14:43:37 2026 X-Original-To: dev-commits-src-main@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 4gmz272C67z6jc2M for ; Fri, 26 Jun 2026 14:43:43 +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 4gmz2710zYz3bq7 for ; Fri, 26 Jun 2026 14:43:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782485023; 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=IkYH21Kzqf1MkOOBUSu1IgrmuGr5ujAwXydGyh0p5pCz9+DMYs43FbVExzR4XoGb7xouI3 eniujxoOg1bxlMiTaiUtVyIBha+jRtK5T83pm+po7IAvPd8CJfDYQDJb829j9lu3Krx2Al qgHjteutDwNzmU9T2WvJPLQFtOcmGxDDBHOAuke48h/axf1SXO+EF1bvfoJnmegcbLQ2fb 9VgdsvwC12eSM+4yDGuo6LqBLDq/E/3Jaz8FBBKiauDCgIoIn0JTLwBW5ni6OdxOnL7OcD 26iWVmOkHDBfxrD9LQutAtswHXi3gLgkxIDP+yF2q7Fw4ckJMSdI0F4hxNOjKQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782485023; a=rsa-sha256; cv=none; b=Redl70VIGbGaBjKJOM1ynzy7ePZTa/E5rv+IiSkT4cZtQK5oF09xQuPy1e7tyDUP46cOVF LNd8v5coAGIcb3n42PhBNNndKQICCF34ZTLbT4w/1TASIe+gpwlJXKydrOJaIth+pYwmzO ZF7Q3vrxP1z4I/rQ6RYweR1yUqHgzvdDCnz+tI253ZHe895xXpMUFIpctcoueUY1aO7RH8 R+kbCevuTbIwWsO3ztNXkmTLIJZn/dcjxN0rZ/yHZjUY+hIHwIOFdFr4dtKWUNbDTRA8Ha WitEmoiaxxnbNivygkEKj8u7O5biDc7a61mNPUWUsivQHxXCV7adhzqUMxTDOw== 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=1782485023; 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=BavbJeN79jGm9Or2uK+8zm9q9Mhhk8McYLKJW0duPQSzi3hbGapbLNvC2C4U9Jb2enY9E7 indUAaMX+F55vD2FsB0celEi5klXAWerYzPdeSjvTfoixb+5GbKX1BeQgk33WjTdpdMnmA MWuY5+02pRfhCNe/BWipba4RHbf92MrPI+BIrgJR0DN9HbHlLoa7gAv3HWyCgzdvRm+hGW K81uXaPvMxVUEjR4JuDN32cHoW+LzIqjEGKj3SaDZR5o13N5QgfFstxRK1th8RSsM5LEwb GrX39CT4XlxMZG+mosg0ufyAnKLg55lt1sQ982tLnHk1rFqWTHkcQkkP34pilQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gmz2704Jbzj39 for ; Fri, 26 Jun 2026 14:43:43 +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 the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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