[PATCH 4/5] dns: Use compile time defined DNS for listener
Jussi Laakkonen <[email protected]> Fri, 8 May 2026 19:05:38 +0300
| Newsgroups | dev.linux.lists.connman |
|---|---|
| Message-ID | <[email protected]> |
Drop use of hardcoded DNSs with listener and use ones defined in
compile time to fully work with systemd-resolved.
---
src/shared/dns.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/shared/dns.c b/src/shared/dns.c
index 930234fc..8f806536 100644
--- a/src/shared/dns.c
+++ b/src/shared/dns.c
@@ -2336,11 +2336,20 @@ static int create_listener(struct dns_listener_data *ifdata,
index = connman_inet_ifindex("lo");
if (ifdata->index == index && !ifdata->lo_exclude) {
+#ifdef SYSTEMD_RESOLVED_DNS_BACKEND
+ if (((err & IPv6_FAILED) != IPv6_FAILED) ||
+ ((err & IPv4_FAILED) != IPv4_FAILED))
+ __connman_resolvfile_append(index, NULL,
+ DNS_BACKEND_V4);
+#else
if ((err & IPv6_FAILED) != IPv6_FAILED)
- __connman_resolvfile_append(index, NULL, "::1");
+ __connman_resolvfile_append(index, NULL,
+ DNS_BACKEND_V6);
if ((err & IPv4_FAILED) != IPv4_FAILED)
- __connman_resolvfile_append(index, NULL, "127.0.0.1");
+ __connman_resolvfile_append(index, NULL,
+ DNS_BACKEND_V4);
+#endif
}
return 0;
@@ -2351,8 +2360,13 @@ static void destroy_listener(struct dns_listener_data *ifdata)
int index = connman_inet_ifindex("lo");
if (ifdata->index == index && !ifdata->lo_exclude) {
- __connman_resolvfile_remove(index, NULL, "127.0.0.1");
- __connman_resolvfile_remove(index, NULL, "::1");
+
+ __connman_resolvfile_remove(index, NULL, DNS_BACKEND_V4);
+
+// With internal DNS this is defined, with systemd-resolved it is not.
+#ifndef SYSTEMD_RESOLVED_DNS_BACKEND
+ __connman_resolvfile_remove(index, NULL, DNS_BACKEND_V6);
+#endif
}
for (GSList *list = request_list; list; list = list->next) {
--
2.47.3