resolved: keep parsing DNS delegate servers after duplicates

The DNS delegate parser tries to filter duplicate DNS= entries, but the
duplicate branch returned from the whole parser. This made a duplicate
server truncate the rest of the same DNS= line, silently dropping later
valid servers.

Reproducer:

  DNS=192.168.77.78 192.168.77.78 192.168.77.79

Before: only 192.168.77.78 appeared in the delegate server list.

Follow-up for: 7928c0e0a1

(cherry picked from commit 0cfa2d4f4c)
This commit is contained in:
dongshengyuan authored and Luca Boccassi committed 2026-09-09 10:08:20 +01:00
1 parent 1fb609802c
commit f2e30e42e3
2 files changed
+3 -2

No files matched your search

+1 -1
View File
@@ -281,7 +281,7 @@ int config_parse_delegate_dns_servers(
/* Drop the marker. This is used to find the servers that ceased to exist, see
* manager_mark_dns_servers() and manager_flush_marked_dns_servers(). */
dns_server_move_back_and_unmark(s);
return 0;
continue;
}
r = dns_server_new(
+2 -1
View File
@@ -1473,7 +1473,7 @@ testcase_delegate() {
mkdir -p /run/systemd/dns-delegate.d/
cat >/run/systemd/dns-delegate.d/testcase.dns-delegate <<EOF
[Delegate]
DNS=192.168.77.78
DNS=192.168.77.78 192.168.77.78 192.168.77.79
Domains=exercise.test
FirewallMark=42
EOF
@@ -1481,6 +1481,7 @@ EOF
resolvectl status
assert_eq "$(resolvectl --json=short | jq -rc '.[] | select(.delegate == "testcase") | .servers | .[0].addressString')" '192.168.77.78'
assert_eq "$(resolvectl --json=short | jq -rc '.[] | select(.delegate == "testcase") | .servers | .[1].addressString')" '192.168.77.79'
assert_eq "$(resolvectl --json=short | jq -rc '.[] | select(.delegate == "testcase") | .searchDomains | .[0].name')" 'exercise.test'
# Now that we installed the delegation the resolution should fail, because nothing is listening on that IP address