[BUG] `ipconfigDHCP_FALL_BACK_AUTO_IP` does not perform ARP clash detection

Open
#1,341 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
c

Research direction

Start in the link-local fallback path: prvPrepareLinkLayerIPLookUp chooses the candidate address, and vARPSendGratuitous is the ARP claim that is sent before the network stack is up. Check whether the claim is actually transmitted during IP acquisition, and why it is not. Done means a clashing address is detected during acquisition, a new link-local address is chosen, and the device keeps it; reproduce with the clash patch described in the report on a board with no DHCP server.

Written by the indexing model from the issue text.

Description

bug

Describe the bug
When automatically getting a link local IP, the stack is supposed to detect if somebody is already using the randomly chosen address.

It does this by issuing a gratuitous ARP claim, and seeing if it gets responded to.

The code attempts to do this, but it doesn't work. Because the network stack is not up yet, vARPSendGratuitous does not lead to any message being sent. Therefore there's no reply, and no clash is detected. The network stack comes up on a conflicted address.

Target
STM32H7
Arm Cortex M
GCC 15.2

To Reproduce

In order to reliably get a clash on the randomly chosen link local address, you'll need to modify prvPrepareLinkLayerIPLookUp to generate a clashing address on purpose.

I used the following patch:

void prvPrepareLinkLayerIPLookUp( NetworkEndPoint_t * pxEndPoint )
{
    uint8_t ucLinkLayerIPAddress[ 2 ];
    uint32_t ulNumbers[ 2 ];

    static uint32_t generate_n_clashes = 1;

    /* After DHCP has failed to answer, prepare everything to start
        * trying-out LinkLayer IP-addresses, using the random method. */
    EP_DHCPData.xDHCPTxTime = xTaskGetTickCount();

    ( void ) xApplicationGetRandomNumber( &( ulNumbers[ 0 ] ) );
    ( void ) xApplicationGetRandomNumber( &( ulNumbers[ 1 ] ) );
    ucLinkLayerIPAddress[ 0 ] = ( uint8_t ) ( 1 + ( ulNumbers[ 0 ] % 0xFDU ) ); /* get value 1..254 for IP-address 3rd byte of IP address to try. */
    ucLinkLayerIPAddress[ 1 ] = ( uint8_t ) ( 1 + ( ulNumbers[ 1 ] % 0xFDU ) ); /* get value 1..254 for IP-address 4th byte of IP address to try. */

    if (generate_n_clashes) {
        ucLinkLayerIPAddress[0] = 131;
        ucLinkLayerIPAddress[1] = 160;
        generate_n_clashes--;
    }
    /* rest snipped */
}
  • Connect to a network with no DHCP server, and make sure ipconfigDHCP_FALL_BACK_AUTO_IP is set
  • Wait for the DHCP attempts to timeout, then watch for ARP resolution

Expected behavior

  • The device should sent an ARP announcement for the clashing IP
  • The clashing host will send a duplicate IP detected ARP message
  • The device should pick a new link local IP, and send an ARP announcement for it
  • This IP should stick

Current behaviour

  • The device sends no ARP announcement during IP acquisition
  • Once the stack is "up", ARP announcements start going out for the clashed address
  • Despite the clashing host sending duplicate IP detected ARP messages, the device never changes IP
Dominant language
C
Stars
215
Forks
222
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from FreeRTOS/FreeRTOS-Plus-TCP

All issues in FreeRTOS/FreeRTOS-Plus-TCP

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.