diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -2261,8 +2261,7 @@ log.u_bbr.lt_epoch = 0; } if (m->m_flags & M_TSTMP_LRO) { - tv.tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000; - tv.tv_usec = (m->m_pkthdr.rcv_tstmp % 1000000000) / 1000; + mbuf_tstmp2timeval(m, &tv); log.u_bbr.flex5 = tcp_tv_to_usectick(&tv); } else { /* No arrival timestamp */ @@ -11691,8 +11690,7 @@ } } if (m->m_flags & M_TSTMP_LRO) { - tv.tv_sec = m->m_pkthdr.rcv_tstmp /1000000000; - tv.tv_usec = (m->m_pkthdr.rcv_tstmp % 1000000000)/1000; + mbuf_tstmp2timeval(m, &tv); } else { /* Should not be should we kassert instead? */ tcp_get_usecs(&tv); diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -14631,8 +14631,7 @@ } } if (m->m_flags & M_TSTMP_LRO) { - tv.tv_sec = m->m_pkthdr.rcv_tstmp /1000000000; - tv.tv_usec = (m->m_pkthdr.rcv_tstmp % 1000000000)/1000; + mbuf_tstmp2timeval(m, &tv); } else { /* Should not be should we kassert instead? */ tcp_get_usecs(&tv); diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1675,12 +1675,24 @@ { KASSERT((m->m_flags & M_PKTHDR) != 0, ("mbuf %p no M_PKTHDR", m)); - KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0, ("mbuf %p no M_TSTMP or M_TSTMP_LRO", m)); + KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0, + ("mbuf %p no M_TSTMP or M_TSTMP_LRO", m)); ts->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000; ts->tv_nsec = m->m_pkthdr.rcv_tstmp % 1000000000; } #endif +static inline void +mbuf_tstmp2timeval(struct mbuf *m, struct timeval *tv) +{ + + KASSERT((m->m_flags & M_PKTHDR) != 0, ("mbuf %p no M_PKTHDR", m)); + KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0, + ("mbuf %p no M_TSTMP or M_TSTMP_LRO", m)); + tv->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000; + tv->tv_usec = (m->m_pkthdr.rcv_tstmp % 1000000000) / 1000; +} + #ifdef DEBUGNET /* Invoked from the debugnet client code. */ void debugnet_mbuf_drain(void);