git: 2220b66fe0d5 - main - Add mbuf_tstmp2timeval()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 05 Oct 2022 23:12:23 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2220b66fe0d5c2dfdaf3c22dcec3771665874d69 commit 2220b66fe0d5c2dfdaf3c22dcec3771665874d69 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-10-03 22:49:45 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-10-05 21:38:13 +0000 Add mbuf_tstmp2timeval() Reviewed by: hselasky, jkim, rscheff Sponsored by: NVIDIA networking MFC after: 1 week Differential revision: https://reviews.freebsd.org/D36870 --- sys/netinet/tcp_stacks/bbr.c | 6 ++---- sys/netinet/tcp_stacks/rack.c | 3 +-- sys/sys/mbuf.h | 14 +++++++++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index dd6b823c6142..5c5c1a2f9986 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -2261,8 +2261,7 @@ bbr_log_ack_event(struct tcp_bbr *bbr, struct tcphdr *th, struct tcpopt *to, uin 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 @@ bbr_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, } } 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 index de88e47e5e41..813cf0a57c3f 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -14631,8 +14631,7 @@ rack_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, } } 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 index fa72314f78ed..97bfd56536e0 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1675,12 +1675,24 @@ mbuf_tstmp2timespec(struct mbuf *m, struct timespec *ts) { 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);