Skip to content

netlib: replace DNS ping with gateway ping for connectivity check#3465

Open
zhhyu7 wants to merge 2 commits intoapache:masterfrom
zhhyu7:upstream-3
Open

netlib: replace DNS ping with gateway ping for connectivity check#3465
zhhyu7 wants to merge 2 commits intoapache:masterfrom
zhhyu7:upstream-3

Conversation

@zhhyu7
Copy link
Copy Markdown
Contributor

@zhhyu7 zhhyu7 commented Apr 27, 2026

Summary

Refactor netlib_check_ipconnectivity() to use gateway/router ping instead of DNS server ping for network connectivity checks. Add IPv6 support.

Impact

  • When ip is NULL, ping the default gateway of each interface (via getifaddrs) instead of the hardcoded DNS server address
  • Add IPv6 ping support (icmpv6_ping) alongside existing IPv4 ping
  • Add routing table fallback: ping routers from /proc/net/route and /proc/net/ipv6route when gateway ping fails
  • For point-to-point/tunnel interfaces (no ARP), treat as reachable directly
  • When ping is disabled at build time, fall back to checking network card status instead of always returning 1
  • Auto-detect IPv4/IPv6 when a specific IP is provided
  • netlib_checkipconnectivity.c no longer depends on CONFIG_NETUTILS_PING to compile
  • Improve doxygen-style comments in netlib.h; fix typo "nagtive" → "negative"

Testing

  • Build tested with combinations of CONFIG_NETUTILS_PING, CONFIG_NETUTILS_PING6, CONFIG_NETDEV_IFINDEX, and HAVE_ROUTE_PROCFS enabled/disabled
  • Verified ntpclient caller (netlib_check_ipconnectivity(NULL, 1, 1)) works correctly with the new gateway ping logic
  • Tested on board with IPv4-only, IPv6-only, and dual-stack network interfaces
  • Verified fallback path when ping is disabled at build time

Update the column ruler and field labels in route_ipv6_entry comment
to match the actual output: lowercase to uppercase, remove colons.
Consistent with Nuttx definition

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

looks good to me.

Refactor netlib_check_ipconnectivity() to use gateway/router ping instead
of DNS server ping for network connectivity checks. Add IPv6 support.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
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.

2 participants