-
Notifications
You must be signed in to change notification settings - Fork 206
Improves handling of IPv4 broadcast addresses. #1221
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
Improves handling of IPv4 broadcast addresses. #1221
Conversation
Add xIsIPv4Broadcast helper function that enumerates over all IPv4 endpoints and their corresponding broadcast addresses. Adds checks for the 255.255.255.255 address. Substitutes ipBROADCAST_IP_ADDRESS with FREERTOS_INADDR_BROADCAST to better match the rest of the world. Cleans up frame filtering a bit to ensure a frame's destination address is NOT matched against other endpoints than the one the frame entered through.
|
/bot run formatting |
source/FreeRTOS_IPv4.c
Outdated
| struct xNetworkEndPoint ** ppxEndPoint ) | ||
| { | ||
| BaseType_t xIsBroadcast; | ||
| uint32_t ulEndPointBroadcast; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Unused variable ulEndPointBroadcast
| uint16_t usProtocolBytes; /**< The total length of the protocol data. */ | ||
| }; | ||
|
|
||
| #define ipBROADCAST_IP_ADDRESS 0xffffffffU |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are few more references to ipBROADCAST_IP_ADDRESS in the code - STM32 network interfaces and UTs
|
Thanks @evpopov for this PR, I have added some minor comments. |
9955e6d to
7f7c4cc
Compare
Removes an unused variable Renames ipBROADCAST_IP_ADDRESS to FREERTOS_INADDR_BROADCAST in the unit tests and the STM32 network driver
7f7c4cc to
fcc0bde
Compare
|
Thanks for catching those @tony-josi-aws |
Description
The current code incorrectly assumes that broadcast addresses only end in x.x.x.255
When a frame enters the stack, all broadcast tests must be made against the 255.255.255.255 address and against the specific broadcast of the endpoint that the frame was assigned
When an ARP lookup is attempted, we need to check if the user is attempting to send a packet that may be considered a broadcast on any of our IPv4 endpoints. Current code was only calling an outgoing packet a "broadcast" is said packet ended in 0xFF.
This PR attempts to correct both of the above.
Additionally, I've taken the liberty to substitute ipBROADCAST_IP_ADDRESS with FREERTOS_INADDR_BROADCAST and put the new definition in a public header file. Here's my reasoning:
I have also probably broken a bunch of test cases with this and I'd really appreciate it if someone can help with fixing the old tests and maybe even add tests that verify the new changes. For example test that verifies 192.168.0.7 as a broadcast if the endpoint is 192.168.0.1/29, etc...
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.