Discussion:
[PATCH 0/5] Properly configure search domains for resolvers
p***@jolla.com
2015-10-28 23:29:27 UTC
Permalink
From: Pasi Sjöholm <***@jollamobile.com>

While debugging append_domain issue reported Vladimir Pavljuchenkov
I noticed that dnsproxy did not do any appended_domain-queries with
nameserver/resolvers configured by IPv6-infrastructure.

After these five small patches the things seems to be right
and all the resolvers are queried with configured search domains
(DNSSL, DHCPv4/6 and manually configured).

DHCPv4/6: siirappi.com
DNSSL: google.com

Before:

--cut--
IP 192.168.189.99.57437 > 192.168.189.1.53: 54758+ A? bz. (20)
IP 192.168.189.99.57437 > 192.168.189.1.53: 24311+ A? bz.siirappi.com. (33)
IP6 2001:470:28:241:2456:88bd:a205:211c.31364 > 2001:470:28:241::1.53: 25855+ A? bz. (20)
IP 192.168.189.1.53 > 192.168.189.99.57437: 54758 0/1/0 (85)
IP 192.168.189.1.53 > 192.168.189.99.57437: 24311 1/0/0 A 1.2.3.4 (49)
IP6 2001:470:28:241::1.53 > 2001:470:28:241:2456:88bd:a205:211c.31364: 25855 0/0/0 (20)
--cut--

After the patches:

--cut--
IP 192.168.189.99.57437 > 192.168.189.1.53: 62803+ A? bz. (20)
IP 192.168.189.99.57437 > 192.168.189.1.53: 56164+ A? bz.siirappi.com. (33)
IP 192.168.189.99.57437 > 192.168.189.1.53: 56164+ A? bz.google.com. (31)
IP6 2001:470:28:241:2456:88bd:a205:211c.33378 > 2001:470:28:241::1.53: 62803+ A? bz. (20)
IP6 2001:470:28:241:2456:88bd:a205:211c.33378 > 2001:470:28:241::1.53: 56164+ A? bz.siirappi.com. (33)
IP6 2001:470:28:241:2456:88bd:a205:211c.33378 > 2001:470:28:241::1.53: 56164+ A? bz.google.com. (31)
IP 192.168.189.1.53 > 192.168.189.99.57437: 62803 0/0/0 (20)
IP 192.168.189.1.53 > 192.168.189.99.57437: 56164 1/0/0 A 1.2.3.4 (49)
IP 192.168.189.1.53 > 192.168.189.99.57437: 56164 NXDomain 0/1/0 (81)
IP6 2001:470:28:241::1.53 > 2001:470:28:241:2456:88bd:a205:211c.33378: 62803 0/0/0 (20)
IP6 2001:470:28:241::1.53 > 2001:470:28:241:2456:88bd:a205:211c.33378: 56164 1/0/0 A 1.2.3.4 (49)
IP6 2001:470:28:241::1.53 > 2001:470:28:241:2456:88bd:a205:211c.33378: 56164 NXDomain 0/0/0 (31)
--cut--

Pasi Sjöholm (5):
dnsproxy: Rename append_domain() to append_or_remove_domain()
dnsproxy: Remove domains from dns server domain list when needed
service: Reconfigure search domains when nameservers have been
modified
resolver: Reorder call to __connman_service_nameserver_append()
resolver: Readd search domains back when resolvers are redone

src/dnsproxy.c | 25 ++++++++++++++++++++++---
src/resolver.c | 45 +++++++++++++++++++++++++++++++++------------
src/service.c | 12 ++++++------
3 files changed, 61 insertions(+), 21 deletions(-)
--
2.1.4
p***@jolla.com
2015-10-28 23:29:28 UTC
Permalink
From: Pasi Sjöholm <***@jollamobile.com>

A new append_domain()- and remove_domain()-functions which both
call append_or_remove_domain()-function by setting boolean append-
variable accordingly.

This enables a capability to remove domains from the dns-server's
domain list.
---
src/dnsproxy.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index c37eee9..1e8fcfb 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -2649,7 +2649,7 @@ static bool resolv(struct request_data *req,
return false;
}

-static void append_domain(int index, const char *domain)
+static void append_or_remove_domain(int index, const char *domain, bool append)
{
GSList *list;

@@ -2680,13 +2680,26 @@ static void append_domain(int index, const char *domain)
}
}

- if (!dom_found) {
+ if (!dom_found && append) {
data->domains =
g_list_append(data->domains, g_strdup(domain));
+ } else if (dom_found && !append) {
+ data->domains =
+ g_list_remove(data->domains, dom);
}
}
}

+static void append_domain(int index, const char *domain)
+{
+ append_or_remove_domain(index, domain, true);
+}
+
+static void remove_domain(int index, const char *domain)
+{
+ append_or_remove_domain(index, domain, false);
+}
+
static void flush_requests(struct server_data *server)
{
GSList *list;
--
2.1.4
Patrik Flykt
2015-11-02 12:44:37 UTC
Permalink
Post by p***@jolla.com
A new append_domain()- and remove_domain()-functions which both
call append_or_remove_domain()-function by setting boolean append-
variable accordingly.
This enables a capability to remove domains from the dns-server's
domain list.
---
src/dnsproxy.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index c37eee9..1e8fcfb 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -2649,7 +2649,7 @@ static bool resolv(struct request_data *req,
return false;
}
-static void append_domain(int index, const char *domain)
+static void append_or_remove_domain(int index, const char *domain, bool append)
{
GSList *list;
@@ -2680,13 +2680,26 @@ static void append_domain(int index, const char *domain)
}
}
- if (!dom_found) {
+ if (!dom_found && append) {
data->domains =
g_list_append(data->domains, g_strdup(domain));
+ } else if (dom_found && !append) {
+ data->domains =
+ g_list_remove(data->domains, dom);
}
}
}
+static void append_domain(int index, const char *domain)
+{
+ append_or_remove_domain(index, domain, true);
+}
+
+static void remove_domain(int index, const char *domain)
+{
+ append_or_remove_domain(index, domain, false);
+}
+
remove_domain() belongs to the next patch, as gcc says:

CC src/src_connmand-dnsproxy.o
src/dnsproxy.c:2698:13: error: ‘remove_domain’ defined but not used [-Werror=unused-function]
static void remove_domain(int index, const char *domain)
^

At the same time, could the append_or_remove_domain() function be simply
called update_domain() ?
Post by p***@jolla.com
static void flush_requests(struct server_data *server)
{
GSList *list;
Cheers,

Patrik

p***@jolla.com
2015-10-28 23:29:29 UTC
Permalink
From: Pasi Sjöholm <***@jollamobile.com>

Whenever the remove_entries() is called the __connman_dnsproxy_remove()
must act properly eg. with triggered solver_expire_cb() the expired DNSSL-records
from the IPv6 RA's must be removed.
---
src/dnsproxy.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index 1e8fcfb..a4682a7 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -2782,9 +2782,15 @@ int __connman_dnsproxy_remove(int index, const char *domain,
{
DBG("index %d server %s", index, server);

- if (!server)
+ if (!server && !domain)
return -EINVAL;

+ if (!server) {
+ remove_domain(index, domain);
+
+ return 0;
+ }
+
if (g_str_equal(server, "127.0.0.1"))
return -ENODEV;
--
2.1.4
p***@jolla.com
2015-10-28 23:29:30 UTC
Permalink
From: Pasi Sjöholm <***@jollamobile.com>

searchdomain_add_all()-function must be called when nameservers are
modified for the service as the IPv4- and IPv6-ipconfig won't
become connected at the same time and calling searchdomain_add_all()
only once when the service becomes ready-state is not enough.

Also nameserver-configuration coming from eg. IPv6 RA RDNSS
(__connman_service_nameserver_append()) must have search domains
applied to it.
---
src/service.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/service.c b/src/service.c
index e33284d..3fc5b60 100644
--- a/src/service.c
+++ b/src/service.c
@@ -134,6 +134,7 @@ static struct connman_ipconfig *create_ip4config(struct connman_service *service
static struct connman_ipconfig *create_ip6config(struct connman_service *service,
int index);

+static int searchdomain_add_all(struct connman_service *service);

struct find_data {
const char *path;
@@ -966,11 +967,7 @@ static int nameserver_add_all(struct connman_service *service,
service->nameservers_config[i]);
i++;
}
-
- return 0;
- }
-
- if (service->nameservers) {
+ } else if (service->nameservers) {
while (service->nameservers[i]) {
nameserver_add(service, type,
service->nameservers[i]);
@@ -978,6 +975,8 @@ static int nameserver_add_all(struct connman_service *service,
}
}

+ searchdomain_add_all(service);
+
return 0;
}

@@ -1121,6 +1120,8 @@ int __connman_service_nameserver_append(struct connman_service *service,
nameserver_add(service, CONNMAN_IPCONFIG_TYPE_ALL, nameserver);
}

+ searchdomain_add_all(service);
+
return 0;
}

@@ -5378,7 +5379,6 @@ static int service_indicate_state(struct connman_service *service)
g_get_current_time(&service->modified);
service_save(service);

- searchdomain_add_all(service);
dns_changed(service);
domain_changed(service);
proxy_changed(service);
--
2.1.4
p***@jolla.com
2015-10-28 23:29:31 UTC
Permalink
From: Pasi Sjöholm <***@jollamobile.com>

__connman_service_nameserver_append() must be called after the
resolver entry has been appended to entry_list and dnsproxy
because otherwise searchdomain_add_all()-call on service
will not add the search domain configuration to nameserver
configured through RDNSS.
---
src/resolver.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/resolver.c b/src/resolver.c
index 6a64938..53e9ebb 100644
--- a/src/resolver.c
+++ b/src/resolver.c
@@ -378,18 +378,6 @@ static int append_resolver(int index, const char *domain,

entry->timeout = g_timeout_add_seconds(interval,
resolver_refresh_cb, entry);
-
- /*
- * We update the service only for those nameservers
- * that are automagically added via netlink (lifetime > 0)
- */
- if (server && entry->index >= 0) {
- struct connman_service *service;
- service = __connman_service_lookup_from_index(entry->index);
- if (service)
- __connman_service_nameserver_append(service,
- server, true);
- }
}

if (entry->index >= 0 && entry->server)
@@ -402,6 +390,18 @@ static int append_resolver(int index, const char *domain,
else
__connman_resolvfile_append(entry->index, domain, server);

+ /*
+ * We update the service only for those nameservers
+ * that are automagically added via netlink (lifetime > 0)
+ */
+ if (server && entry->index >= 0 && lifetime) {
+ struct connman_service *service;
+ service = __connman_service_lookup_from_index(entry->index);
+ if (service)
+ __connman_service_nameserver_append(service,
+ server, true);
+ }
+
return 0;
}
--
2.1.4
p***@jolla.com
2015-10-28 23:29:32 UTC
Permalink
From: Pasi Sjöholm <***@jollamobile.com>

Redoing dns servers will remove the current list of search domains
from the servers/resolvers (eg. RDNSS configured ones) therefore they need
to be added back.
---
src/resolver.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/src/resolver.c b/src/resolver.c
index 53e9ebb..5c463be 100644
--- a/src/resolver.c
+++ b/src/resolver.c
@@ -600,6 +600,27 @@ int __connman_resolver_redo_servers(int index)
entry->server);
}

+ /*
+ * We want to re-add all search domains back to search
+ * domain lists as they just got removed for IPv6-servers (above).
+ * Removal of search domains is not necessary
+ * as there can be only one instance of each search domain
+ * in the each dns-servers search domain list.
+ */
+
+ for (list = entry_list; list; list = list->next) {
+ struct entry_data *entry = list->data;
+
+ if (entry->index != index)
+ continue;
+
+ if (entry->server)
+ continue;
+
+ __connman_dnsproxy_append(entry->index, entry->domain,
+ NULL);
+ }
+
return 0;
}
--
2.1.4
Loading...