DNS issues on NTP client
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- c
- Domain
- networking
Research direction
Start by reading ntpclient.c around gethostbyname, the NTP query retry loop, and the configured-server cycle described in the logs. Determine whether the existing client can request a fresh resolution or whether a cache API is needed; done should be a documented, reproducible way to avoid repeatedly querying the same non-responsive address.
Written by the indexing model from the issue text.
Description
During NTP server querying through the ntpclient.c, different NTP server domain names (e.g., 0.uk.pool.ntp.org, 1.uk.pool.ntp.org) might resolve to the same set of IP addresses due to DNS caching. This can lead to repeated queries to the same non-responsive IP addresses, resulting in failures to obtain the correct time.
For example, in the following, there are some logs that I added to ntpclient.c, in order to understand why the NTP was failing:
[ 51.046000] [25] (Info) '0.pool.ntp.org' resolved to: 216.238.113.58
[ 51.046000] [25] (Info) ntpclient.c-447-gethostbyname for 0.pool.ntp.org OK
[ 51.046000] [25] (Info) ntpclient.c-480-Sending a NTP packet
[ 51.055000] [25] (Info) ntpclient.c-509-sendto ret: 68
[ 51.056000] [25] (Info) ntpclient.c-515-Recv a NTP packet
[ 56.055000] [25] (Info) ntpclient.c-521-recvfrom nbytes: -1
[ 56.056000] [25] (Info) '0.pool.ntp.org' resolved to: 216.238.113.58
[ 56.056000] [25] (Info) ntpclient.c-447-gethostbyname for 0.pool.ntp.org OK
[ 56.056000] [25] (Info) ntpclient.c-480-Sending a NTP packet
[ 56.063000] [25] (Info) ntpclient.c-509-sendto ret: 68
[ 56.063000] [25] (Info) ntpclient.c-515-Recv a NTP packet
[ 61.065000] [25] (Info) ntpclient.c-521-recvfrom nbytes: -1
[ 61.066000] [25] (Info) '0.pool.ntp.org' resolved to: 216.238.113.58
[ 61.066000] [25] (Info) ntpclient.c-447-gethostbyname for 0.pool.ntp.org OK
[ 61.066000] [25] (Info) ntpclient.c-480-Sending a NTP packet
[ 61.075000] [25] (Info) ntpclient.c-509-sendto ret: 68
[ 61.075000] [25] (Info) ntpclient.c-515-Recv a NTP packet
[ 66.075000] [25] (Info) ntpclient.c-521-recvfrom nbytes: -1
[ 66.076000] [25] (Info) '0.pool.ntp.org' resolved to: 216.238.113.58
[ 66.076000] [25] (Info) ntpclient.c-447-gethostbyname for 0.pool.ntp.org OK
[ 66.076000] [25] (Info) ntpclient.c-480-Sending a NTP packet
[ 66.085000] [25] (Info) ntpclient.c-509-sendto ret: 68
[ 66.085000] [25] (Info) ntpclient.c-515-Recv a NTP packet
[ 71.085000] [25] (Info) ntpclient.c-521-recvfrom nbytes: -1
[ 71.086000] [25] (Info) '0.pool.ntp.org' resolved to: 216.238.113.58
[ 71.086000] [25] (Info) ntpclient.c-447-gethostbyname for 0.pool.ntp.org OK
[ 71.086000] [25] (Info) ntpclient.c-480-Sending a NTP packet
[ 71.095000] [25] (Info) ntpclient.c-509-sendto ret: 68
[ 71.095000] [25] (Info) ntpclient.c-515-Recv a NTP packet
[ 76.095000] [25] (Info) ntpclient.c-521-recvfrom nbytes: -1
[ 76.095000] [25] (Info) ntpclient.c-563-ERROR: recvfrom() failed: 11
[ 76.095000] [25] (Info) ntpclient.c-589-The NTP client is terminating
To mitigate this issue, a possible option is to flush the DNS cache after cycling through all configured NTP servers, ensuring that subsequent DNS resolutions provide potentially new and responsive IP addresses, thereby increasing the likelihood of successful time synchronization. However, I cannot manipulate the DNS cache from the user space, unless I create an API for it.
Overall, do you have a workaround or a hack that I can use in order to solve this NTP issue? Or at least to force a new IP resolution for an NTP hostname after some failures?
- Dominant language
- C
- Stars
- 465
- Forks
- 782
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 44
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/nuttx-apps
-
Type: Enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
apache/nuttx-apps#3620 · 5 comments · 1 reaction ·
-
Type: Bug
Difficulty 4/5 3-5 days Newbie friendliness 52/100
apache/nuttx-apps#3634 · 1 comment ·
-
apache/nuttx-apps#3436 · 1 assignee ·
-
[FEATURE/SECURITY/BUG] Add hash key validation to check the files downloaded from external projects OpenType: Bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
apache/nuttx-apps#3418 ·
-
Type: Bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
apache/nuttx-apps#3407 · 14 comments ·
All issues in apache/nuttx-apps
Similar issues
-
level/task module/gcp type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
hapostgres/pg_auto_failover#1190 ·
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
P3 sonic-vpp
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sonic-net/sonic-buildimage#29662 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
spack/spack-packages#6586 ·