Add a new socket option which timestamps packet arrival with a struct bintime instead of timeval for SO_TIMESTAMP. Yes, we actually can afford hardware where this makes measurable difference. Poul-Henning Index: kern/uipc_socket.c =================================================================== RCS file: /home/ncvs/src/sys/kern/uipc_socket.c,v retrieving revision 1.159 diff -u -r1.159 uipc_socket.c --- kern/uipc_socket.c 16 Nov 2003 18:25:20 -0000 1.159 +++ kern/uipc_socket.c 19 Jan 2004 12:40:01 -0000 _at__at_ -1357,6 +1357,7 _at__at_ case SO_REUSEPORT: case SO_OOBINLINE: case SO_TIMESTAMP: + case SO_BINTIME: case SO_NOSIGPIPE: error = sooptcopyin(sopt, &optval, sizeof optval, sizeof optval); _at__at_ -1555,6 +1556,7 _at__at_ case SO_BROADCAST: case SO_OOBINLINE: case SO_TIMESTAMP: + case SO_BINTIME: case SO_NOSIGPIPE: optval = so->so_options & sopt->sopt_name; integer: Index: netinet/ip_input.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v retrieving revision 1.259 diff -u -r1.259 ip_input.c --- netinet/ip_input.c 26 Nov 2003 20:31:13 -0000 1.259 +++ netinet/ip_input.c 19 Jan 2004 20:15:55 -0000 _at__at_ -2062,14 +2062,25 _at__at_ register struct ip *ip; register struct mbuf *m; { - if (inp->inp_socket->so_options & SO_TIMESTAMP) { - struct timeval tv; + if (inp->inp_socket->so_options & (SO_BINTIME | SO_TIMESTAMP)) { + struct bintime bt; - microtime(&tv); - *mp = sbcreatecontrol((caddr_t) &tv, sizeof(tv), - SCM_TIMESTAMP, SOL_SOCKET); - if (*mp) - mp = &(*mp)->m_next; + 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, Index: netinet/udp_usrreq.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/udp_usrreq.c,v retrieving revision 1.143 diff -u -r1.143 udp_usrreq.c --- netinet/udp_usrreq.c 26 Nov 2003 01:40:43 -0000 1.143 +++ netinet/udp_usrreq.c 19 Jan 2004 12:40:01 -0000 _at__at_ -475,7 +475,7 _at__at_ } #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; Index: sys/socket.h =================================================================== RCS file: /home/ncvs/src/sys/sys/socket.h,v retrieving revision 1.74 diff -u -r1.74 socket.h --- sys/socket.h 24 Dec 2003 18:47:43 -0000 1.74 +++ sys/socket.h 19 Jan 2004 13:02:22 -0000 _at__at_ -120,6 +120,7 _at__at_ #define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ #define SO_NOSIGPIPE 0x0800 /* no SIGPIPE from EPIPE */ #define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */ +#define SO_BINTIME 0x2000 /* timestamp received dgram traffic */ #endif /* _at__at_ -462,6 +463,7 _at__at_ #if __BSD_VISIBLE #define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ #define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */ +#define SCM_BINTIME 0x04 /* timestamp (struct bintime) */ #endif #if __BSD_VISIBLE -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk_at_FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.Received on Mon Jan 19 2004 - 12:22:45 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:39 UTC