dhcpv4: don't send zero IPv6-only preferred option
authorDavid Härdeman <[email protected]>
Tue, 9 Dec 2025 08:21:11 +0000 (09:21 +0100)
committerÁlvaro Fernández Rojas <[email protected]>
Tue, 9 Dec 2025 14:07:53 +0000 (15:07 +0100)
As noted in https://github.com/openwrt/openwrt/issues/21048, if the
ipv6_only_preferred option isn't set (or is set to zero), odhcpd will
still include the IPv6-Only Preferred option (with a zero value) in
DHCPv4 replies, while it should not return the option at all.

Closes: https://github.com/openwrt/openwrt/issues/21048
Signed-off-by: David Härdeman <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/341
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/dhcpv4.c

index 5073d97ae595a8b6f2fdf5ffea7a73b6b6b9c091..31ef1e5f3da8dd9722b25a6a96ef5ccb01d64975 100644 (file)
@@ -1306,7 +1306,8 @@ void dhcpv4_handle_msg(void *src_addr, void *data, size_t len,
                        break;
 
                case DHCPV4_OPT_IPV6_ONLY_PREFERRED:
-                       iov[IOV_IPV6_ONLY_PREF].iov_len = sizeof(reply_ipv6_only);
+                       if (iface->dhcpv4_v6only_wait)
+                               iov[IOV_IPV6_ONLY_PREF].iov_len = sizeof(reply_ipv6_only);
                        break;
 
                case DHCPV4_OPT_CAPTIVE_PORTAL: