From 7457fd34f44caf5a75380b731c30c169781637ed Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Mon, 10 Jun 2019 23:45:20 +0000 Subject: 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(). --- sys/kern/uipc_mbuf.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'sys/kern') 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) { -- cgit v1.2.3