diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2019-06-10 23:45:20 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2019-06-10 23:45:20 +0000 |
commit | 7457fd34f44caf5a75380b731c30c169781637ed (patch) | |
tree | 7f77f013e33ec5089a6164a92bb8fba5107b752d /sys/kern | |
parent | 91d63a98840b81557d1fb15f5cf3d0dd09b3a182 (diff) |
add m_microtime for getting the wall clock time associated with a packet
if the packet has the M_TIMESTAMP csum_flag, ph_timestamp is added
to the boottime clock, otherwise it just uses microtime().
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/uipc_mbuf.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index d100d3dd65b..019d0296a8d 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.268 2019/02/10 22:45:58 tedu Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.269 2019/06/10 23:45:19 dlg Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -1445,6 +1445,19 @@ fail: return (NULL); } +void +m_microtime(const struct mbuf *m, struct timeval *tv) +{ + if (ISSET(m->m_pkthdr.csum_flags, M_TIMESTAMP)) { + struct timeval btv, utv; + + NSEC_TO_TIMEVAL(m->m_pkthdr.ph_timestamp, &utv); + microboottime(&btv); + timeradd(&btv, &utv, tv); + } else + microtime(tv); +} + void * m_pool_alloc(struct pool *pp, int flags, int *slowdown) { |