Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Level 5
Level 5
10 sign-ins 50 questions asked 10 solutions authored

I ran into a scenario where a device pulled two DNS server address on the initial wiced_ip_up called after power up from some rouge device on our test network. Eventually the device pulled a valid DHCP address but I found that wiced_hostname_lookup was failing. After reviewing wireless captures, i found the DNS request was being sent to the rouge addresses that did not match our network IP range. I also noticed that the DNS addresses were not updated after a DHCP renewal.

Looking at the WICED implementation for DNS , the server addresses are only set when wiced_ip_up is ran but LWIP caches the latest DNS addresses from DHCP renews. In order to prevent the above issue, or handle DNS servers being updated on the Network controller, i need a way to periodically sync the WICED DNS library's server address (dns_server_address_array) to the cached LWIP array with dns_getserver.

1. Is this considered a bug in WICED?

2. What would the best approach be? Should I call dns_getserver periodically and update dns_server_address_array? Is there any downside such as a multithreading issue? At first i thought about a LWIP callback but the IP changed callback from LWIP DHCP library is only called when the ip changes, so a renewal will not trigger it if the device address did not change.

3 Replies
250 sign-ins 250 replies posted 100 solutions authored


On which device is this issue being faced and what is the version of WICED that is being used?
Also could you share your project so that we could look into it?



SDK 6.2.1 with LWIP/FreeRTOS

It is simple as in libraries/protocols/dns.c, the hostname look up uses a static array called dns_server_address_array.

This array is set by a public function called dns_client_add_server_address

dns_client_add_server_address is only called from wiced_ip_up, found in wiced_network.c.

In the background, DHCP process is running in LWIP and storing updates from DHCP renews/ACKS through a LWIP helper function called dns_setserver, which stores the addresses into a static array called dns_servers, which is in LwIP/Ver2.0.3/src/core/dns.c. There is no noticeable link between LWIP's DNS library and the WICED DNS library, so the WICED DNS library has no knowledge if someone updated DNS settings in the DHCP server.

With the current configuration in order to get an updated DNS list in WICED, either the client has to bring the ip connection down with wiced_ip_down, or the wireless link has to go down.

I do not mind attempting to sync the LWIP dns_servers array to the WICED dns_server_address_array but I want to make sure there are no known multi-threading issues since LWIP is very strict on accessing the network thread from outside threads.



Is it possible for you to use a public DNS server like Google instead of the one provided by DHCP client?

If you need to use LwIP DHCP Clinet, you can try to sync LwIP dns_servers array to wiced_dns_server array just like you have mentioned. I don't think it should be an issue since the dns_getserver api is a callback style API from LwIP but then again this has not been tested from our side.