]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Add a new socket option SO_TS_CLOCK to pick from several different clock
authorsobomax <sobomax@FreeBSD.org>
Mon, 16 Jan 2017 17:46:38 +0000 (17:46 +0000)
committersobomax <sobomax@FreeBSD.org>
Mon, 16 Jan 2017 17:46:38 +0000 (17:46 +0000)
commit701697521cdd74f2f7cfee4e18bd672544300bb3
tree250aca065db174079d41caaf6f1a46a17cd315d0
parentbfc26a0c9420ebdf86d6b597453cffef86853159
Add a new socket option SO_TS_CLOCK to pick from several different clock
sources to return timestamps when SO_TIMESTAMP is enabled. Two additional
clock sources are:

o nanosecond resolution realtime clock (equivalent of CLOCK_REALTIME);
o nanosecond resolution monotonic clock (equivalent of CLOCK_MONOTONIC).

In addition to this, this option provides unified interface to get bintime
(equivalent of using SO_BINTIME), except it also supported with IPv6 where
SO_BINTIME has never been supported. The long term plan is to depreciate
SO_BINTIME and move everything to using SO_TS_CLOCK.

Idea for this enhancement has been briefly discussed on the Net session
during dev summit in Ottawa last June and the general input was positive.

This change is believed to benefit network benchmarks/profiling as well
as other scenarios where precise time of arrival measurement is necessary.

There are two regression test cases as part of this commit: one extends unix
domain test code (unix_cmsg) to test new SCM_XXX types and another one
implementis totally new test case which exchanges UDP packets between two
processes using both conventional methods (i.e. calling clock_gettime(2)
before recv(2) and after send(2)), as well as using setsockopt()+recv() in
receive path. The resulting delays are checked for sanity for all supported
clock types.

Reviewed by:    adrian, gnn
Differential Revision:  https://reviews.freebsd.org/D9171
lib/libc/sys/getsockopt.2
sys/kern/uipc_socket.c
sys/kern/uipc_usrreq.c
sys/netinet/ip_input.c
sys/netinet6/ip6_input.c
sys/sys/socket.h
sys/sys/socketvar.h
tools/regression/sockets/udp_pingpong/Makefile [new file with mode: 0644]
tools/regression/sockets/udp_pingpong/udp_pingpong.c [new file with mode: 0644]
tools/regression/sockets/unix_cmsg/Makefile
tools/regression/sockets/unix_cmsg/unix_cmsg.c