svn commit: r351030 - head/sbin/ping

Alan Somers asomers at FreeBSD.org
Wed Aug 14 16:45:10 UTC 2019


Author: asomers
Date: Wed Aug 14 16:45:09 2019
New Revision: 351030
URL: https://svnweb.freebsd.org/changeset/base/351030

Log:
  ping: fix triptime calculation after r350998
  
  That revision changed the internal clock to the monotonic, but neglected to
  change the datagram's timestamp source.
  
  Reported by:	Oliver Hartmann, Michael Butler
  Reviewed by:	Ján Sučan <sucanjan at gmail.com>, allanjude
  MFC after:	2 weeks
  MFC-With:	r350998
  Differential Revision:	https://reviews.freebsd.org/D21258

Modified:
  head/sbin/ping/ping.c

Modified: head/sbin/ping/ping.c
==============================================================================
--- head/sbin/ping/ping.c	Wed Aug 14 16:40:23 2019	(r351029)
+++ head/sbin/ping/ping.c	Wed Aug 14 16:45:09 2019	(r351030)
@@ -760,9 +760,15 @@ main(int argc, char *const *argv)
 		}
 	}
 #ifdef SO_TIMESTAMP
-	{ int on = 1;
-	if (setsockopt(srecv, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on)) < 0)
-		err(EX_OSERR, "setsockopt SO_TIMESTAMP");
+	{
+		int on = 1;
+		int ts_clock = SO_TS_MONOTONIC;
+		if (setsockopt(srecv, SOL_SOCKET, SO_TIMESTAMP, &on,
+		    sizeof(on)) < 0)
+			err(EX_OSERR, "setsockopt SO_TIMESTAMP");
+		if (setsockopt(srecv, SOL_SOCKET, SO_TS_CLOCK, &ts_clock,
+		    sizeof(ts_clock)) < 0)
+			err(EX_OSERR, "setsockopt SO_TS_CLOCK");
 	}
 #endif
 	if (sweepmax) {


More information about the svn-src-all mailing list