FreeRTOS / FreeRTOS-Plus-TCP

FreeRTOS-Plus-TCP library repository. +TCP files only. Submoduled into https://github.com/FreeRTOS/FreeRTOS and various other repos.
MIT License
146 stars 159 forks source link

DNS local lookups using mDNS repaired #1118

Closed htibosch closed 3 months ago

htibosch commented 6 months ago

Description

Somewhere along the way, active lookups using mDNS got broken.

When a peer answers an mDNS a lookup, in its answer, it will not repeat the questions that were asked by the client.

Test Steps

I did 3 kinds of lookups, each of them in 4 different ways: A normal DNS lookup A mDNS lookup of laptop-hp.local An LLMNR lookup of laptop-hp

I repeated each lookup by either asking for A or for AAAA records. Also I would either use IPv4 or IPv6 to contact the peer/server, setting xDNS_IP_Preference.

Here are the results of of mDNS/LLMNR tests:

DNS_tests.zip

Without the reparation, mDNS would not succeed.

Checklist:

Related Issue

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

htibosch commented 6 months ago

/bot run uncrustify

tony-josi-aws commented 5 months ago

@htibosch

Without the reparation, mDNS would not succeed.

I tested the mDNS without the changes using ping (from a Windows PC):

C:\Users\tonyjosi>ping STM32F4.local

Pinging STM32F4.local [192.168.0.102] with 32 bytes of data:
Reply from 192.168.0.102: bytes=32 time=1ms TTL=64
Reply from 192.168.0.102: bytes=32 time=1ms TTL=64
Reply from 192.168.0.102: bytes=32 time=1ms TTL=64
Reply from 192.168.0.102: bytes=32 time=1ms TTL=64

Ping statistics for 192.168.0.102:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 1ms, Average = 1ms

and also with a DNS v4 query from another +TCP DUT. It seems to be working.

Wondering if the tests you performed were different.

htibosch commented 5 months ago

and also with a DNS v4 query from another +TCP DUT. It seems to be working.

Wondering if the tests you performed were different.

My tests were about a LLMNR or mDNS lookup lookup that originates from a DUT running FreeRTOS+TCP.

The biggest problem is this code in FreeRTOS_DNS_Parser.c:

if( xSet.usQuestions == 0U )
{
    /* The IP-stack will only accept DNS replies that have a copy
     * of the questions. */
    xReturn = pdFALSE;
    break;
}

As for mDNS it is normal that the questions are not repeated.

tony-josi-aws commented 4 months ago

@htibosch

Can you help fix the CI checks?

moninom1 commented 3 months ago

FreeRTOS_SetDNSIPPreference makes more sense, as now application can set it accordingly. We might have to update this API in the website as well. Thanks for the update.