an mbuf timestamp is set by hw when a packet is rxed, and is then used
by the socket layer and things like ntpd, but is also used by bpf when
it provides packet timestamps.

the timestamp is only valid on rxed packets though. when they leave the
stack they should not be used anymore. on the way out of the stack it is
more correct to read the clock for the time. this clears the timestamp
bit on the way out so it can't be used anymore.

ok?

Index: if.c
===================================================================
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.620
diff -u -p -r1.620 if.c
--- if.c        3 Oct 2020 00:23:55 -0000       1.620
+++ if.c        12 Dec 2020 00:24:28 -0000
@@ -682,6 +682,8 @@ if_qstart_compat(struct ifqueue *ifq)
 int
 if_enqueue(struct ifnet *ifp, struct mbuf *m)
 {
+       CLR(m->m_pkthdr.csum_flags, M_TIMESTAMP);
+
 #if NPF > 0
        if (m->m_pkthdr.pf.delay > 0)
                return (pf_delay_pkt(m, ifp->if_index));

Reply via email to