mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-03 21:14:40 +08:00

As laid out in RFC 5942, the assumption that a dynamically assigned (SLAAC/DHCPv6) address implies an on-link subnet, is wrong. lwIP does currently make that assumption, routing packets according to local address subnets rather than the on-link prefix list. The result is that packets may not make it to their destination due to incorrect routing decisions. This patch changes the routing algorithms to be (more) compliant with RFC 5942, by implementing the following new routing policies: - all routing decisions check the on-link prefix list first, and select a default router for off-link routing only if there is no matching entry in the on-link prefix list; - dynamically assigned addresses (from address autoconfiguration) are considered /128 assignments, and thus, no routing decisions are taken based on matches against their (/64) subnet anymore; - more generally, all addresses that have a lifetime are considered dynamically assigned and thus of size /128, which is the required behavior for externally implemented SLAAC clients and DHCPv6; - statically assigned (i.e., manually configured) addresses are still considered /64 assignments, and thus, their associated subnet is considered for routing decisions, in order to behave as generally expected by end users and to retain backward compatibility; - the link-local address in IPv6 address slot #0 is considered static and thus has no lifetime and an implied /64 subnet, although link- local routing is currently always handled separately anyway. IPv6 source address selection is kept as is, as the subnet tests in the algorithm serve as poor man's longest-common-prefix equivalent there (RFC 6724 Sec. 5, Rule 8).