dhcpv6: retry failed PD assignments on addrlist change
authorTian Hao <haotia@gmail.com>
Thu, 29 Aug 2019 17:08:17 +0000 (01:08 +0800)
committerHans Dedecker <dedeckeh@gmail.com>
Sun, 15 Sep 2019 17:35:55 +0000 (19:35 +0200)
Currently only assignments with prefixes larger than the largest
available one will be re-assigned on addrlist change events.
Previously failed PD assignments are not taken into account, and these
assignments will never have a chance to recover even if the address just
added to the interface could satisfy them.

Failed PD assignments could be very common when upstream prefix is obtained
from a PPPoE WAN, as ISPs tend to terminate the PPPoE session after a fixed
time period. Addresses on LAN could disappear and re-appear during WAN redial,
and all existing PD assignments to clients in LAN will become failed when the
addresses disappear. These assignments will not be recovered after WAN has been
brought back up, and clients in LAN could no longer receive any PD prefix.

This commit fixes the issue by including failed PD assignments in the
re-assign list on addrlist change event, so that newly added prefixes can be
put into use right after they are added to the interface.

Signed-off-by: Tian Hao <haotia@gmail.com>
(cherry picked from commit fd93e36727bc605f6f860759d7710a43bee5215d)

src/dhcpv6-ia.c

index 084683665cff3fd2de5915d2fbc1761c7b30029f..c8e616ff07373d147bba667413b678e503a18d03 100644 (file)
@@ -700,7 +700,7 @@ static void handle_addrlist_change(struct netevent_handler_info *info)
                                c->managed_size)
                        continue;
 
-               if (c->length < 128 && c->assigned >= border->assigned && c != border)
+               if (c->length < 128 && (c->assigned == 0 || c->assigned >= border->assigned) && c != border)
                        list_move(&c->head, &reassign);
                else if (c != border && (c->flags & OAF_BOUND))
                        apply_lease(iface, c, true);