From nobody Tue Jul 7 06:38:48 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 4gvWlY3LcBz6l0jl for ; Tue, 07 Jul 2026 06:38:49 +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 4gvWlX6g8gz41xs for ; Tue, 07 Jul 2026 06:38:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783406329; 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=im2Yc/6PrLkZlZlGAY3y8fQotuaGrBk7qW6oiT6o6dE=; b=TiiXA7An0fqEvSX2LZ4wjAkrpS3YcjKcnmb6c9lDaQt5MRuJL3Cn2CuO0z4IRQgf9HVL1H +Jql0QhPsO2eqFc7aS5GWDkhHJuAc2RAzXWwjlaSL7MSHSCw3DVheg3l1GbkUwRz9s1DYu i813pNFR6jke9xPU2cRKLI0tfwPfcxtPOQbijfud6lZcxURqVcmpG2Zwx4rBtk9Z6E2h84 uppuT9Z0D+dxkZnYsTNk73ujLPGbiK1gqUEyLefmNryZMcob7ZfK6gvEZszizEEMsybvAn t92VgG6Bp3yD1OP+sij7FQUwMpG2CtQVcKbW30C1pv13/AD8C4l38prgXl9+rA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1783406328; a=rsa-sha256; cv=none; b=lQI6NLZhwN5jSJHVtJIGaYyjvwY678CrriYKLu5nfENH/3P2MGi+y0N0bbNnu4xCDYE4PD 6q08urxW24phxd6//oO2pJ+dsglKSQPlWEYmb4KyAib3QWNoL3hCQ3FH6pzI+d5yWR5qk3 GUv4LJCi3aBOUAqqTm26MdnYNQyyNu7CUr0idkEArxbsXvBy7w+errfYF2yjti5esgDpUP Y4shmeN4zM64Sm7rttEyIUVSQg73yOmDc9Q2qYkQ6Wxk7wXxUM+xw52/L3hAuMs9S7YF47 4zIloDYCdAXqV6/WxY5k1XtOD7WyVyl6SCMP7vC9/SNaDUtvnaS9+OpmoV2l0Q== 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=1783406328; 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=im2Yc/6PrLkZlZlGAY3y8fQotuaGrBk7qW6oiT6o6dE=; b=G1w2SH5JlBXxLZ8d0tdMmhLzDWz1MwsKhCCyODeyShdsYpXk+nM3i4GQiupPikZenGhuqH Rh9jJn6ariljkwMJTNYi9jO786qJNYqHLwJ/cRLNLvaAP1NNEVXtFGaVTUsoPxGlpS/Daa bzdS2GqWjwCOPnynrCHURViJ7lC6bsJIBxPNVn+EFWUcck/vUyJxFX3UNghxFr0vl9u2Sf tcLFamqCydXpTWf4eEaecvjUKkbsIHp7Wv36//fWxGolTP6zkPfZmGZi9CxohRf2rPkAhw YWxIcTQ7EeHMOgZcICp/Arob/RemrvD5ZiETD2kl0BMWXZ3ijosJAaCWZd+Htg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gvWlX5XZXz836 for ; Tue, 07 Jul 2026 06:38:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 376e0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 07 Jul 2026 06:38:48 +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: ba4033104a89 - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: ba4033104a89c9a0e0ebe6bed5f029cc1cf95755 Auto-Submitted: auto-generated Date: Tue, 07 Jul 2026 06:38:48 +0000 Message-Id: <6a4c9ef8.376e0.205857a8@gitrepo.freebsd.org> The branch stable/15 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=ba4033104a89c9a0e0ebe6bed5f029cc1cf95755 commit ba4033104a89c9a0e0ebe6bed5f029cc1cf95755 Author: Dag-Erling Smørgrav AuthorDate: 2026-06-26 14:43:26 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-07-07 06:38:11 +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 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