[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ntp-bugs
Subject:    [ntp:bugs] [Bug 2178] New: Refclock reach register fails to shift
From:       bugzilla-daemon () ntp ! org
Date:       2012-05-07 2:40:54
Message-ID: bug-2178-35 () http ! bugs ! ntp ! org/
[Download RAW message or body]

http://bugs.ntp.org/show_bug.cgi?id=2178

             Bug #: 2178
           Summary: Refclock reach register fails to shift
           Product: ntp
           Version: 4.2.6
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: minor
          Priority: P5
         Component: ntpd
        AssignedTo: stenn@ntp.org
        ReportedBy: andris@hpl.hp.com
                CC: bugs@ntp.org
    Classification: Unclassified


NTP version: 4.2.6p2 packaged for Debian "squeeze"
Reference clock: Spectracom TSyncI-PCIe (onboard GPS receiver)

Problem: The "reach" peer variable for the reference clock is set to "1" by
         refclock_receive() in ntp_refclock.c but never gets shifted by the
         refclock_transmit() function.

I tracked this problem down to the "if (peer->burst == 0)" test at the
beginning
of refclock_transmit().  The burst count starts out at NSTAGE in the
refclock_tsyncpci.c driver and is decremented to 1 before being reset back to
NSTAGE.  The refclock_transmit() function never sees peer->burst == 0 and thus
never shifts the reach register.

I could not see where to fix this problem in the refclock_tsyncpci.c driver.
In fact, a lot of the refclock drivers have this approximate sequence of
common actions at the end of the polling loop:

    if (peer->burst > 0) {
        return;
    }

    record_clock_stats(&peer->srcadr, pp->a_lastcode);
    refclock_receive(peer);

    /* Reset for the next burst of polls */
    peer->burst = NSTAGE;

The following patch to refclock_transmit() fixes the problem:

--- ntp-4.2.6p2/ntpd/ntp_refclock.c.orig  2010-06-18 23:40:31.000000000 -0700
+++ ntp-4.2.6p2/ntpd/ntp_refclock.c       2012-04-21 21:34:02.803744379 -0700
@@ -313,7 +313,7 @@
         * specialized for reference clocks. We do a little less
         * protocol here and call the driver-specific transmit routine.
         */
-       if (peer->burst == 0) {
+       if (peer->burst <= 1) {
                u_char oreach;
 #ifdef DEBUG
                if (debug)
@@ -339,6 +339,7 @@
                        if (peer->flags & FLAG_BURST)
                                peer->burst = NSTAGE;
                }
+               peer->burst = 0;
        } else {
                peer->burst--;
        }

I feel a little iffy about doing it this way because this affects the ntpd
interface to *all* reference clock drivers, not just the one I'm using.

By the way, I saw that the latest development release of ntp has added
Spectracom's TSYNC refclock driver to the standard known collection.
I'm using it instead of the vendor's version and it seems to work fine
since 4.2.6 supports the leap second enhancements that were added.
However, the above patch is still necessary to get the reach shift
register to work.

Thanks for taking a look into this.
Andris Kalnozols

-- 
Configure bugmail: http://bugs.ntp.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
bugs mailing list
bugs@lists.ntp.org
http://lists.ntp.org/listinfo/bugs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic