autoip: Choose next address after rate limit#59
Conversation
src/core/ipv4/autoip.c
Outdated
| @@ -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 | |||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Or alternatively, edit the comment to match the new way of handling it.
There was a problem hiding this comment.
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)
2cd29d1 to
84dcc2c
Compare
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.
84dcc2c to
98647c8
Compare
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_llipaddrwas incremented inautoip_restart():lwip/src/core/ipv4/autoip.c
Lines 125 to 130 in 6ca936f
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_DECLINEcase cleared the address but didn't increment the counter.Fix
The patch adds one line to increment the
tried_llipaddrcounter in theACD_DECLINEcase, 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.