diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 3ec32571ea2..f06e48bf4a9 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1357,6 +1357,7 @@ sosetopt(so, sopt) 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 @@ sogetopt(so, sopt) case SO_BROADCAST: case SO_OOBINLINE: case SO_TIMESTAMP: + case SO_BINTIME: case SO_NOSIGPIPE: optval = so->so_options & sopt->sopt_name; integer: diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index bb4271e6168..0900202a503 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; + 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, diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 1591fc8c38d..02a0e77eef9 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; diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 0935277724e..34865fd81a6 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -120,6 +120,7 @@ typedef __uid_t uid_t; #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 @@ struct cmsgcred { #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