Skip to content

Commit d574382

Browse files
committed
feat(lwip): Remove deprecated LWIP_DHCPS_ADD_DNS Kconfig option
1 parent f3dedf6 commit d574382

File tree

4 files changed

+67
-20
lines changed

4 files changed

+67
-20
lines changed

components/lwip/Kconfig

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -452,20 +452,6 @@ menu "LWIP"
452452
Enabling this option allows DHCP server to support temporary static ARP entries
453453
for DHCP Client. This will help the DHCP server to send the DHCP OFFER and DHCP ACK using IP unicast.
454454

455-
config LWIP_DHCPS_ADD_DNS
456-
bool "Always add DNS option in DHCP responses"
457-
default y
458-
depends on LWIP_DHCPS
459-
help
460-
This allows the DNS option to be optional in the DHCP offers,
461-
depending on the server's runtime configuration.
462-
When enabled, the DHCP server will always add the DNS option to DHCP responses.
463-
If a DNS server is not explicitly configured, the server's IP address will be used
464-
as the fallback for the DNS option.
465-
When disabled, the DHCP server will only include the DNS option in responses
466-
if a DNS server has been explicitly configured.
467-
This option will be removed in IDF v6.x
468-
469455
endmenu # DHCPS
470456

471457
menuconfig LWIP_AUTOIP

components/lwip/apps/dhcpserver/dhcpserver.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,27 +468,32 @@ static u8_t *add_offer_options(dhcps_t *dhcps, u8_t *optptr)
468468
}
469469
}
470470

471-
// In order of preference
472-
if (dhcps_dns_enabled(dhcps->dhcps_dns)) {
473-
uint8_t size = 4;
471+
// Add DNS option if either main or backup DNS is set
472+
if (dhcps_dns_enabled(dhcps->dhcps_dns) &&
473+
(dhcps->dns_server[DNS_TYPE_MAIN].addr || dhcps->dns_server[DNS_TYPE_BACKUP].addr)) {
474474

475+
uint8_t size = 0;
476+
477+
if (dhcps->dns_server[DNS_TYPE_MAIN].addr) {
478+
size += 4;
479+
}
475480
if (dhcps->dns_server[DNS_TYPE_BACKUP].addr) {
476481
size += 4;
477482
}
478483

479484
*optptr++ = DHCP_OPTION_DNS_SERVER;
480485
*optptr++ = size;
481-
optptr = dhcps_option_ip(optptr, &dhcps->dns_server[DNS_TYPE_MAIN]);
482486

487+
if (dhcps->dns_server[DNS_TYPE_MAIN].addr) {
488+
optptr = dhcps_option_ip(optptr, &dhcps->dns_server[DNS_TYPE_MAIN]);
489+
}
483490
if (dhcps->dns_server[DNS_TYPE_BACKUP].addr) {
484491
optptr = dhcps_option_ip(optptr, &dhcps->dns_server[DNS_TYPE_BACKUP]);
485492
}
486-
#ifdef CONFIG_LWIP_DHCPS_ADD_DNS
487493
} else {
488494
*optptr++ = DHCP_OPTION_DNS_SERVER;
489495
*optptr++ = 4;
490496
optptr = dhcps_option_ip(optptr, &ipadd);
491-
#endif /* CONFIG_LWIP_DHCPS_ADD_DNS */
492497
}
493498

494499
ip4_addr_t broadcast_addr = { .addr = (ipadd.addr & dhcps->dhcps_mask.addr) | ~dhcps->dhcps_mask.addr };

docs/en/migration-guides/release-6.x/6.0/networking.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,31 @@ Alternative (find with predicate):
108108
if (target) {
109109
// use "target"
110110
}
111+
112+
113+
DHCP Server DNS Option Behavior
114+
-------------------------------
115+
116+
The ``LWIP_DHCPS_ADD_DNS`` macro has been removed.
117+
118+
Previously, when running a DHCP server on SoftAP, if no DNS offer option was set, the server IP address was automatically advertised as the DNS server.
119+
120+
**Current behavior:**
121+
122+
From this release onward, the DHCP server includes DNS information in its offers only when explicitly configured using :cpp:func:`esp_netif_dhcps_option` with the ``ESP_NETIF_DOMAIN_NAME_SERVER`` option. In that case, the currently configured main and/or backup DNS addresses for the SoftAP interface are sent to clients.
123+
124+
If the option is not enabled, the DHCP server's own IP address is sent as the DNS server, which preserves the previous default behavior.
125+
126+
**Migration:**
127+
128+
If applications rely on custom DNS settings, developers should:
129+
130+
1. Enable the DHCP server to include DNS information in its offers using :cpp:func:`esp_netif_dhcps_option` with the ``ESP_NETIF_DOMAIN_NAME_SERVER`` option.
131+
2. Configure one or more DNS server addresses for the SoftAP interface using :cpp:func:`esp_netif_set_dns_info`.
132+
3. If no DNS information should be sent at all, configure :cpp:func:`esp_netif_dhcps_option` but set the DNS server address to ``0.0.0.0`` using :cpp:func:`esp_netif_set_dns_info`.
133+
134+
This allows developers to:
135+
136+
- replicate the old behavior (advertising the SoftAP IP),
137+
- provide custom DNS servers (for example, public resolvers), or
138+
- suppress DNS information entirely by setting the DNS server to ``0.0.0.0``.

docs/zh_CN/migration-guides/release-6.x/6.0/networking.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,31 @@ ESP-NETIF
108108
if (target) {
109109
// 使用 "target"
110110
}
111+
112+
113+
DHCP 服务器 DNS 选项行为
114+
-------------------------
115+
116+
``LWIP_DHCPS_ADD_DNS`` 宏已被移除。
117+
118+
在此之前,在 SoftAP 上运行 DHCP 服务器时,如果没有设置 DNS 选项,则服务器的 IP 地址会被自动公布为 DNS 服务器。
119+
120+
**当前行为:**
121+
122+
从本版本开始,DHCP 服务器只有在显式配置了 :cpp:func:`esp_netif_dhcps_option` 并启用了 ``ESP_NETIF_DOMAIN_NAME_SERVER`` 选项时,才会在 DHCP offer 报文中包含 DNS 信息。此时,SoftAP 接口当前配置的主 DNS 和/或备用 DNS 地址将被发送给客户端。
123+
124+
如果没有启用该选项,DHCP 服务器会将自己的 IP 地址作为 DNS 服务器发送给客户端,从而与之前的默认行为保持一致。
125+
126+
**迁移说明:**
127+
128+
如果应用程序依赖自定义 DNS 设置,开发者应:
129+
130+
1. 使用 :cpp:func:`esp_netif_dhcps_option` 并启用 ``ESP_NETIF_DOMAIN_NAME_SERVER`` 选项,让 DHCP 服务器在 offer 报文中包含 DNS 信息。
131+
2. 使用 :cpp:func:`esp_netif_set_dns_info` 为 SoftAP 接口配置一个或多个 DNS 服务器地址。
132+
3. 若需完全禁止发送 DNS 信息,仍需配置 :cpp:func:`esp_netif_dhcps_option`,但应通过 :cpp:func:`esp_netif_set_dns_info` 将 DNS 服务器地址设置为 ``0.0.0.0``。
133+
134+
这样开发者可以:
135+
136+
- 复现旧的行为(通告 SoftAP IP),
137+
- 提供自定义的 DNS 服务器(例如公共解析器),
138+
- 通过将 DNS 地址设置为 ``0.0.0.0`` 来完全禁止 DNS 信息通告。

0 commit comments

Comments
 (0)