Packet timestamp patch for 2.0.32

ldoolitt@jlab.org
Thu, 22 Jan 1998 10:33:51 -0500 (EST)


This is a tiny patch that makes Linux 2.0.32 timestamp packets
more precisely. It will slow down packet handling a tad, but
on a Pentium or better (that uses do_fast_gettimeoffset) it's
not a big deal. I run this on my Pentium-90, and now the stock
tcpdump shows timestamps with microsecond resolution, via the
SIOCGSTAMP ioctl. This change is recommended by the libpcap
folks. Not recommended for 386's.

I know development is supposed to be on 2.1.x, but I haven't had
time to play with those. What is missing from this patch is some
way to switch between jiffy-based and cycle-counter-based timestamps,
without taking a performance hit, or forcing one more compile-time
option.

- Larry Doolittle <ldoolitt@jlab.org>

--- net/core/dev.c.orig Wed Nov 19 14:23:35 1997
+++ net/core/dev.c Wed Nov 19 14:28:34 1997
@@ -424,7 +424,11 @@
/* copy outgoing packets to any sniffer packet handlers */
if (dev_nit) {
struct packet_type *ptype;
+#if 0
skb->stamp=xtime;
+#else
+ do_gettimeofday(&(skb->stamp));
+#endif
for (ptype = ptype_all; ptype!=NULL; ptype = ptype->next)
{
/* Never send packets back to the socket
@@ -506,7 +510,11 @@
skb->sk = NULL;
skb->free = 1;
if(skb->stamp.tv_sec==0)
+#if 0
skb->stamp = xtime;
+#else
+ do_gettimeofday(&(skb->stamp));
+#endif

/*
* Check that we aren't overdoing things.