Heads up: USE_PACKET_TIMESTAMP tangle

Hal Murray hmurray at megapathdsl.net
Sun Jun 4 09:05:09 UTC 2017


A long time ago, we decided that all modern systems support getting a recv 
time stamp via recvmsg and we got rid of the code that that used SIGIO to get 
a time stamp.

6 months ago, ntp_packetstamp.c was split off from ntp_io.c

There is code in ntp_packetstamp that #defines USE_PACKET_TIMESTAMP

There is code in ntp_io that tests it.  But it gets set in a different 
module, so all the code in ntp_io to call the code in ntp_packetstamp never 
gets compiled in.  (I assume it worked OK before it was split out.)

It took me a while to figure out how it actually works today.  The code that 
calls read_network_packet passes in a time stamp which comes from right after 
the select.  I guess it works well enough when lightly loaded.

I have changes that get rid of USE_PACKET_TIMESTAMP   I'll test it for a day 
or two before I push.  That also gives people time to comment.

My plan is to have it crash at build time if it can't get a recv time stamp.  
There may be systems where that happens.  If so, we can make it work like it 
does today.  I think that deserves a configure time option.

Gary:
  This will be an interesting test case for ntpviz.  Can you see a step in a 
graph when you start running the new code?
  The old recv time stamps should be off by the time from the interrupt 
handler processing the packet until ntpd gets woken up and takes a few steps.

  Things get complicated under heavy load.  This should reduce the deviation. 
 Do you have any busy systems and/or can you set up a test case?

-----

The code to extract the time stamp is a good candidate for the ugly code 
contest:

                 switch (cmsghdr->cmsg_type)
                {
#ifdef USE_SCM_BINTIME
                case SCM_BINTIME:
#endif  /* USE_SCM_BINTIME */
#ifdef USE_SCM_TIMESTAMPNS
                case SCM_TIMESTAMPNS:
#endif  /* USE_SCM_TIMESTAMPNS */
#ifdef USE_SCM_TIMESTAMP
                case SCM_TIMESTAMP:
#endif  /* USE_SCM_TIMESTAMP */
#if defined(USE_SCM_BINTIME) || defined (USE_SCM_TIMESTAMPNS) || 
defined(USE_SCM_TIMESTAMP)
                        switch (cmsghdr->cmsg_type)
                        {
#ifdef USE_SCM_BINTIME
                        case SCM_BINTIME:
...

The outer select is useless.


-- 
These are my opinions.  I hate spam.





More information about the devel mailing list