Enable Fallback DNS server when server is created
cover Enable Fallback DNS server when server is created
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(-)
Signature · 1 line
2.25.1
PATCH 1/1 dnsproxy: enable Fallback DNS server when created if needed
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(-)
src/dnsproxy.c +19 -9
@@ -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,
Signature · 1 line
2.25.1
Hi Christophe,
Quoted 9 lines · 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.
Quoted 7 lines
They are not enabled because when
dnsproxy_default_changedis called, DNS servers are not created yet andenable_fallbackdoes not do anything. Then when servers are created increate_server(dnsproxy.c), they are not enabled because they are fallback servers.I made a patch to change the behavior in
create_serverand enable Fallback server if there is no other DNS servers.
Patch applied. Thanks!
Daniel