Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NTP kerninfo offset/estimated error scaling #1314

Closed
wants to merge 1 commit into from

Conversation

PierreF
Copy link
Contributor

@PierreF PierreF commented Oct 20, 2015

This pull requests fix #1300

The scaling was taken from ntp-4.2.6, from ntpdc/ntpdc_ops.c , function kerninfo

Tested with ntp from Ubuntu vivid (1:4.2.6.p5+dfsg-3ubuntu6), value are the correct one with this patch.

Code from ntpdc_ops.c looks like:

  [...]
  struct info_kernel *ik;
  double tscale = 1e-6;
  [...]
#ifdef STA_NANO                                                                 
    if (status & STA_NANO)                                                      
        tscale = 1e-9;                                                          
#endif
    (void)fprintf(fp, "pll offset:           %g s\n",
        (int32)ntohl(ik->offset) * tscale);
    (void)fprintf(fp, "pll frequency:        %s ppm\n",
        fptoa((s_fp)ntohl(ik->freq), 3));
    (void)fprintf(fp, "estimated error:      %g s\n",
        (u_long)ntohl(ik->esterror) * 1e-6);

Note: on my proposed patch tscale is always 1e-6 ... I didn't find where/how STA_NANO could be defined. I've assumed it could only be defined with customized/patched build of ntp.

@mfournier mfournier added the Bug A genuine bug label Oct 30, 2015
@octo
Copy link
Member

octo commented Nov 30, 2015

STA_NANO appears to come from the Linux kernel, usable via the Linux specific <sys/timex.h>. I'll add an appropriate comment.

@mfournier
Copy link

FYI I cherry-picked this patch as 53438c5. Thanks a lot @PierreF !

@mfournier mfournier closed this Nov 30, 2015
octo added a commit that referenced this pull request Nov 30, 2015
Also add note about STA_NANO.

Issue: #1314.
@octo octo added Fix A pull request fixing a bug and removed Bug A genuine bug labels Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix A pull request fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NTPD time_offset-loop is wrong
3 participants