Nice trick.
Though, wouldn't we break the cmsg loop once the SCM_TIMESTAMP is found ?
+ for (cmsg = CMSG_FIRSTHDR(&somsg); cmsg != NULL;
+ cmsg = CMSG_NXTHDR(&somsg, cmsg)) {
+ if (cmsg->cmsg_level == SOL_SOCKET &&
+ cmsg->cmsg_type == SCM_TIMESTAMP) {
+ memcpy(&tv1, CMSG_DATA(cmsg), sizeof tv1);
+ T4 += tv1.tv_sec + JAN_1970 + 1.0e-6 * tv1.tv_usec;
++ break;
+ }
+ }
Michael Shalayeff wrote:
re
this diff converts ntpd to use socket timestamps (SO_TIMESTAMP sockopt)
for received packets. this seems to reduce deviation by a factor of 5.
code pohnz0red from bgpd and others using recvmsg.
this has ran on a number of servers already (and still should apply
to original ntpd code ;) but surely can use another look.
cu