From owner-freebsd-current@FreeBSD.ORG Mon Jan 19 13:22:45 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A0C9516A4D1 for ; Mon, 19 Jan 2004 13:22:45 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 258BB43D3F for ; Mon, 19 Jan 2004 13:22:32 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.10/8.12.10) with ESMTP id i0JLMVCf099020 for ; Mon, 19 Jan 2004 22:22:31 +0100 (CET) (envelope-from phk@phk.freebsd.dk) To: current@freebsd.org From: Poul-Henning Kamp Date: Mon, 19 Jan 2004 22:22:31 +0100 Message-ID: <99019.1074547351@critter.freebsd.dk> Subject: REVIEW: SO_BINTIME patch X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jan 2004 21:22:45 -0000 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 @@ -1357,6 +1357,7 @@ case SO_REUSEPORT: case SO_OOBINLINE: case SO_TIMESTAMP: + case SO_BINTIME: case SO_NOSIGPIPE: error = sooptcopyin(sopt, &optval, sizeof optval, sizeof optval); @@ -1555,6 +1556,7 @@ 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 @@ -2062,14 +2062,25 @@ 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 @@ -475,7 +475,7 @@ } #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 @@ -120,6 +120,7 @@ #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 /* @@ -462,6 +463,7 @@ #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@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.