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

Wi-Fi Combo Forum Discussions

rashc_2727106
Level 4
Level 4
10 likes received First like received First like given

We recently tracked down an annoying issue with DNS reliability when we updated our firmware to wiced SDK v6.1.

Our firmware uses ThreadX and NetX and our hardware is an STM32F4xx and the 4343W module. 

The issue originally presented as DNS working reliably at some of our labs and not working reliably or at all at other office sites.

Eventually we traced this to a bug that appears in DNS for v6.1 and is still there in the 6.2.x releases.

Specifically, with the 6.1 update,  the endian order of dns server addresses extracted and saved from DHCP responses changed inside WICED/network/NetX/WICED/wiced_network.c::wiced_ip_up() from host order to network order.   But the consumer of the DNS addresses inside libraries/protocols/DNS/dns.c::dns_client_hostname_lookup() did not change. So those addressesno longer matched the order expected from wiced_udp_send (used to query the DNS servers). So all queries to DNS servers specified by the DHCP payload were failing.

Why did DNS sort-of work at some sites?   Because the bug was partially masked by wiced code that was arbitrarily adding a hard-coded 8.8.8.8 (the google public dns a server) to the list of DNS servers.   BUT that fix only worked if the DHCP payload had not already filled the list. So if you connected to an AP that only supplied one DNS address, that DNS server would fail, but the hardcoded google address would work.

It's trivial to reproduce this failure for any wiced 6.1 or 6.2 that uses DNS (including their example apps and snips) by simply commenting out that 8.8.8.8 hardcode inside WICED/network/NetX/WICED/wiced_network.c::wiced_ip_up().  Here are those lines.

        /* Add Google DNS server (8.8.8.8) */

        memset( dns_ip_string, 8, 4 );

        SET_IPV4_ADDRESS( address, nx_dhcp_user_option_convert( dns_ip_string ) );

        dns_client_add_server_address( address );

@Cypress can someone please confirm and add this to your bug tracking for the next release?

10 Replies
rashc_2727106
Level 4
Level 4
10 likes received First like received First like given

D'oh - forgot to post our fix.

Which is simply to add an endian swap

ntohl(  dns_server_address_array.ip.v4 )

to the address before passing it to wiced_udp_send inside WICED/network/NetX/WICED/wiced_network.c::wiced_ip_up().

JeWo_3581161
Level 1
Level 1
First like given

Has anybody else been able to reproduce this? I'm unclear on where to apply this suggested patch.

0 Likes

Double - D'oh posted the wrong path for the fix.  Thanks for noticing that jeremywood

You need to reverse the address inside libraries\protocols\DNS\dns.c::dns_client_hostname_lookup()

More specifically (my changes in bold),

dns_client_hostname_lookup()

    ...

    for ( a = 0; a < dns_server_address_count; a++ ) {

         ...

          wiced_ip_address_t  reverse_order_addr;

         logIpV4Addr("Querying DNS server", (uint8_t*) &(dns_server_address_array.ip.v4) );

         reverse_order_addr = dns_server_address_array;

         reverse_order_addr.ip.v4 = ntohl(  dns_server_address_array.ip.v4 );

         if ( wiced_udp_send( &socket, &reverse_order_addr, DNS_PORT, packet ) != WICED_SUCCESS )

              ....

0 Likes
AxLi_1746341
Level 7
Level 7
10 comments on KBA 5 comments on KBA First comment on KBA

I comment out the code adding Google DNS server (8.8.8.8) in below files:

WICED/network/LwIP/WICED/wiced_network.c

WICED/network/NetX/WICED/wiced_network.c

WICED/network/NetX_Duo/WICED/wiced_network.c

Then test using snip.httpbin_org with different network stack build:

ThreadX-NetX: fail

ThreadX-NetX_Duo: work

FreeRTOS-LwIP: work

After apply your change and test again:

ThreadX-NetX: work

ThreadX-NetX_Duo: fail

FreeRTOS-LwIP: fail

So I think the BUG is real but your fix is incorrect.

It's a NetX specific issue, should not touch the common code in dns.c.

Thanks for the testing axel.lin_1746341

And you're certainly right - my fix was in the wrong place.


The fix should certainly be in inside WICED/network/NetX/WICED/wiced_network.c::wiced_ip_up() where the DNS server addresses should be swapped before storing in dns_server_address_array.

Once I'm free of deadlines I can post a patch.

mifo​ Does Cypress have plans to fix this?

0 Likes

I'm not sure.  Could you create a new SFDC case and pose this question to the applications team.

0 Likes

MichaelF_56 wrote:

I'm not sure.  Could you create a new SFDC case and pose this question to the applications team.

AFAICT, this bug is real and it's a kind of major bug because DNS won't work.

It has been reported quite long time, are you going to fix it soon?

0 Likes
AxLi_1746341
Level 7
Level 7
10 comments on KBA 5 comments on KBA First comment on KBA

This is fixed by sdk-6.4.

@AxLi_1746341 I have reviewed the wiced_network.c and dns.h files and find no changes.  What are the actual changes that were made?  Do you know?

0 Likes

MaVa_3369831 wrote:

@AxLi_1746341 I have reviewed the wiced_network.c and dns.h files and find no changes.  What are the actual changes that were made?  Do you know?

I don't know what actual changed, I simply test it.

The same test fails in sdk-6.2 but works in sdk-6.4.

0 Likes