After a long time of debugging, I think I found the root cause of the hang.
The bug has been firstly introduced by the patch[1], see [2] for details. The patch aimed to solve the multi-ip-addr-per-interface issue, but mistakely introduced another issue. It mistakely calls getifaddrs() in the "while (next_iface(&info, &err, &ifaces))" loop. As we reproduced above, there are 2500 ip addresses in the system, which will cause the loop runs 2500 x 2500 times, and totally calls getifaddrs() 2500 times too. The getifaddrs() is not free, it allocates memories which need to call freeifaddrs() to free them. But the patch[1] does not do that, causing the dhclient's memory increases very fast, like a memory leak. To fix the BUG, I propose a patch (the attachment), which reverts the patch[1] and append a tiny fix. The fix is pretty simple and already exists in the source code of another next_iface() routine. It just trims the "eth0:1" to "eth0" in the next_iface() routine, and returns the "eth0" to the caller, no need to loop 2500 times for each address. After the fix, the dhclient hang issue disappears. [1] https://launchpadlibrarian.net/66470806/dhcpd.workaround.patch [2] https://bugs.launchpad.net/eucalyptus/+bug/717166 ** Patch added: "dhclient-fix-hang.patch" https://bugs.launchpad.net/ubuntu/+source/isc-dhcp/+bug/2109303/+attachment/5874217/+files/dhclient-fix-hang.patch -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2109303 Title: dhclient hang when tons of ip addresses exist To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/isc-dhcp/+bug/2109303/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
