summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-01-31 10:40:25 +0000
committerphk <phk@FreeBSD.org>2004-01-31 10:40:25 +0000
commit35592de77bccf63789e2fd7396b81328733450f9 (patch)
tree541f152b903334a9cf726d3180613df082ab33ba /sys/netinet
parentac460e8a52313c38e9e4e8d52da016ce8df9e8e3 (diff)
downloadFreeBSD-src-35592de77bccf63789e2fd7396b81328733450f9.zip
FreeBSD-src-35592de77bccf63789e2fd7396b81328733450f9.tar.gz
Introduce the SO_BINTIME option which takes a high-resolution timestamp
at packet arrival. For benchmarking purposes SO_BINTIME is preferable to SO_TIMEVAL since it has higher resolution and lower overhead. Simultaneous use of the two options is possible and they will return consistent timestamps. This introduces an extra test and a function call for SO_TIMEVAL, but I have not been able to measure that.
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/ip_input.c27
-rw-r--r--sys/netinet/udp_usrreq.c2
2 files changed, 20 insertions, 9 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index bb4271e..0900202 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -2062,14 +2062,25 @@ ip_savecontrol(inp, mp, ip, m)
register struct ip *ip;
register struct mbuf *m;
{
- if (inp->inp_socket->so_options & SO_TIMESTAMP) {
- struct timeval tv;
-
- microtime(&tv);
- *mp = sbcreatecontrol((caddr_t) &tv, sizeof(tv),
- SCM_TIMESTAMP, SOL_SOCKET);
- if (*mp)
- mp = &(*mp)->m_next;
+ if (inp->inp_socket->so_options & (SO_BINTIME | SO_TIMESTAMP)) {
+ struct bintime bt;
+
+ bintime(&bt);
+ if (inp->inp_socket->so_options & SO_BINTIME) {
+ *mp = sbcreatecontrol((caddr_t) &bt, sizeof(bt),
+ SCM_BINTIME, SOL_SOCKET);
+ if (*mp)
+ mp = &(*mp)->m_next;
+ }
+ if (inp->inp_socket->so_options & SO_TIMESTAMP) {
+ struct timeval tv;
+
+ bintime2timeval(&bt, &tv);
+ *mp = sbcreatecontrol((caddr_t) &tv, sizeof(tv),
+ SCM_TIMESTAMP, SOL_SOCKET);
+ if (*mp)
+ mp = &(*mp)->m_next;
+ }
}
if (inp->inp_flags & INP_RECVDSTADDR) {
*mp = sbcreatecontrol((caddr_t) &ip->ip_dst,
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 1591fc8..02a0e77 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -475,7 +475,7 @@ udp_append(last, ip, n, off)
}
#endif
if (last->inp_flags & INP_CONTROLOPTS ||
- last->inp_socket->so_options & SO_TIMESTAMP) {
+ last->inp_socket->so_options & (SO_TIMESTAMP | SO_BINTIME)) {
#ifdef INET6
if (last->inp_vflag & INP_IPV6) {
int savedflags;
OpenPOWER on IntegriCloud