On Tue, Dec 11, 2018 at 10:20 AM Ricardo Biehl Pasquali <[email protected]> wrote: > > Network timestamps are always from REALTIME clock, which > may be adjusted by the user (mainly Network Time Protocol > corrections though). > > For applications that do not want this behavior, an option > for setting clock type is needed. > > The sound subsystem has already an option to set the clock > type for its timestamps. See SNDRV_PCM_TSTAMP_TYPE_* in > include/uapi/sound/asound.h and snd_pcm_gettime() in > include/sound/pcm.h . > > While preparing a small set of changes I found some issues. > > Brief of the changes: > > - Add SO_TIMESTAMP_CLOCK socket option macro. > > - Add macros for clock types: > SOF_TIMESTAMP_CLOCK_REALTIME, > SOF_TIMESTAMP_CLOCK_MONOTONIC, > SOF_TIMESTAMP_CLOCK_MONOTONIC_RAW, > > - Add set/get for the option. Initialize to REALTIME. > > - In __net_timestamp(), get the time according to > sk_timestamp_clock in 'struct sock'.
__net_timestamp is called early in the receive path before socket lookup, in netif_receive_skb_internal through net_timestamp_check. It is not possible to choose the clocktype based on destination socket at this stage. > - Do every caller of __net_timestamp() has skb->sk set? See above, no.
