Skip to content

netlib: support checkipconnectivity when use reslov.conf#3460

Closed
zhhyu7 wants to merge 1 commit intoapache:masterfrom
zhhyu7:upstream-3
Closed

netlib: support checkipconnectivity when use reslov.conf#3460
zhhyu7 wants to merge 1 commit intoapache:masterfrom
zhhyu7:upstream-3

Conversation

@zhhyu7
Copy link
Copy Markdown
Contributor

@zhhyu7 zhhyu7 commented Apr 22, 2026

Summary

Improve netlib_check_ipconnectivity() to support DNS nameservers from resolv.conf via dns_foreach_nameserver(), instead of relying on the compile-time CONFIG_NETDB_DNSSERVER_IPv4ADDR macro.

Impact

  • Add dns_ping_callback() to iterate over all configured DNS nameservers and ping each one until a reply is received.
  • When ip is NULL, use dns_foreach_nameserver() to dynamically resolve and ping DNS servers at runtime, replacing the previous #ifdef CONFIG_NETDB_DNSSERVER_IPv4ADDR compile-time approach.
  • When ip is provided, ping the specified address directly (behavior unchanged).
  • Fix missing newline at end of file.

Testing

Verify netlib_check_ipconnectivity(NULL, ...) pings DNS servers from resolv.conf and ram.

Improve netlib_check_ipconnectivity() to support DNS nameservers from
resolv.conf via dns_foreach_nameserver(), instead of relying on the
compile-time CONFIG_NETDB_DNSSERVER_IPv4ADDR macro.

Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
@masc2008
Copy link
Copy Markdown
Contributor

masc2008 commented Apr 22, 2026

@zhhyu7 it's not a good method to use ping to check if DNS server is reachable. Here is the reason:
A DNS server is only required to answer DNS queries on port 53 over UDP/TCP. Replying to ping means replying to ICMP Echo, which is separate and optional.

So a DNS server may:

  • answer DNS normally
  • ignore or block ping
  • be behind a firewall that drops ICMP

If you want to test DNS reachability, use a DNS query like nslookup, dig, or host, not ping.

And we need move further:
It's not good practice to just check network connectivity via ping ipv4 address, the device may just have an IPv6 address only.

@zhhyu7
Copy link
Copy Markdown
Contributor Author

zhhyu7 commented Apr 22, 2026

@zhhyu7 it's not a good method to use ping to check if DNS server is reachable. Here is the reason: A DNS server is only required to answer DNS queries on port 53 over UDP/TCP. Replying to ping means replying to ICMP Echo, which is separate and optional.

So a DNS server may:

  • answer DNS normally
  • ignore or block ping
  • be behind a firewall that drops ICMP

If you want to test DNS reachability, use a DNS query like nslookup, dig, or host, not ping.

And we need move further: It's not good practice to just check network connectivity via ping ipv4 address, the device may just have an IPv6 address only.

@masc2008, You're right. Regarding NTP, I think we should directly remove the netlib_check_ipconnectivity check from the ntpclient file, because we already have backoff behavior to avoid screen flooding. Meanwhile, I will add a new patch later to select a more appropriate IP address for the check, such as DRaddr, and also add support for IPv6 addresses.

@masc2008
Copy link
Copy Markdown
Contributor

masc2008 commented Apr 22, 2026 via email

Copy link
Copy Markdown
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 @zhhyu7 :-) I agree with @masc2008 remarks please todo in a free moment :-)

@zhhyu7 zhhyu7 closed this Apr 23, 2026
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.

4 participants