The branch main has been updated by jkim: URL: https://cgit.FreeBSD.org/src/commit/?id=56cdab3372690a28ef7daf6cdb1a2146cf3123f9
commit 56cdab3372690a28ef7daf6cdb1a2146cf3123f9 Author: Jung-uk Kim <[email protected]> AuthorDate: 2022-10-03 22:45:56 +0000 Commit: Jung-uk Kim <[email protected]> CommitDate: 2022-10-03 22:53:40 +0000 bpf: obtain timestamps from controller via pkthdr if available r325506 (3cf8254f1ea9) extended struct pkthdr to add packet timestamp in mbuf(9) chain. For example, cxgbe(4) and mlx5en(4) support this feature. Use the timestamp for bpf(4) if it is available. Reviewed by: hselasky, kib, np MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D36868 --- sys/net/bpf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 4c8c77d1e948..eded898d2fc3 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -2265,6 +2265,7 @@ bpf_ts_quality(int tstype) static int bpf_gettime(struct bintime *bt, int tstype, struct mbuf *m) { + struct timespec ts; struct m_tag *tag; int quality; @@ -2273,6 +2274,11 @@ bpf_gettime(struct bintime *bt, int tstype, struct mbuf *m) return (quality); if (m != NULL) { + if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | M_TSTMP)) { + mbuf_tstmp2timespec(m, &ts); + timespec2bintime(&ts, bt); + return (BPF_TSTAMP_EXTERN); + } tag = m_tag_locate(m, MTAG_BPF, MTAG_BPF_TIMESTAMP, NULL); if (tag != NULL) { *bt = *(struct bintime *)(tag + 1);
