* [PATCH 0/1] Enable Fallback DNS server when server is created
@ 2022-10-11 9:56 Christophe Ronco
2022-10-11 9:56 ` [PATCH 1/1] dnsproxy: enable Fallback DNS server when created if needed Christophe Ronco
2022-10-24 6:52 ` [PATCH 0/1] Enable Fallback DNS server when server is created Daniel Wagner
0 siblings, 2 replies; 3+ messages in thread
From: Christophe Ronco @ 2022-10-11 9:56 UTC (permalink / raw)
To: connman; +Cc: Christophe Ronco
I have a DHCP server that do not send DNS servers along with IP address.
I use the FallbackNameservers option in main.conf to handle this case.
After a board reboot or a connman restart, Fallback DNS servers are correctly
displayed in service properties but DNS requests still fail.
If I disconnect and reconnect the service, DNS requests are OK.
DNS requests fail because Fallback servers are not enabled.
They are not enabled because when dnsproxy_default_changed is called, DNS
servers are not created yet and enable_fallback does not do anything.
Then when servers are created in create_server (dnsproxy.c), they are not
enabled because they are fallback servers.
I made a patch to change the behavior in create_server and enable Fallback
server if there is no other DNS servers.
Best Regards,
Christophe Ronco
Christophe Ronco (1):
dnsproxy: enable Fallback DNS server when created if needed
src/dnsproxy.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/1] dnsproxy: enable Fallback DNS server when created if needed
2022-10-11 9:56 [PATCH 0/1] Enable Fallback DNS server when server is created Christophe Ronco
@ 2022-10-11 9:56 ` Christophe Ronco
2022-10-24 6:52 ` [PATCH 0/1] Enable Fallback DNS server when server is created Daniel Wagner
1 sibling, 0 replies; 3+ messages in thread
From: Christophe Ronco @ 2022-10-11 9:56 UTC (permalink / raw)
To: connman; +Cc: Christophe Ronco
If there is no default DNS server when a fallback DNS server is created,
enable it.
---
src/dnsproxy.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index 22730047..a810b676 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -2586,6 +2586,20 @@ static void enable_fallback(bool enable)
}
}
+static unsigned int get_enabled_server_number(void)
+{
+ GSList *list;
+ unsigned int result = 0;
+
+ for (list = server_list; list; list = list->next) {
+ struct server_data *data = list->data;
+
+ if (data->index != -1 && data->enabled == true)
+ result++;
+ }
+ return result;
+}
+
static struct server_data *create_server(int index,
const char *domain, const char *server,
int protocol)
@@ -2674,6 +2688,9 @@ static struct server_data *create_server(int index,
DBG("Adding DNS server %s", data->server);
enable_fallback(false);
+ } else if (data->index == -1 && get_enabled_server_number() == 0) {
+ data->enabled = true;
+ DBG("Adding fallback DNS server %s", data->server);
}
server_list = g_slist_append(server_list, data);
@@ -2834,7 +2851,6 @@ int __connman_dnsproxy_append(int index, const char *domain,
static void remove_server(int index, const char *server, int protocol)
{
struct server_data *data;
- GSList *list;
data = find_server(index, server, protocol);
if (!data)
@@ -2842,14 +2858,8 @@ static void remove_server(int index, const char *server, int protocol)
destroy_server(data);
- for (list = server_list; list; list = list->next) {
- data = list->data;
-
- if (data->index != -1 && data->enabled == true)
- return;
- }
-
- enable_fallback(true);
+ if (get_enabled_server_number() == 0)
+ enable_fallback(true);
}
int __connman_dnsproxy_remove(int index, const char *domain,
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 0/1] Enable Fallback DNS server when server is created
2022-10-11 9:56 [PATCH 0/1] Enable Fallback DNS server when server is created Christophe Ronco
2022-10-11 9:56 ` [PATCH 1/1] dnsproxy: enable Fallback DNS server when created if needed Christophe Ronco
@ 2022-10-24 6:52 ` Daniel Wagner
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Wagner @ 2022-10-24 6:52 UTC (permalink / raw)
To: Christophe Ronco; +Cc: connman
Hi Christophe,
On Tue, Oct 11, 2022 at 11:56:40AM +0200, Christophe Ronco wrote:
> I have a DHCP server that do not send DNS servers along with IP address.
> I use the FallbackNameservers option in main.conf to handle this case.
>
> After a board reboot or a connman restart, Fallback DNS servers are correctly
> displayed in service properties but DNS requests still fail.
> If I disconnect and reconnect the service, DNS requests are OK.
>
> DNS requests fail because Fallback servers are not enabled.
>
> They are not enabled because when dnsproxy_default_changed is called, DNS
> servers are not created yet and enable_fallback does not do anything.
> Then when servers are created in create_server (dnsproxy.c), they are not
> enabled because they are fallback servers.
>
> I made a patch to change the behavior in create_server and enable Fallback
> server if there is no other DNS servers.
Patch applied. Thanks!
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-24 6:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-11 9:56 [PATCH 0/1] Enable Fallback DNS server when server is created Christophe Ronco
2022-10-11 9:56 ` [PATCH 1/1] dnsproxy: enable Fallback DNS server when created if needed Christophe Ronco
2022-10-24 6:52 ` [PATCH 0/1] Enable Fallback DNS server when server is created Daniel Wagner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).