mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-13 09:54:39 +08:00

In summary, this patch aims to resolve bugs #47923 and #48162, by decoupling address autoconfiguration from the on-link prefix list, since those are not related. Important necessary changes are needed to meet this goal, ultimately bringing the lwIP ND6 implementation closer to compliance with RFC 4862. The main changes are: 1. support for address lifetimes, and, 2. addition of a new DUPLICATED address state. The decoupling implies that the prefix list can no longer be used to maintain state for address autoconfiguration. Most importantly, the lifetime of each address, which was previously derived from the prefix slot's lifetime, must now be associated with the address itself. This patch implements address lifetime tracking, maintaining both a valid and a preferred lifetime for each address, along with the corresponding address state changes (e.g., between PREFERRED and DEPRECATED), all as required by RFC 4862. The support for address lifetimes can be enabled with a new LWIP_IPV6_ADDRESS_LIFETIMES setting in lwipopts.h. It is required for autoconfiguration and enabled by default if autoconfiguration is enabled as well, but it may also be enabled separately, so as to allow application-controlled lifetime management (e.g., if autoconfiguration is implemented in a separate application). A special valid-lifetime of zero is used to denote a static address--that is, an address that was configured manually, that does not have lifetimes, and that should be left alone by the autoconfiguration functionality. Addresses assigned without setting a lifetime are deemed static, thus preserving compatibility with existing lwIP-based applications in this respect. Similarly, the decoupling implies that the prefix list can no longer be used to remember cases of address duplication. Previously, the detection of a duplicated address would simply result in removal of the address altogether. Instead, this patch introduces a new state "DUPLICATED", indicating that the address, while technically still present, has been found to conflict with other node addresses, and no attempt should be made to produce an autoconfiguration address for that prefix. Manually added addresses, including the link-local address, once set to DUPLICATED, will remain in that state until manual intervention. Autoconfigured DUPLICATED addresses will expire according to their valid-lifetime, essentially preserving the current behavior but without the use of the prefix list. As a first attempt to approach compliance with RFC 4862 Sec. 5.4.5, if the link-local address is detected to be duplicated, all derived addresses are marked duplicated as well, and no new addresses will be autoconfigured. More work is to be done for full compliance with that section, however. Together, those two main changes indeed do fully decouple address autoconfiguration from the on-link prefix list. Changes to the latter thus no longer affect the former, resolving bug #47923. Moreover, as a result, autoconfiguration can, and does, now also take place on advertised prefixes that do not have the on-link flag set, resolving bug #48162. The routing changes mentioned in the discussion of that bug are left to a separate patch, though.