Skip to contentSkip to conversation

package/ntp: use ntpd to set initial time

PATCH New Matt Weber 3 participants 14 messages Oct 23, 2018 – Nov 3, 2018

lore
Share & tools
lore

Matt Weber

author
#0 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

The ntpdate program has been in the process of being deprecated for some time. (http://support.ntp.org/bin/view/Dev/DeprecatingNtpdate)

This patch updates the existing ntpd script to handle setting initial time using the new ntpd "one time set and exit" approach.

---
Based on Oscar's v1 patch to add a ntpdate startup script.
http://patchwork.ozlabs.org/patch/986852/

---
 package/ntp/Config.in |  5 +++++
 package/ntp/S49ntp    | 17 +++++++++++++++++
 2 files changed, 22 insertions(+)
package/ntp/Config.in +5 -0
index efd47e1..5cc78ce 100644
@@ -54,6 +54,11 @@ config BR2_PACKAGE_NTP_NTPDATE
 	  The ntpdate utility program is used to set the local date
 	  and time from an NTP server given as an argument.
 
+	  This option is deprecated by upstream and replaced with the
+	  -gq options of ntpd. The package/ntp/S49ntp script has an
+	  example implementation.
+	  (http://support.ntp.org/bin/view/Dev/DeprecatingNtpdate)
+
 config BR2_PACKAGE_NTP_NTPDC
 	bool "ntpdc"
 	help
package/ntp/S49ntp +17 -0
index 35e5874..9851747 100755
@@ -11,6 +11,23 @@ fi
 case "$1" in
   start)
     printf "Starting $NAME: "
+    NTP_WAIT_DELAY=15 #sec
+    CURRENT_DATE=$(date | grep "1970")
+    if [ "$CURRENT_DATE" != "" ]; then
+        printf "checking for time"
+        /usr/sbin/ntpd -g -q > /dev/null 2>&1 &
+        NTP_PID=$!
+        while [ ${NTP_WAIT_DELAY} -gt 0 ]; do
+            [ ! -e /proc/$NTP_PID ] && break
+            sleep 1
+            printf "."
+            : $((NTP_WAIT_DELAY -= 1))
+        done
+        # ntpd never returns if it can't access the NTP server(s)
+        # noted in /etc/ntp.conf.
+        kill $NTP_PID > /dev/null 2>&1
+        [ $? = 0 ] && printf "(Not set): "
+    fi
     start-stop-daemon -S -q -x /usr/sbin/ntpd -- -g
     [ $? = 0 ] && echo "OK" || echo "FAIL"
     ;;
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

Quoted 5 lines · Matt Weber

The ntpdate program has been in the process of being deprecated for some time. (http://support.ntp.org/bin/view/Dev/DeprecatingNtpdate)

This patch updates the existing ntpd script to handle setting initial time using the new ntpd "one time set and exit" approach.

I still think this should be a separate script, e.g. S48ntpdate. But OK, I'm
not going to block the patch for that.

Quoted 32 lines

---
Based on Oscar's v1 patch to add a ntpdate startup script.
http://patchwork.ozlabs.org/patch/986852/

---
 package/ntp/Config.in |  5 +++++
 package/ntp/S49ntp    | 17 +++++++++++++++++
 2 files changed, 22 insertions(+)
package/ntp/Config.in +5 -0
index efd47e1..5cc78ce 100644
@@ -54,6 +54,11 @@ config BR2_PACKAGE_NTP_NTPDATE
 	  The ntpdate utility program is used to set the local date
 	  and time from an NTP server given as an argument.
 
+	  This option is deprecated by upstream and replaced with the
+	  -gq options of ntpd. The package/ntp/S49ntp script has an
+	  example implementation.
+	  (http://support.ntp.org/bin/view/Dev/DeprecatingNtpdate)
+
 config BR2_PACKAGE_NTP_NTPDC
 	bool "ntpdc"
 	help
package/ntp/S49ntp +0 -0
index 35e5874..9851747 100755

package/ntp/S49ntp fi · line 13

Quoted 3 lines
package/ntp/S49ntp +0 -0
@@ -11,6 +11,23 @@ fi
 case "$1" in
   start)
     printf "Starting $NAME: "

This should be done after the ntpdate run.

package/ntp/S49ntp fi · line 14

Quoted 1 line
package/ntp/S49ntp +1 -0
+    NTP_WAIT_DELAY=15 #sec

This should be done before sourcing the defaults file, so it can be overridden.

package/ntp/S49ntp fi · line 15

Quoted 1 line
package/ntp/S49ntp +1 -0
+    CURRENT_DATE=$(date | grep "1970")

So, you didn't like my proposal to use the Unix timestamp (to avoid any
possible issue with localtime):

CURRENT_UNIX_TIME="$(date +%s)"
if [ $CURRENT_UNIX_TIME -lt 1000000000 ]; then

package/ntp/S49ntp fi · line 18

Quoted 3 lines
package/ntp/S49ntp +3 -0
+    if [ "$CURRENT_DATE" != "" ]; then
+        printf "checking for time"
+        /usr/sbin/ntpd -g -q > /dev/null 2>&1 &

Why redirect stderr and stdout?

package/ntp/S49ntp fi · line 25

Quoted 7 lines
package/ntp/S49ntp +7 -0
+        NTP_PID=$!
+        while [ ${NTP_WAIT_DELAY} -gt 0 ]; do
+            [ ! -e /proc/$NTP_PID ] && break
+            sleep 1
+            printf "."
+            : $((NTP_WAIT_DELAY -= 1))
+        done

This is horribly ugly, but there is no better way because the timeout applet is
not enabled in our busybox config. One small improvement could be to use the -p option to save it in a PID file.

However, is there any reason to not just add the "-w $NTP_WAIT_DELAY" option to
the normal invocation of ntpd, below? I haven't tried it, I just thought that that is what is supposed to be the replacement of the initial ntpdate command.

So my proposal would be:

	NTPD_WAIT_ARG=""
	CURRENT_UNIX_TIME="$(date +%s)"
	if [ $CURRENT_UNIX_TIME -lt 1000000000 ]; then
		NTPD_WAIT_ARG="-w ${NTP_WAIT_DELAY}"
	fi
	start-stop-daemon -S -q -x /usr/sbin/ntpd -- -g $NTPD_WAIT_ARG

It would actually even make sense to set the wait delay to a low value (say,
1). I've had quite a few boards where the RTC is wildly inaccurate, off by a few seconds after a day or so. But maybe that is a bit too board-specific. And would anyway be a separate patch.

Note that with -w, ntpd returns ETIMEDOUT if it times out, and unfortunately
that value is platform-dependent (145 on mips, 60 on sparc, 110 on others). So it's a bit tricky to handle that properly. Without handling, the init script will return FAIL while the daemon is actually running.

Regards,
Arnout

Quoted 9 lines
package/ntp/S49ntp +5 -0
+        # ntpd never returns if it can't access the NTP server(s)
+        # noted in /etc/ntp.conf.
+        kill $NTP_PID > /dev/null 2>&1
+        [ $? = 0 ] && printf "(Not set): "
+    fi
     start-stop-daemon -S -q -x /usr/sbin/ntpd -- -g
     [ $? = 0 ] && echo "OK" || echo "FAIL"
     ;;
#2 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

Arnout,

Quoted 42 lines · Arnout Vandecappelle
Quoted 5 lines · Matt Weber

The ntpdate program has been in the process of being deprecated for some time. (http://support.ntp.org/bin/view/Dev/DeprecatingNtpdate)

This patch updates the existing ntpd script to handle setting initial time using the new ntpd "one time set and exit" approach.

I still think this should be a separate script, e.g. S48ntpdate. But OK, I'm
not going to block the patch for that.

Quoted 29 lines

---
Based on Oscar's v1 patch to add a ntpdate startup script.
http://patchwork.ozlabs.org/patch/986852/

---
 package/ntp/Config.in |  5 +++++
 package/ntp/S49ntp    | 17 +++++++++++++++++
 2 files changed, 22 insertions(+)
package/ntp/Config.in +5 -0
index efd47e1..5cc78ce 100644
@@ -54,6 +54,11 @@ config BR2_PACKAGE_NTP_NTPDATE
        The ntpdate utility program is used to set the local date
        and time from an NTP server given as an argument.
 
+       This option is deprecated by upstream and replaced with the
+       -gq options of ntpd. The package/ntp/S49ntp script has an
+       example implementation.
+       (http://support.ntp.org/bin/view/Dev/DeprecatingNtpdate)
+
 config BR2_PACKAGE_NTP_NTPDC
      bool "ntpdc"
      help
package/ntp/S49ntp +0 -0
index 35e5874..9851747 100755
Quoted 8 lines

package/ntp/S49ntp fi · line 13

Quoted 6 lines
package/ntp/S49ntp +0 -0
@@ -11,6 +11,23 @@ fi
 case "$1" in
   start)
     printf "Starting $NAME: "

This should be done after the ntpdate run.

Sure, do you think it is still good to have the information prints about checking and if set or not?

Quoted 4 lines

package/ntp/S49ntp fi · line 14

Quoted 2 lines
package/ntp/S49ntp +1 -0
+    NTP_WAIT_DELAY=15 #sec

This should be done before sourcing the defaults file, so it can be overridden.

Sure.

Quoted 5 lines

package/ntp/S49ntp fi · line 15

Quoted 2 lines
package/ntp/S49ntp +1 -0
+    CURRENT_DATE=$(date | grep "1970")

So, you didn't like my proposal to use the Unix timestamp (to avoid any
possible issue with localtime):

I'll switch to unix.

Quoted 9 lines

CURRENT_UNIX_TIME="$(date +%s)"
if [ $CURRENT_UNIX_TIME -lt 1000000000 ]; then

package/ntp/S49ntp fi · line 18

Quoted 3 lines
package/ntp/S49ntp +3 -0
+    if [ "$CURRENT_DATE" != "" ]; then
+        printf "checking for time"
+        /usr/sbin/ntpd -g -q > /dev/null 2>&1 &

Why redirect stderr and stdout?

Habit, I'll see if just stdout keeps it clean for the basic output. Err I guess would be good to see.

Quoted 9 lines

package/ntp/S49ntp fi · line 25

Quoted 8 lines
package/ntp/S49ntp +7 -0
+        NTP_PID=$!
+        while [ ${NTP_WAIT_DELAY} -gt 0 ]; do
+            [ ! -e /proc/$NTP_PID ] && break
+            sleep 1
+            printf "."
+            : $((NTP_WAIT_DELAY -= 1))
+        done
Quoted 4 lines

This is horribly ugly, but there is no better way because the timeout applet is
not enabled in our busybox config. One small improvement could be to use the -p option to save it in a PID file.

True.

Quoted 4 lines

However, is there any reason to not just add the "-w $NTP_WAIT_DELAY" option to
the normal invocation of ntpd, below? I haven't tried it, I just thought that that is what is supposed to be the replacement of the initial ntpdate command.

From what I can tell and tested, it just waits until the first time is sync'd correctly. It doesn't do the one shot setting of the initial time (must -g and should do -q so it exits). So since we have the case of the time possibly not being valid, I'm not sure we'd want to add the -w to our actual ntpd service start so that it would wait for the other ntpd -g to get time. We already handle this with the NTP_WAIT_DELAY that manages the ntpd -gq process state.
http://lists.ntp.org/pipermail/questions/2011-July/030041.html

Quoted 14 lines

So my proposal would be:

        NTPD_WAIT_ARG=""
        CURRENT_UNIX_TIME="$(date +%s)"
        if [ $CURRENT_UNIX_TIME -lt 1000000000 ]; then
                NTPD_WAIT_ARG="-w ${NTP_WAIT_DELAY}"
        fi
        start-stop-daemon -S -q -x /usr/sbin/ntpd -- -g $NTPD_WAIT_ARG

It would actually even make sense to set the wait delay to a low value (say,
1). I've had quite a few boards where the RTC is wildly inaccurate, off by a few seconds after a day or so. But maybe that is a bit too board-specific. And would anyway be a separate patch.

Quoted 4 lines

Note that with -w, ntpd returns ETIMEDOUT if it times out, and unfortunately
that value is platform-dependent (145 on mips, 60 on sparc, 110 on others). So it's a bit tricky to handle that properly. Without handling, the init script will return FAIL while the daemon is actually running.

Yeah, I was sort of thinking of keeping it simple by not changing the existing ntpd behavior at all and just adding the one shot support in
a reliable manner above it. -w feels like something that would need
to be tuned and we'd still need the code to kill the -gq process.

Matt

#3 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

Quoted 3 lines · Matthew Weber

Arnout,

On Tue, Oct 23, 2018 at 3:31 PM Arnout Vandecappelle <[email protected]> wrote:

[snip]

Quoted 33 lines
Quoted 4 lines

However, is there any reason to not just add the "-w $NTP_WAIT_DELAY" option to
the normal invocation of ntpd, below? I haven't tried it, I just thought that that is what is supposed to be the replacement of the initial ntpdate command.

From what I can tell and tested, it just waits until the first time is sync'd correctly. It doesn't do the one shot setting of the initial time (must -g and should do -q so it exits). So since we have the case of the time possibly not being valid, I'm not sure we'd want to add the -w to our actual ntpd service start so that it would wait for the other ntpd -g to get time. We already handle this with the NTP_WAIT_DELAY that manages the ntpd -gq process state.
http://lists.ntp.org/pipermail/questions/2011-July/030041.html

Quoted 14 lines

So my proposal would be:

        NTPD_WAIT_ARG=""
        CURRENT_UNIX_TIME="$(date +%s)"
        if [ $CURRENT_UNIX_TIME -lt 1000000000 ]; then
                NTPD_WAIT_ARG="-w ${NTP_WAIT_DELAY}"
        fi
        start-stop-daemon -S -q -x /usr/sbin/ntpd -- -g $NTPD_WAIT_ARG

It would actually even make sense to set the wait delay to a low value (say,
1). I've had quite a few boards where the RTC is wildly inaccurate, off by a few seconds after a day or so. But maybe that is a bit too board-specific. And would anyway be a separate patch.

Quoted 4 lines

Note that with -w, ntpd returns ETIMEDOUT if it times out, and unfortunately
that value is platform-dependent (145 on mips, 60 on sparc, 110 on others). So it's a bit tricky to handle that properly. Without handling, the init script will return FAIL while the daemon is actually running.

Quoted 4 lines

Yeah, I was sort of thinking of keeping it simple by not changing the existing ntpd behavior at all and just adding the one shot support in
a reliable manner above it. -w feels like something that would need
to be tuned and we'd still need the code to kill the -gq process.

Just to be clear: the idea is to NOT do the -gq process, so it doesn't need to
be killed. Instead, you do just ONE invocation of ntpd with the -g option (so the first time it gets a time, it does a big jump; we may want to add -G as well for smaller jumps in case of an inaccurate RTC). As far as I understand, this should do the same as what we attempt to do here: wait for one clock adjustment to finish before continuing, but time out and continue with the wrong time if that clock adjustment doesn't happen within 15 seconds.

Regards,
Arnout

#4 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

Arnout,

Quoted 46 lines · Arnout Vandecappelle
Quoted 3 lines · Matthew Weber

Arnout,

On Tue, Oct 23, 2018 at 3:31 PM Arnout Vandecappelle <[email protected]> wrote:

[snip]

Quoted 33 lines
Quoted 4 lines

However, is there any reason to not just add the "-w $NTP_WAIT_DELAY" option to
the normal invocation of ntpd, below? I haven't tried it, I just thought that that is what is supposed to be the replacement of the initial ntpdate command.

From what I can tell and tested, it just waits until the first time is sync'd correctly. It doesn't do the one shot setting of the initial time (must -g and should do -q so it exits). So since we have the case of the time possibly not being valid, I'm not sure we'd want to add the -w to our actual ntpd service start so that it would wait for the other ntpd -g to get time. We already handle this with the NTP_WAIT_DELAY that manages the ntpd -gq process state.
http://lists.ntp.org/pipermail/questions/2011-July/030041.html

Quoted 14 lines

So my proposal would be:

        NTPD_WAIT_ARG=""
        CURRENT_UNIX_TIME="$(date +%s)"
        if [ $CURRENT_UNIX_TIME -lt 1000000000 ]; then
                NTPD_WAIT_ARG="-w ${NTP_WAIT_DELAY}"
        fi
        start-stop-daemon -S -q -x /usr/sbin/ntpd -- -g $NTPD_WAIT_ARG

It would actually even make sense to set the wait delay to a low value (say,
1). I've had quite a few boards where the RTC is wildly inaccurate, off by a few seconds after a day or so. But maybe that is a bit too board-specific. And would anyway be a separate patch.

Quoted 4 lines

Note that with -w, ntpd returns ETIMEDOUT if it times out, and unfortunately
that value is platform-dependent (145 on mips, 60 on sparc, 110 on others). So it's a bit tricky to handle that properly. Without handling, the init script will return FAIL while the daemon is actually running.

Quoted 4 lines

Yeah, I was sort of thinking of keeping it simple by not changing the existing ntpd behavior at all and just adding the one shot support in
a reliable manner above it. -w feels like something that would need
to be tuned and we'd still need the code to kill the -gq process.

Quoted 8 lines

Just to be clear: the idea is to NOT do the -gq process, so it doesn't need to
be killed. Instead, you do just ONE invocation of ntpd with the -g option (so the first time it gets a time, it does a big jump; we may want to add -G as well for smaller jumps in case of an inaccurate RTC). As far as I understand, this should do the same as what we attempt to do here: wait for one clock adjustment to finish before continuing, but time out and continue with the wrong time if that clock adjustment doesn't happen within 15 seconds.

Agree. So if we do the one invocation we'll have to figure out how to deal with the return value. Sounds like that is desired, so I'll put together a test and see. For the -w value, from testing it looks like the -w should probably be ~10-15sec as a sync on average was ~8-9sec.

Matt

#5 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

Quoted 4 lines · Matthew Weber

Agree. So if we do the one invocation we'll have to figure out how to deal with the return value. Sounds like that is desired, so I'll put together a test and see. For the -w value, from testing it looks like the -w should probably be ~10-15sec as a sync on average was ~8-9sec.

8 seconds is not good. We want to get the same sync time as with ntpdate,
otherwise we're doing something wrong. And I guess ntpdate does it in a second, right?

If I remember correctly (but it has been *years* since I used ntpd rather than
chrony or systemd-timesyncd) ntpd had options for how fast it would converge on the first sync. Normally when a new peer is added, it waits for a couple of round trips before that peer is accepted as a healthy source. But I thought it was possible (and hopefully default) to just believe the first packet you receive during startup and sync on that.

#6 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

Hi Arnout,

Quoted 3 lines

8 seconds is not good. We want to get the same sync time as with ntpdate,
otherwise we're doing something wrong. And I guess ntpdate does it in a second, right?

I made a test on my Raspberry Pi 3B+ and it took me around 10-12 seconds to execute ntpdate.

Best regards.

Oscar Gomez Fuente
TST Sistemas
www.tst-sistemas.es

#7 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

In reply to Arnout Vandecappelle

Arnout, Oscar,

Quoted 14 lines · Arnout Vandecappelle
Quoted 4 lines · Matthew Weber

Agree. So if we do the one invocation we'll have to figure out how to deal with the return value. Sounds like that is desired, so I'll put together a test and see. For the -w value, from testing it looks like the -w should probably be ~10-15sec as a sync on average was ~8-9sec.

8 seconds is not good. We want to get the same sync time as with ntpdate,
otherwise we're doing something wrong. And I guess ntpdate does it in a second, right?

Quoted 6 lines

If I remember correctly (but it has been *years* since I used ntpd rather than
chrony or systemd-timesyncd) ntpd had options for how fast it would converge on the first sync. Normally when a new peer is added, it waits for a couple of round trips before that peer is accepted as a healthy source. But I thought it was possible (and hopefully default) to just believe the first packet you receive during startup and sync on that.

All the research I've found and also inspection of the code leads me to believe that the -w option can be used to wait for an initial sync of "good time". Not an initial step which is large and set to system time right away. I've submitted a v3 using the new sntp tool which I believe has got some traction as the replacement for ntpdate.
https://patchwork.ozlabs.org/patch/991267/

Oscar, this new script should sync time quite fast ~1sec in my QEMU.

Matt

#8 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

Hi everyone,

I was checking it on my Raspberry Pi 3B+ and it works perfectly.

The only weird thing is the log related to the other ntp servers, but I think they are normal. It sees to be that they are duplicated, the alternative servers exist in case one of them it was down, so it is ok.

----->

# date --set "1970-01-01 10:10:00"
Thu Jan  1 10:10:00 UTC 1970
# sntp -K /tmp/kod -sS -M 128 0.pool.ntp.org 1.pool.ntp.org
2.pool.ntp.org 3.pool.ntp.org
sntp 4.2.8p12 at 1.3728-o Wed Oct 31 08:22:38 UTC 2018 (1)
213.251.52.234:123 0.pool.ntp.org duplicate address from 1.pool.ntp.org ignored.
37.139.121.60:123 0.pool.ntp.org duplicate address from 1.pool.ntp.org ignored.
185.132.136.116:123 0.pool.ntp.org duplicate address from
1.pool.ntp.org ignored.
81.19.96.148:123 0.pool.ntp.org duplicate address from 1.pool.ntp.org ignored.
213.251.52.234:123 0.pool.ntp.org duplicate address from 2.pool.ntp.org ignored.
81.19.96.148:123 0.pool.ntp.org duplicate address from 2.pool.ntp.org ignored.
185.132.136.116:123 0.pool.ntp.org duplicate address from
2.pool.ntp.org ignored.
37.139.121.60:123 0.pool.ntp.org duplicate address from 2.pool.ntp.org ignored.
Send to [2001:720:1014:a205::2]:123 failed, Network is unreachable
213.251.52.234:123 0.pool.ntp.org duplicate address from 3.pool.ntp.org ignored.
81.19.96.148:123 0.pool.ntp.org duplicate address from 3.pool.ntp.org ignored.
185.132.136.116:123 0.pool.ntp.org duplicate address from
3.pool.ntp.org ignored.
37.139.121.60:123 0.pool.ntp.org duplicate address from 3.pool.ntp.org ignored.
Send to [2001:720:1014:a202::2]:123 failed, Network is unreachable
1970-01-01 10:10:05.624784 (+0000) +1540938259.059756 +/-
1027292172.738343 0.pool.ntp.org 213.251.52.234 s2 no-leap
# date
Wed Oct 31 08:34:26 UTC 2018
----->

Great Job!

Best regards.

Oscar Gomez Fuente
TST Sistemas
www.tst-sistemas.es

#9 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

Oscar,

Quoted 37 lines · Oscar Gomez Fuente

Hi everyone,

I was checking it on my Raspberry Pi 3B+ and it works perfectly.

The only weird thing is the log related to the other ntp servers, but I think they are normal. It sees to be that they are duplicated, the alternative servers exist in case one of them it was down, so it is ok.

----->

# date --set "1970-01-01 10:10:00"
Thu Jan  1 10:10:00 UTC 1970
# sntp -K /tmp/kod -sS -M 128 0.pool.ntp.org 1.pool.ntp.org
2.pool.ntp.org 3.pool.ntp.org
sntp 4.2.8p12 at 1.3728-o Wed Oct 31 08:22:38 UTC 2018 (1)
213.251.52.234:123 0.pool.ntp.org duplicate address from 1.pool.ntp.org ignored.
37.139.121.60:123 0.pool.ntp.org duplicate address from 1.pool.ntp.org ignored.
185.132.136.116:123 0.pool.ntp.org duplicate address from
1.pool.ntp.org ignored.
81.19.96.148:123 0.pool.ntp.org duplicate address from 1.pool.ntp.org ignored.
213.251.52.234:123 0.pool.ntp.org duplicate address from 2.pool.ntp.org ignored.
81.19.96.148:123 0.pool.ntp.org duplicate address from 2.pool.ntp.org ignored.
185.132.136.116:123 0.pool.ntp.org duplicate address from
2.pool.ntp.org ignored.
37.139.121.60:123 0.pool.ntp.org duplicate address from 2.pool.ntp.org ignored.
Send to [2001:720:1014:a205::2]:123 failed, Network is unreachable
213.251.52.234:123 0.pool.ntp.org duplicate address from 3.pool.ntp.org ignored.
81.19.96.148:123 0.pool.ntp.org duplicate address from 3.pool.ntp.org ignored.
185.132.136.116:123 0.pool.ntp.org duplicate address from
3.pool.ntp.org ignored.
37.139.121.60:123 0.pool.ntp.org duplicate address from 3.pool.ntp.org ignored.
Send to [2001:720:1014:a202::2]:123 failed, Network is unreachable
1970-01-01 10:10:05.624784 (+0000) +1540938259.059756 +/-
1027292172.738343 0.pool.ntp.org 213.251.52.234 s2 no-leap
Quoted 3 lines
# date
Wed Oct 31 08:34:26 UTC 2018
----->

I debated keeping all the pool servers in the list. When the sntp agent resolves any of the "0/1/2/3.pool.ntp.org or pool.ntp.org", the DNS response is 4 server IPs. The sntp agent then uses all 4 in serial or a -c flag can be set to concurrently check them. So realistically just pool.ntp.org could be set as the sole server, assuming there are 4 servers provided when it resolves.

Matt

#10 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

Oscar,

Quoted 46 lines · Matthew Weber

Oscar,

Quoted 37 lines · Oscar Gomez Fuente

Hi everyone,

I was checking it on my Raspberry Pi 3B+ and it works perfectly.

The only weird thing is the log related to the other ntp servers, but I think they are normal. It sees to be that they are duplicated, the alternative servers exist in case one of them it was down, so it is ok.

----->

# date --set "1970-01-01 10:10:00"
Thu Jan  1 10:10:00 UTC 1970
# sntp -K /tmp/kod -sS -M 128 0.pool.ntp.org 1.pool.ntp.org
2.pool.ntp.org 3.pool.ntp.org
sntp 4.2.8p12 at 1.3728-o Wed Oct 31 08:22:38 UTC 2018 (1)
213.251.52.234:123 0.pool.ntp.org duplicate address from 1.pool.ntp.org ignored.
37.139.121.60:123 0.pool.ntp.org duplicate address from 1.pool.ntp.org ignored.
185.132.136.116:123 0.pool.ntp.org duplicate address from
1.pool.ntp.org ignored.
81.19.96.148:123 0.pool.ntp.org duplicate address from 1.pool.ntp.org ignored.
213.251.52.234:123 0.pool.ntp.org duplicate address from 2.pool.ntp.org ignored.
81.19.96.148:123 0.pool.ntp.org duplicate address from 2.pool.ntp.org ignored.
185.132.136.116:123 0.pool.ntp.org duplicate address from
2.pool.ntp.org ignored.
37.139.121.60:123 0.pool.ntp.org duplicate address from 2.pool.ntp.org ignored.
Send to [2001:720:1014:a205::2]:123 failed, Network is unreachable
213.251.52.234:123 0.pool.ntp.org duplicate address from 3.pool.ntp.org ignored.
81.19.96.148:123 0.pool.ntp.org duplicate address from 3.pool.ntp.org ignored.
185.132.136.116:123 0.pool.ntp.org duplicate address from
3.pool.ntp.org ignored.
37.139.121.60:123 0.pool.ntp.org duplicate address from 3.pool.ntp.org ignored.
Send to [2001:720:1014:a202::2]:123 failed, Network is unreachable
1970-01-01 10:10:05.624784 (+0000) +1540938259.059756 +/-
1027292172.738343 0.pool.ntp.org 213.251.52.234 s2 no-leap
Quoted 3 lines
# date
Wed Oct 31 08:34:26 UTC 2018
----->
Quoted 7 lines

I debated keeping all the pool servers in the list. When the sntp agent resolves any of the "0/1/2/3.pool.ntp.org or pool.ntp.org", the DNS response is 4 server IPs. The sntp agent then uses all 4 in serial or a -c flag can be set to concurrently check them. So realistically just pool.ntp.org could be set as the sole server, assuming there are 4 servers provided when it resolves.

Would you mind testing my v4 patch which defaults to one server and if all looks good, provide your tested-by on that patch's email?
https://patchwork.ozlabs.org/patch/992167/

#11 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

Hi Matthew,

Quoted 3 lines

Would you mind testing my v4 patch which defaults to one server and if all looks good, provide your tested-by on that patch's email?
https://patchwork.ozlabs.org/patch/992167/

Ok, It will have to be on Monday because I'm out of the office until Monday.

Best regards.

#12 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

Hi Matthew,

I was able to connect by VPN and check the new patch v4. Everything works fine on my Raspberry Pi 3B+:

# /etc/init.d/S49ntp stop
Stopping ntpd: OK

# date
Sat Nov  3 15:41:17 UTC 2018
# date --set "1970-02-01 10:10:10"
Sun Feb  1 10:10:10 UTC 1970
# date
Sun Feb  1 10:10:11 UTC 1970
# /etc/init.d/S48sntp start
Starting sntp:
sntp 4.2.8p12 at 1.3728-o Wed Oct 31 08:22:38 UTC 2018 (1)
1970-02-01 10:10:24.982820 (+0000) +1538544675.515026 +/-
1025696450.421369 pool.ntp.org 37.139.121.60 s2 no-leap
OK
# date
Sat Nov  3 15:41:42 UTC 2018

But I don't how to do that:

Quoted 2 lines
Quoted 2 lines

... provide your tested-by on that patch's email?
https://patchwork.ozlabs.org/patch/992167/

Best regards.

Oscar Gomez Fuente
TST Sistemas
www.tst-sistemas.es

#13 lore raw

PATCH 1/1 package/ntp: use ntpd to set initial time

Quoted 23 lines · Oscar Gomez Fuente

Hi Matthew,

I was able to connect by VPN and check the new patch v4. Everything works fine on my Raspberry Pi 3B+:

# /etc/init.d/S49ntp stop
Stopping ntpd: OK

# date
Sat Nov  3 15:41:17 UTC 2018
# date --set "1970-02-01 10:10:10"
Sun Feb  1 10:10:10 UTC 1970
# date
Sun Feb  1 10:10:11 UTC 1970
# /etc/init.d/S48sntp start
Starting sntp:
sntp 4.2.8p12 at 1.3728-o Wed Oct 31 08:22:38 UTC 2018 (1)
1970-02-01 10:10:24.982820 (+0000) +1538544675.515026 +/-
1025696450.421369 pool.ntp.org 37.139.121.60 s2 no-leap
OK
# date
Sat Nov  3 15:41:42 UTC 2018
Quoted 4 lines

But I don't how to do that:

Quoted 2 lines
Quoted 2 lines

... provide your tested-by on that patch's email?
https://patchwork.ozlabs.org/patch/992167/

Just reply to the patch with this line in the mail:

(now you don't need to do it anymore since I already did).

This gets picked up by Patchwork, so you can see in [1] that your tested-by line has been added to the commit message.

Regards,
Arnout

[1] http://patchwork.ozlabs.org/patch/992167/mbox/