Skip to content

autoip: Choose next address after rate limit#59

Merged
yarrick merged 1 commit intolwip-tcpip:masterfrom
david-cermak:fix/autoip_ratelimit_addrinc
Aug 3, 2025
Merged

autoip: Choose next address after rate limit#59
yarrick merged 1 commit intolwip-tcpip:masterfrom
david-cermak:fix/autoip_ratelimit_addrinc

Conversation

@david-cermak
Copy link
Contributor

Fix: AutoIP selects a new address after rate limiting

Issue

After hitting MAX_CONFLICTS (10), AutoIP enters rate limiting mode for 60 seconds. After this timeout, it tries to acquire an IP address again, but it incorrectly reuses the same address that previously had conflicts.

This causes devices to fail Bonjour Conformance Tests for rate limiting, as they should try different addresses after timeouts.

Root Cause

In lwIP pre-2.2.0, address conflict detection was handled directly in autoip.c, where tried_llipaddr was incremented in autoip_restart():

lwip/src/core/ipv4/autoip.c

Lines 125 to 130 in 6ca936f

autoip_restart(struct netif *netif)
{
struct autoip *autoip = netif_autoip_data(netif);
autoip->tried_llipaddr++;
autoip_start(netif);
}

When ACD was extracted into a separate module in 2.2.0, this increment was missing for the rate-limiting path in the callback handler. The ACD_DECLINE case cleared the address but didn't increment the counter.

Fix

The patch adds one line to increment the tried_llipaddr counter in the ACD_DECLINE case, ensuring that after rate limiting, a new address is tried rather than the same one.

Testing

With this patch, devices pass the Bonjour Conformance Test for rate limiting.

@@ -224,8 +224,9 @@ autoip_conflict_callback(struct netif *netif, acd_callback_enum_t state)
break;
case ACD_DECLINE:
/* "delete" conflicting address so a new one will be selected in
Copy link
Member

Choose a reason for hiding this comment

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

This comment says _start will select a new address. Can we make it do that instead? If we increment it every time in autoip_start it should also pass the tests right?

Copy link
Member

Choose a reason for hiding this comment

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

Or alternatively, edit the comment to match the new way of handling it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestions.
I would prefer to update the comment, if it's okay.

If we increment it every time in autoip_start it should also pass the tests right?

Yes, it would probably pass the BCT, but might have some side effects, e.g. if we want to try the same address (like link-up / down), or at the startup. So we would need some way to pass the information about from ACD to AUTOIP.
(also this is the old behavior -- prior to v2.2.0)

@david-cermak david-cermak force-pushed the fix/autoip_ratelimit_addrinc branch from 2cd29d1 to 84dcc2c Compare May 29, 2025 15:32
AutoIP now selects a new address after rate limit timeout,
AutoIP tries a new address by incrementing the tried_llipaddr counter
in the ACD_DECLINE case of the callback.

In lwIP pre-2.2.0, address conflict detection was handled within autoip.c, and
the incrementing happened in autoip_restart() (line 150). When ACD was
extracted into a separate module in 2.2.0, this increment was missing for the
rate-limiting path.

Without this change, devices continuously retry the same IP address after rate
limiting, causing them to fail Bonjour Conformance Tests.
@david-cermak david-cermak force-pushed the fix/autoip_ratelimit_addrinc branch from 84dcc2c to 98647c8 Compare May 29, 2025 16:28
@yarrick yarrick merged commit e7ab7e0 into lwip-tcpip:master Aug 3, 2025
1 of 4 checks passed
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.

2 participants