Bug #16170
openIncorrect logic for detection of DNS server change in cases where the ISP does not provide search domains in DHCPv6 renewal
100%
Description
For 25.03-BETA-3 (25.03.b.20250427.2348) I applied commit https://github.com/pfsense/pfsense/commit/5c2c11b.patch by marcosm to reduce the system log noise from DHCPv6 renewal. However, I noticed the log kept filling up with renewal logging, so I added some debug printouts and found the root cause to why the patch does not work on my system and with my ISP. It is however nothing wrong in the commit itself, the problem is in the original code on which it relies.
These lines of code in /etc/rc.newwanipv6 does not give the expected result, $dns_changed is always true even though packet trace show no change in DNS servers received. Note, the line number corresponds to a file with the 5c2c11b applied.
176 /**
177 * @var bool Used for only action when the DNS information changes.
178 */
179 $dns_changed = true;
180 if (($new_domain_name_servers_received === false) && ($new_searchdomains_received === false)) {
181 $dns_changed = false;
182 }
My debug shows that $new_searchdomains_received is not defined at this point so the comparison with false fails. From the code I can see that new_searchdomains_received is only set if $new_domain_name is provided, something my ISP doesn't do for resedential lines.
A belt-and-braces approach to a fix could look something like this
--- rc.newwanipv6 2025-04-30 16:20:38.697476000 +0200
+++ rc.newwanipv6.new 2025-04-30 18:43:51.298711700 +0200
@@ -176,9 +176,9 @@
/**
* @var bool Used for only action when the DNS information changes.
*/
-$dns_changed = true;
-if (($new_domain_name_servers_received === false) && ($new_searchdomains_received === false)) {
- $dns_changed = false;
+$dns_changed = false;
+if ((isset($new_domain_name_servers_received) && ($new_domain_name_servers_received === true)) || (isset($new_searchdomains_received) && ($new_searchdomains_received === true))) {
+ $dns_changed = true;
}
I have successfully tested the patch on my system, where no search domain is provided, but YMMV.