Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No searching for end-points when responding to mDNS/LLMNR/NBNS #1064

Merged
merged 10 commits into from
Jan 9, 2024

Conversation

evpopov
Copy link
Contributor

@evpopov evpopov commented Dec 18, 2023

Description

When name queries (mDNS/LLMNR/NBNS) need to be responded to, the current code searches for an end-point to use when sending the response. This PR gets rid of this search and uses the end-point on which the original request was received. This removes the possibility of a malformed request causing responses to be sent on other interfaces.
A lot more details can be found in #1042

I am not sure if any test are being affected by this change.
I have also removed prvFindEndPointOnNetMask( NetworkBufferDescriptor_t * pxNetworkBuffer ) since it is no longer used. I also believe the whole premise of having a function that searches for and end-point to be used for a response is incorrect. Any response should be using the end-point of the original request, but this is just my opinion. Please let me know what you think and if you believe I should keep this function in the codebase even though it is no longer used.

Related Issue

#1042

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

Emil Popov added 2 commits December 18, 2023 09:12
…d during the reception of the query instead of searching for one.
@evpopov evpopov requested a review from a team as a code owner December 18, 2023 14:34
Copy link
Contributor

@htibosch htibosch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @evpopov

* @param[in] pxNetworkBuffer The Ethernet packet that was received.
* @return An end-point.
*/
static NetworkEndPoint_t * prvFindEndPointOnNetMask( NetworkBufferDescriptor_t * pxNetworkBuffer )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we already wrote in your issue #1042 I totally agree with this choice. And also I agree that the endpoint receiving a request should be used for the reply as well.
I already tested this PR and it looks good, both IPV4 and IPv6 connections, and for A and AAAA DNS requests.

n9wxu
n9wxu previously approved these changes Dec 20, 2023
ActoryOu
ActoryOu previously approved these changes Dec 21, 2023
@n9wxu
Copy link
Member

n9wxu commented Dec 21, 2023

Please take a look at the PR checks and correct the issues.

@htibosch
Copy link
Contributor

@n9wxu wrote:

Please take a look at the PR checks and correct the issues.

To @evpopov, adapted unit tests: FreeRTOS_DNS_Parser_utest.zip

@evpopov evpopov dismissed stale reviews from ActoryOu and n9wxu via 6ceff67 December 22, 2023 17:00
@evpopov
Copy link
Contributor Author

evpopov commented Dec 22, 2023

Thanks @htibosch !
I really appreciate you jumping in and helping with the updated unit test

@htibosch
Copy link
Contributor

htibosch commented Jan 9, 2024

I saw that the coverage was still no 100% and repaired that in these source files:

changes_coverage.zip

source\FreeRTOS_DNS_Parser.c
test\unit-test\FreeRTOS_DNS_Parser\FreeRTOS_DNS_Parser_utest.c

I had forgotten the new configASSERT().

I could also make this simplification:

-    pxIPHeader->ulSourceIPAddress = ( pxEndPoint != NULL ) ? pxEndPoint->ipv4_settings.ulIPAddress : 0U;
+    pxIPHeader->ulSourceIPAddress = pxEndPoint->ipv4_settings.ulIPAddress;

because pxEndPoint is proven to be not NULL.

@tony-josi-aws
Copy link
Member

/bot run formatting

@tony-josi-aws tony-josi-aws force-pushed the NoEndPointSearchOnNameQuery_PR branch from 39840e9 to 56c9f60 Compare January 9, 2024 09:04
@tony-josi-aws tony-josi-aws merged commit 15b2f81 into FreeRTOS:main Jan 9, 2024
10 checks passed
@evpopov evpopov deleted the NoEndPointSearchOnNameQuery_PR branch January 9, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants