Hey,

detha wrote on tech@ recently about how adjtime(2) now sets EINVAL
if delta->tv_nsec < 0, which breaks xntpd's clock retardation.

Given the rarity of this syscall I'd rather patch the software than
restore the 4.4BSD behavior.  I skimmed codesearch.debian.net and
outside of noise from language bindings, noise from test suites, and
noise from compilers, I found very little code using the call.  NTP
and its various forks/rewrites, ptpd, systemd... that's about it.  How
many callers are there in OpenBSD ports?

The attached patch should fix ntpd's problem.  I have only compiled
it.  Unsure if this is the right way to submit this.  I fetched,
extracted, and built, then I made my edit and did update-patches and
this file was the result.  So I think I'm close.  At least, if you
put this patch into ports/net/ntp/patches/patch-libntp_systime_c
I think you'll be good to go.

detha: could you check if this fixes the problem?

Index: libntp/systime.c
--- libntp/systime.c.orig
+++ libntp/systime.c
@@ -344,6 +344,10 @@ adj_systime(
        if (isneg) {
                adjtv.tv_sec = -adjtv.tv_sec;
                adjtv.tv_usec = -adjtv.tv_usec;
+               if (adjtv.tv_usec < 0) {
+                       adjtv.tv_sec  -= 1;
+                       adjtv.tv_usec += 1000000;
+               }
                sys_residual = -sys_residual;
        }
        if (adjtv.tv_sec != 0 || adjtv.tv_usec != 0) {

Reply via email to