Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Mar 1999 21:10:01 -0800 (PST)
From:      Brian Haug <haug@hawaii.conterra.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   bin/10611: timed enhancement
Message-ID:  <199903170510.VAA57238@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/10611; it has been noted by GNATS.

From: Brian Haug <haug@hawaii.conterra.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:  
Subject: bin/10611: timed enhancement
Date: Tue, 16 Mar 1999 00:12:33 -0500 (EST)

 >Number:         10611
 >Category:       bin
 >Synopsis:       timed enhancement
 >Confidential:   no
 >Severity:       non-critical
 >Priority:       low
 >Responsible:    freebsd-bugs
 >State:          open
 >Quarter:        
 >Keywords:       
 >Date-Required:
 >Class:          change-request
 >Submitter-Id:   current-users
 >Arrival-Date:   Mon Mar 15 21:20:01 PST 1999
 >Closed-Date:
 >Last-Modified:
 >Originator:     Brian Haug
 >Release:        FreeBSD 3.1-RELEASE i386 (submitting from different machine)
 >Organization:
 None
 >Environment:
 
 	Generic BSD environemtn with timed protocol in use
 
 >Description:
 
 	Updated man page to correctly describe what happens when timed
 	starts (does doesn't automatically set the date, but will adjust
 	if delta is reasonable).  Added -a option which will only adjust
 	the time with adjtime(2), and a -A option which specifies the max
 	adjustment which will be made with adjtime(2).
 
 >How-To-Repeat:
 
 	Not applicable?
 
 >Fix:
 	
 
 The BRH define was used for me to keep track of the changes.  I suggest
 removinging it.
 *** /usr/src/usr.sbin/timed/timed/timed.c.old	Sun Mar 14 08:27:39 1999
 --- /usr/src/usr.sbin/timed/timed/timed.c	Sun Mar 14 08:30:18 1999
 ***************
 *** 80,85 ****
 --- 80,88 ----
   struct netinfo *nettab = 0;
   struct netinfo *slavenet;
   int Mflag;
 + #ifdef BRH
 + int aflag;
 + #endif
   int justquit = 0;
   int debug;
   
 ***************
 *** 114,119 ****
 --- 117,125 ----
   #endif
   
   static void usage __P((void));
 + #ifdef BRH
 + int MAXADJ = DEF_MAXADJ;
 + #endif
   
   /*
    * The timedaemons synchronize the clocks of hosts in a local area network.
 ***************
 *** 176,183 ****
 --- 182,202 ----
   #endif /* sgi */
   
   	opterr = 0;
 + #ifdef BRH
 + 	while ((c = getopt(argc, argv, "Mtdn:i:F:G:P:aA:")) != -1) {
 + #else
   	while ((c = getopt(argc, argv, "Mtdn:i:F:G:P:")) != -1) {
 + #endif
   		switch (c) {
 + #ifdef BRH
 + 		case 'A':
 + 			MAXADJ = atol(optarg);
 + 			break;
 + 		case 'a':
 + 			/* only do adjtime */
 + 			aflag = 1;
 + 			break;
 + #endif
   		case 'M':
   			Mflag = 1;
   			break;
 ***************
 *** 550,556 ****
 --- 569,579 ----
   "usage: timed [-dtM] [-i net|-n net] [-F host1 host2 ...] [-G netgp]\n");
   #else
   	fprintf(stderr,
 + 	#ifdef BRH
 + "usage: timed [-dtMa] [-A max_adjtime ] [-i net|-n net] [-F host1 host2 ...]\n");
 + 	#else
   "usage: timed [-dtM] [-i net|-n net] [-F host1 host2 ...]\n");
 + 	#endif
   #endif /* HAVENIS */
   #endif /* sgi */
   	exit(1);
 *** /usr/src/usr.sbin/timed/timed/timed.8.old	Tue Oct 21 23:19:49 1997
 --- /usr/src/usr.sbin/timed/timed/timed.8	Sun Mar 14 08:27:14 1999
 ***************
 *** 45,50 ****
 --- 45,52 ----
   .Op Fl i Ar network
   .Op Fl n Ar network
   .Op Fl F Ar host1 host2 ...
 + .Op Fl a
 + .Op Fl A Ar max_adjtime
   .Sh DESCRIPTION
   This
   is a time server daemon and is normally invoked
 ***************
 *** 67,76 ****
   scheme.
   When
   .Nm
 ! is started on a machine, it asks the master for the network time
 ! and sets the host's clock to that time.
 ! After that, it accepts synchronization messages periodically sent by
 ! the master and calls 
   .Xr adjtime 2
   to perform the needed corrections on the host's clock.
   .Pp
 --- 69,77 ----
   scheme.
   When
   .Nm
 ! is started on a machine, searches for a master and starts adjusting the time
 ! based on messages received.
 ! If the clock correction is large the time is explicitly set, otherwise it calls
   .Xr adjtime 2
   to perform the needed corrections on the host's clock.
   .Pp
 ***************
 *** 153,158 ****
 --- 154,172 ----
   If it finds masters on more than one network, it chooses one network
   on which to be a "slave," and then periodically checks the other
   networks to see if the masters there have disappeared.
 + The
 + .Fl a
 + option forces
 + .Nm timed
 + to only adjust the time using the 
 + .Xr adjtime 2 ) ,
 + system call.
 + The
 + .Fl A
 + option forces
 + .Nm timed
 + to explicitly set the time if the difference in the clocks exceeds
 + the value of max_adjtime seconds.
   .Pp
   One way to synchronize a group of machines is to use an
   .Tn NTP
 *** /usr/src/usr.sbin/timed/timed/globals.h.old	Fri Oct 31 05:33:05 1997
 --- /usr/src/usr.sbin/timed/timed/globals.h	Sun Mar 14 08:48:05 1999
 ***************
 *** 1,3 ****
 --- 1,4 ----
 + #define BRH
   /*-
    * Copyright (c) 1985, 1993
    *	The Regents of the University of California.  All rights reserved.
 ***************
 *** 73,79 ****
 --- 74,86 ----
   
   
   #define SAMPLEINTVL	240		/* synch() freq for master in sec */
 + #ifdef BRH
 + #define MAXADJ	(maxadj)		/* now a variable */
 + extern int maxadj;
 + #define	DEF_MAXADJ	20		/* max adjtime() correction in sec */
 + #else
   #define	MAXADJ		20		/* max adjtime() correction in sec */
 + #endif
   
   #define MAX_TRIM	3000000		/* max drift in nsec/sec, 0.3% */
   #define BIG_ADJ		(MAX_TRIM/1000*SAMPLEINTVL*2)	/* max good adj */
 *** /usr/src/usr.sbin/timed/timed/master.c.old	Mon Mar 15 10:20:57 1999
 --- /usr/src/usr.sbin/timed/timed/master.c	Sun Mar 14 08:32:36 1999
 ***************
 *** 379,385 ****
 --- 379,389 ----
   	adj_msg_time(msg,&otime);
   
   	timevalsub(&ntime, &msg->tsp_time, &otime);
 + 	#ifdef BRH
 + 	if (aflag || (ntime.tv_sec < MAXADJ && ntime.tv_sec > -MAXADJ)) {
 + 	#else
   	if (ntime.tv_sec < MAXADJ && ntime.tv_sec > -MAXADJ) {
 + 	#endif
   		/*
   		 * do not change the clock if we can adjust it
   		 */
 *** /usr/src/usr.sbin/timed/timed/slave.c.old	Mon Mar 15 09:57:54 1999
 --- /usr/src/usr.sbin/timed/timed/slave.c	Sun Mar 14 08:34:26 1999
 ***************
 *** 282,288 ****
 --- 282,292 ----
   
   			setmaster(msg);
   			timevalsub(&ntime, &msg->tsp_time, &otime);
 + #ifdef BRH
 + 			if (aflag || (ntime.tv_sec < MAXADJ && ntime.tv_sec > -MAXADJ)) {
 + #else
   			if (ntime.tv_sec < MAXADJ && ntime.tv_sec > -MAXADJ) {
 + #endif
   				/*
   				 * do not change the clock if we can adjust it
   				 */
 *** /usr/src/usr.sbin/timed/timed/correct.c.old	Mon Mar 15 10:23:28 1999
 --- /usr/src/usr.sbin/timed/timed/correct.c	Mon Mar 15 10:22:40 1999
 ***************
 *** 128,134 ****
 --- 128,138 ----
   		return;
   
   	adj = *corr;
 + 	#ifdef BRH
 + 	if (aflag || (adj.tv_sec < MAXADJ && adj.tv_sec > - MAXADJ)) {
 + 	#else
   	if (adj.tv_sec < MAXADJ && adj.tv_sec > - MAXADJ) {
 + 	#endif
   		delta = adj.tv_sec*1000000 + adj.tv_usec;
   		/* If the correction is less than the minimum round
   		 *	trip time for an ICMP packet, and thus
 
 >Release-Note:
 >Audit-Trail:
 >Unformatted:
 
 
 To Unsubscribe: send mail to majordomo@FreeBSD.org
 with "unsubscribe freebsd-bugs" in the body of the message
 
 
 
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199903170510.VAA57238>