ntp: add support for software timestamping on Linux

Enable SCM_TIMESTAMPING control messages and the socket's error queue in
order to receive our transmitted packets with a more accurate transmit
timestamp. Add a new file for Linux-specific NTP I/O and implement
processing of these messages there.
This commit is contained in:
Miroslav Lichvar
2016-10-07 17:03:09 +02:00
parent 14c8f07629
commit 997406fe47
7 changed files with 374 additions and 10 deletions

21
configure vendored
View File

@@ -101,6 +101,7 @@ For better control, use the options below.
--disable-asyncdns Disable asynchronous name resolving
--disable-forcednsretry Don't retry on permanent DNS error
--without-clock-gettime Don't use clock_gettime() even if it is available
--disable-timestamping Disable support for SW timestamping
--enable-ntp-signd Enable support for MS-SNTP authentication in Samba
--with-ntp-era=SECONDS Specify earliest assumed NTP time in seconds
since 1970-01-01 [50*365 days ago]
@@ -219,6 +220,8 @@ try_lockmem=0
feat_asyncdns=1
feat_forcednsretry=1
try_clock_gettime=1
feat_timestamping=1
try_timestamping=0
feat_ntp_signd=0
ntp_era_split=""
default_user="root"
@@ -329,6 +332,9 @@ do
--without-clock-gettime)
try_clock_gettime=0
;;
--disable-timestamping)
feat_timestamping=0
;;
--enable-ntp-signd)
feat_ntp_signd=1
;;
@@ -387,6 +393,7 @@ case $OPERATINGSYSTEM in
[ $try_libcap != "0" ] && try_libcap=1
try_rtc=1
[ $try_seccomp != "0" ] && try_seccomp=1
try_timestamping=1
try_setsched=1
try_lockmem=1
try_phc=1
@@ -459,6 +466,7 @@ if [ $feat_ntp = "1" ]; then
fi
else
feat_asyncdns=0
feat_timestamping=0
fi
if [ "$feat_cmdmon" = "1" ] || [ $feat_ntp = "1" ]; then
@@ -633,6 +641,19 @@ else
fi
fi
if [ $feat_timestamping = "1" ] && [ $try_timestamping = "1" ] &&
test_code 'SW timestamping' 'sys/types.h sys/socket.h linux/net_tstamp.h
linux/errqueue.h' '' '' '
int val = SOF_TIMESTAMPING_SOFTWARE | SOF_TIMESTAMPING_RX_SOFTWARE |
SOF_TIMESTAMPING_OPT_CMSG;
return sizeof (struct scm_timestamping) + SCM_TSTAMP_SND +
setsockopt(0, SOL_SOCKET, SO_SELECT_ERR_QUEUE + SO_TIMESTAMPING,
&val, sizeof (val));'
then
add_def HAVE_LINUX_TIMESTAMPING
EXTRA_OBJECTS="$EXTRA_OBJECTS ntp_io_linux.o"
fi
timepps_h=""
if [ $feat_refclock = "1" ] && [ $feat_pps = "1" ]; then
if test_code '<sys/timepps.h>' 'sys/timepps.h' '' '' ''; then