Skip to content

Conversation

@nuttxs
Copy link
Contributor

@nuttxs nuttxs commented Nov 6, 2025

Summary

netlib/netlib_delipv4dnsaddr.c: add DNS deletion functionality, support deleting DNS servers by address or by index:

Modify the DHCP-client data structure to support multiple DNS addresses.
Enhance DHCP-option parsing to extract all DNS-server addresses.
Set all received DNS-server addresses.
Fix some example case compiler error.

netlib_del_ipv4dnsaddr()
netlib_del_ipv4dnsaddr_by_index()
netlib_del_ipv6dnsaddr()
netlib_del_ipv6dnsaddr_by_index()

Multi-DNS delete Call-Chain Implementation:
Application Layer: netlib_del_ipv4dnsaddr() / netlib_del_ipv6dnsaddr()
           ↓
Network Layer: dns_del_nameserver()
           ↓
Storage Layer: g_dns_servers[] array

Depend on PR#apache/nuttx#17284

Impact

New Feature/Change: Yes
User Impact: support delete the DNS server address by index or address
Build Impact:No new Kconfig options or build system changes.
Hardware Impact: No
Security: No
Compatibility: Backward-compatible; no breaking changes.

Testing

Test process example

// Add the first DNS server
netlib_set_ipv4dnsaddr(&dns1);

// Add the second DNS server
netlib_set_ipv4dnsaddr(&dns2);

// List all DNS servers
dns_foreach_nameserver(print_dns_callback, &count);

// Delete DNS server by index
netlib_del_ipv4dnsaddr_by_index(0);

// Delete DNS server by address
netlib_del_ipv4dnsaddr(&dns2);

xiaoxiang781216
xiaoxiang781216 previously approved these changes Nov 6, 2025
Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @nuttxs :-) Some issues:

  • Build errors, please fix.
  • PR and Commit topic does not match content, it also changes DHCP functionalities, please update (i.e. netutils/netlib: DHCP and DNS related updates. then bullet point changes already there).

@xiaoxiang781216
Copy link
Contributor

Thank you @nuttxs :-) Some issues:

* Build errors, please fix.

* PR and Commit topic does not match content, it also changes DHCP functionalities, please update (i.e. netutils/netlib: DHCP and DNS related updates. then bullet point changes already there).

apache/nuttx#17284 need be merged first.

@cederom
Copy link
Contributor

cederom commented Nov 6, 2025

Thanks @xiaoxiang781216 I missed the dependency on apache/nuttx#17284 sorry :-)

@nuttxs please update git commit message to:

netutils/netlib: DHCP and DNS related updates.

* new functionality: delete the DNS server address by index or address.
* Modify the DHCP-client data structure to support multiple DNS addresses.
* Enhance DHCP-option parsing to extract all DNS-server addresses.
* Set all received DNS-server addresses.

Signed..

acassis
acassis previously approved these changes Nov 6, 2025
@acassis
Copy link
Contributor

acassis commented Nov 6, 2025

@nuttxs could you please help to create some basic Documentation about netlib: https://nuttx.apache.org/docs/latest/applications/netutils/netlib/index.html ?

@nuttxs
Copy link
Contributor Author

nuttxs commented Nov 8, 2025

The basic documentation update for “netlib” has been completed—please verify it (https://github.com/apache/nuttx/pull/17284/files#diff-a3d43ff48c0c7f39a7306020ac95d948edde9aebb9a3d30cdd13fcdff2d0b206) meets the requirements.
As for the compilation errors, I will push update again once PR #17284 (apache/nuttx#17284) is merged.

cederom
cederom previously approved these changes Nov 8, 2025
Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work thank you @nuttxs :-)

NOTE: This PR depends on apache/nuttx#17284 and should be verified again after dependency merge :-)

@nuttxs nuttxs force-pushed the feature/support-delete-DNS-server-by-index-or-address branch from 6efaf9d to 769fd82 Compare November 9, 2025 08:48
@xiaoxiang781216
Copy link
Contributor

@nuttxs please fix the compiler error:

====================================================================================
Configuration/Tool: stm3240g-eval/discover,CONFIG_ARM_TOOLCHAIN_GNU_EABI
2025-11-09 10:25:57
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Disabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Enabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Building NuttX...
chip/stm32_gpio.c:44:11: note: '#pragma message: CONFIG_STM32_USE_LEGACY_PINMAP will be deprecated migrate board.h see tools/stm32_pinmap_tool.py'
   44 | #  pragma message "CONFIG_STM32_USE_LEGACY_PINMAP will be deprecated migrate board.h see tools/stm32_pinmap_tool.py"
      |           ^~~~~~~
discover_main.c: In function 'discover_main':
Error: discover_main.c:155:21: error: '(struct in_addr *)&ds.dnsaddr' is a pointer; did you mean to use '->'?
  155 |       if (ds.dnsaddr.s_addr != 0)
      |                     ^
      |                     ->
Error: discover_main.c:157:34: error: passing argument 1 of 'netlib_set_ipv4dnsaddr' from incompatible pointer type [-Werror=incompatible-pointer-types]
  157 |           netlib_set_ipv4dnsaddr(&ds.dnsaddr);
      |                                  ^~~~~~~~~~~
      |                                  |
      |                                  struct in_addr (*)[1]
In file included from discover_main.c:37:
/github/workspace/sources/apps/include/netutils/netlib.h:484:54: note: expected 'const struct in_addr *' but argument is of type 'struct in_addr (*)[1]'
  484 | int netlib_set_ipv4dnsaddr(FAR const struct in_addr *inaddr);
      |                                ~~~~~~~~~~~~~~~~~~~~~~^~~~~~

@nuttxs nuttxs dismissed stale reviews from acassis, cederom, and xiaoxiang781216 via 2d05d60 November 10, 2025 02:12
@nuttxs nuttxs force-pushed the feature/support-delete-DNS-server-by-index-or-address branch from 769fd82 to 2d05d60 Compare November 10, 2025 02:12
@nuttxs nuttxs force-pushed the feature/support-delete-DNS-server-by-index-or-address branch from 2d05d60 to f3746b2 Compare November 10, 2025 04:11
…dress

- Modify the DHCP-client data structure to support multiple DNS addresses
- Enhance DHCP-option parsing to extract all DNS-server addresses
- Set all received DNS-server addresses
- fix some test case build error

Signed-off-by: nuttxs <zhaoqing.zhang@sony.com>
@nuttxs nuttxs force-pushed the feature/support-delete-DNS-server-by-index-or-address branch from f3746b2 to 0e5674c Compare November 10, 2025 04:19
@xiaoxiang781216 xiaoxiang781216 merged commit 92269be into apache:master Nov 10, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants