Package: dhcpcd5 Version: 7.1.0-2 Severity: normal Tags: ipv6 patch Dear Maintainer,
*** Reporter, please consider answering these questions, where appropriate *** * What led up to the situation? Set up multiple LANs with prefix delegation from WAN using ia_pd with an explicit list of interaces to delegate to. * What exactly did you do (or not do) that was effective (or ineffective)? Initial dhcp startup works fine, prefixes get delegated as expected. When the WAN link is lost the delegated addresses are removed as expected. After the link recovers the delegation does not work properly. * What was the outcome of this action? Right after link restoration the first LAN interface gets an address from the prefix assigned. With each renew another interface get an address assigned. * What outcome did you expect instead? All interfaces should get a delegated address assigned immediately. Root cause: In dhcp6_delegate_prefix is a loop over all interfaces in the context. As the delegated prefixes are assigned the interface order is changing (e.g., due to DAD being executed for the newly assigned prefix which changes interface priority). This causes the loop to skip other LAN interfaces. Solution that worked for me: Replace the loop with a "_SAFE" variant. This will likely process interfaces twice but this has no negative side effects. The binary is modified on the system as I have the patched binary running successfully. -- System Information: Debian Release: 11.5 APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable') Architecture: armhf (armv7l) Kernel: Linux 5.10.153-clearfog (SMP w/2 CPU threads) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages dhcpcd5 depends on: ii libc6 2.31-13+deb11u5 ii lsb-base 11.1.0 Versions of packages dhcpcd5 recommends: ii openresolv [resolvconf] 3.12.0-1 Versions of packages dhcpcd5 suggests: pn dhcpcd-gtk <none> -- Configuration Files: /etc/dhcpcd.conf changed [not included] -- no debconf information -- debsums errors found: debsums: changed file /usr/sbin/dhcpcd (from dhcpcd5 package)
--- dhcp6.c.orig 2022-11-08 22:14:22.153113692 -0500 +++ dhcp6.c 2022-11-08 23:37:03.903831263 -0500 @@ -2751,7 +2751,7 @@ size_t i, j, k; struct if_ia *ia; struct if_sla *sla; - struct interface *ifd; + struct interface *ifd, *ifdn; bool carrier_warned; ifo = ifp->options; @@ -2762,7 +2762,7 @@ ap->flags &= ~IPV6_AF_DELEGATEDLOG; } - TAILQ_FOREACH(ifd, ifp->ctx->ifaces, next) { + TAILQ_FOREACH_SAFE(ifd, ifp->ctx->ifaces, next, ifdn) { if (!ifd->active) continue; k = 0;