From: Miroslav Lichvar Date: Fri, 2 Mar 2018 10:49:53 +0000 (+0100) Subject: ntp: delay enabling permanent kernel RX timestamping on Linux X-Git-Tag: 3.3-pre1~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b1f68b1b4044a941d4f2ffc579aea1430ce432c;p=thirdparty%2Fchrony.git ntp: delay enabling permanent kernel RX timestamping on Linux Wait until a kernel RX timestamp is actually missing before opening the dummy socket in order to avoid a small performance impact in case the servers are so slow/distant that the kernel can constantly win the race. --- diff --git a/ntp_io_linux.c b/ntp_io_linux.c index eb437e37..c44a13be 100644 --- a/ntp_io_linux.c +++ b/ntp_io_linux.c @@ -397,9 +397,7 @@ NIO_Linux_Initialise(void) monitored_socket = INVALID_SOCK_FD; suspended_socket = INVALID_SOCK_FD; - - /* Open a socket to keep the kernel RX timestamping permanently enabled */ - dummy_rxts_socket = open_dummy_socket(); + dummy_rxts_socket = INVALID_SOCK_FD; } /* ================================================== */ @@ -763,6 +761,14 @@ NIO_Linux_ProcessMessage(NTP_Remote_Address *remote_addr, NTP_Local_Address *loc } } + /* If the kernel is slow with enabling RX timestamping, open a dummy + socket to keep the kernel RX timestamping permanently enabled */ + if (!is_tx && local_ts->source == NTP_TS_DAEMON && ts_flags) { + DEBUG_LOG("Missing kernel RX timestamp"); + if (dummy_rxts_socket == INVALID_SOCK_FD) + dummy_rxts_socket = open_dummy_socket(); + } + /* Return the message if it's not received from the error queue */ if (!is_tx) return 0;