Ntpd: bug and patch: not reporting lost sync

Denys Vlasenko vda.linux at googlemail.com
Wed May 22 16:19:29 UTC 2013


On Fri, May 3, 2013 at 3:47 PM, Andreas Helmcke <ahe at helmcke.name> wrote:
> Hello,
>
> I am trying to find a way to keep hwclock in sync with the ntp-synced system time using busysbox ntpd.
> Ntpd is able to start a script after each change and every 11 minutes (parameter -S) but there seems to be no way to
> find out if the time is still synchronized i.e. there is at least one valid ntp server.
> The attached patch exports one more value to the script (last_update_recv_time) so that the script can at least check if
> the last update is within some limit.
> I consider this a workaround rather than a real solution because I would expect
> ntpd to set stratum to 16 when loosing contact to the upstream ntp servers but I could not find a proper way to handle this.
> Anyone any suggestions?

I will add something like this in main loop:


                if (G.ntp_peers && G.stratum != MAXSTRAT) {
                        for (item = G.ntp_peers; item != NULL; item =
item->link) {
                                peer_t *p = (peer_t *) item->data;
                                if (p->p->reachable_bits)
                                        goto have_reachable_peer;
                        }
                        /* No peer responded for last 8 packets, panic */
                        G.polladj_count = 0;
                        G.poll_exp = MINPOLL;
                        G.stratum = MAXSTRAT;
                        run_script("unsync", G.last_update_offset);
 have_reachable_peer: ;
                }
        } /* while (!bb_got_signal) */

and the script can look for unsync event.


More information about the busybox mailing list