System: ntp version 3.4 Patch #: 6 Priority: Add bit in flags which allow a peer to be synced to. Changed a char to a bit field so that it is always signed. There is now a run-time option that can be specified in the configuration which specifies if we will synchronize to unconfigured hosts. Fixes to receive() logic state machine. Add support for "trusting" directive in NTP configuration file. It allows you to specify at run time if non-configured peers will be synced to. More fixes. Make sure that compliance is not negative. Bug fix for VAX_COMPILER_FLT_BUG test, start of test for Sun problem. From: Description: Repeat-By: Fix: From rn, say "| patch -p -N -d DIR", where DIR is your ntp source directory. Outside of rn, say "cd DIR; patch -p -N #define PATCHLEVEL 6 Index: ntp.h *** ntp.h.old Fri Mar 31 16:39:24 1989 --- ntp.h Fri Mar 31 16:39:25 1989 *************** *** 1,7 **** ! /* $Source: /usr/users/louie/ntp/RCS/ntp.h,v $ $Revision: 3.4.1.3 $ $Date: 89/03/29 12:26:18 $ */ /* * $Log: ntp.h,v $ * Revision 3.4.1.3 89/03/29 12:26:18 louie * Removed some unused #defines. Replaced MAXSTRATUM with NTP_INFIN per new * spec. The variable 'mode' in the peer structure has been renamed 'hmode' --- 1,11 ---- ! /* $Source: /usr/users/louie/ntp/RCS/ntp.h,v $ $Revision: 3.4.1.4 $ $Date: 89/03/31 16:34:50 $ */ /* * $Log: ntp.h,v $ + * Revision 3.4.1.4 89/03/31 16:34:50 louie + * Add bit in flags which allow a peer to be synced to. Changed a char to a bit + * field so that it is always signed. + * * Revision 3.4.1.3 89/03/29 12:26:18 louie * Removed some unused #defines. Replaced MAXSTRATUM with NTP_INFIN per new * spec. The variable 'mode' in the peer structure has been renamed 'hmode' *************** *** 264,273 **** #define INFO_QUERY 62 /* **** THIS implementation dependent **** */ #define INFO_REPLY 63 /* **** THIS implementation dependent **** */ - #define ACTIVE 0x01 /* opposite of PASIVE */ - #define MEDIAN 0x02 - /* ================= table 3.2 Peer Variables ================= */ struct ntp_peer { struct ntp_peer *next, *prev; --- 268,274 ---- *************** *** 276,281 **** --- 277,283 ---- int flags; /* local flags */ #define PEER_FL_CONFIG 1 #define PEER_FL_AUTHENABLE 2 + #define PEER_FL_SYNC 0x1000 /* peer can bet sync'd to */ #define PEER_FL_BCAST 0x2000 /* broadcast peer */ #define PEER_FL_SELECTED 0x8000 /* actually used by query routine */ *************** *** 351,357 **** u_char leap; u_char stratum; u_char ppoll; ! char precision; u_char hpoll; u_char filler1; --- 353,359 ---- u_char leap; u_char stratum; u_char ppoll; ! int precision:8; u_char hpoll; u_char filler1; Index: ntp_proto.c *** ntp_proto.c.old Fri Mar 31 16:39:33 1989 --- ntp_proto.c Fri Mar 31 16:39:35 1989 *************** *** 1,5 **** #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp_proto.c,v $ $Revision: 3.4.1.4 $ $Date: 89/03/29 12:29:10 $"; #endif /* --- 1,5 ---- #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp_proto.c,v $ $Revision: 3.4.1.5 $ $Date: 89/03/31 16:36:38 $"; #endif /* *************** *** 10,15 **** --- 10,20 ---- * * * $Log: ntp_proto.c,v $ + * Revision 3.4.1.5 89/03/31 16:36:38 louie + * There is now a run-time option that can be specified in the configuration + * which specifies if we will synchronize to unconfigured hosts. Fixes to + * receive() logic state machine. + * * Revision 3.4.1.4 89/03/29 12:29:10 louie * The variable 'mode' in the peer structure was renamed 'hmode'. Add * poll_update() calls in a few places per Mills. The receive() procedure is *************** *** 105,110 **** --- 110,116 ---- extern int debug; extern void dump_pkt(); #endif + extern int trusting; extern struct sysdata sys; extern struct list peer_list; extern struct ntp_peer *check_peer(); *************** *** 316,321 **** --- 322,340 ---- this from */ peer->hmode = MODE_SYM_PAS; clear(peer); + #if 1 + /* + * If we decide to consider any random NTP peer that might + * come as a peer we might sync to, then set the PEER_FL_SYNC + * flag in the peer structure. + * + * Alternatively, we could change the hmode to MODE_SERVER, + * but then the peer state wouldn't be persistant. + */ + if (trusting) + peer->flags |= PEER_FL_SYNC; + #endif + enqueue(&peer_list, peer); } *************** *** 351,367 **** } #endif #ifdef DEBUG ! if (peer_mode < MODE_SYM_ACT || peer_mode > MODE_BROADCAST || ! peer->hmode < MODE_SYM_ACT || peer->hmode > MODE_BROADCAST) { ! printf("Bogus peer_mode or peer->hmode\n"); abort(); } - #endif switch (actions[peer_mode - 1][peer->hmode - 1]) { case ACT_RECV: ! if (!(peer->flags & PEER_FL_CONFIG == 0 && STRMCMP(pkt->stratum, >, sys.stratum))) { peer->reach |= 1; process_packet(dst, pkt, tvp, peer); --- 370,393 ---- } #endif + if (peer_mode < MODE_SYM_ACT || peer_mode > MODE_BROADCAST) { + syslog(LOG_DEBUG, "Bogus peer_mode %d from %s", peer_mode, + ntoa(dst->sin_addr)); #ifdef DEBUG ! if (debug > 3) abort(); ! #endif ! return; ! } ! ! if (peer->hmode < MODE_SYM_ACT || peer->hmode > MODE_BROADCAST) { ! syslog(LOG_ERR, "Bogus hmode %d for peer %s", peer->hmode, ! ntoa(peer->src.sin_addr)); abort(); } switch (actions[peer_mode - 1][peer->hmode - 1]) { case ACT_RECV: ! if (!(((peer->flags & PEER_FL_CONFIG) == 0) && STRMCMP(pkt->stratum, >, sys.stratum))) { peer->reach |= 1; process_packet(dst, pkt, tvp, peer); *************** *** 369,386 **** } /* Note fall-through */ case ACT_ERROR: ! if ((peer != &dummy_peer) && (peer->flags & PEER_FL_CONFIG)) ! demobilize(peer); ! return; case ACT_PKT: ! if (!((peer->flags & PEER_FL_CONFIG == 0) && ! STRMCMP(pkt->stratum, >, sys.stratum))) { peer->reach |= 1; process_packet(dst, pkt, tvp, peer); break; } ! /* note fall-through */ case ACT_XMIT: process_packet(dst, pkt, tvp, peer); poll_update(peer, peer->ppoll); --- 395,413 ---- } /* Note fall-through */ case ACT_ERROR: ! if (((peer->flags & PEER_FL_CONFIG) == 0) && ! (peer != &dummy_peer)) ! demobilize(&peer_list, peer); ! break; case ACT_PKT: ! if (!(((peer->flags & PEER_FL_CONFIG) == 0) && ! STRMCMP(pkt->stratum, >, sys.stratum))) { peer->reach |= 1; process_packet(dst, pkt, tvp, peer); break; } ! /* Note fall-through */ case ACT_XMIT: process_packet(dst, pkt, tvp, peer); poll_update(peer, peer->ppoll); *************** *** 989,995 **** inet_ntoa(peer->src.sin_addr), peer->stratum); #endif /* Sanity check 0. ?? */ ! if (!(peer->flags & PEER_FL_CONFIG)) return(0); /* Sanity check 1. */ --- 1016,1022 ---- inet_ntoa(peer->src.sin_addr), peer->stratum); #endif /* Sanity check 0. ?? */ ! if (!(peer->flags & PEER_FL_SYNC)) return(0); /* Sanity check 1. */ *************** *** 1020,1026 **** The peer clock must be synchronized... and the interval since the peer clock was last updated satisfy ! peer.org - peer.reftime < NTP.MAXAGS */ if (peer->leap == ALARM || (ul_fixed_to_double(&peer->org) --- 1047,1053 ---- The peer clock must be synchronized... and the interval since the peer clock was last updated satisfy ! peer.org - peer.reftime < NTP.MAXAGE */ if (peer->leap == ALARM || (ul_fixed_to_double(&peer->org) Index: ntpd.c *** ntpd.c.old Fri Mar 31 16:39:44 1989 --- ntpd.c Fri Mar 31 16:39:46 1989 *************** *** 1,9 **** #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntpd.c,v $ $Revision: 3.4.1.4 $ $Date: 89/03/29 12:30:46 $"; #endif lint /* * $Log: ntpd.c,v $ * Revision 3.4.1.4 89/03/29 12:30:46 louie * peer->mode has been renamed peer->hmode. Drop PEER_FL_SYNC since the * PEER_FL_CONFIG flag means much the same thing. --- 1,13 ---- #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntpd.c,v $ $Revision: 3.4.1.5 $ $Date: 89/03/31 16:37:49 $"; #endif lint /* * $Log: ntpd.c,v $ + * Revision 3.4.1.5 89/03/31 16:37:49 louie + * Add support for "trusting" directive in NTP configuration file. It allows + * you to specify at run time if non-configured peers will be synced to. + * * Revision 3.4.1.4 89/03/29 12:30:46 louie * peer->mode has been renamed peer->hmode. Drop PEER_FL_SYNC since the * PEER_FL_CONFIG flag means much the same thing. *************** *** 114,119 **** --- 118,124 ---- int doset = 1; int ticked; int selfds; + int trusting = 1; double WayTooBig = WAYTOOBIG; unsigned long clock_watchdog; *************** *** 242,253 **** setlogmask(LOG_UPTO(LOG_INFO)); #endif /* LOG_DAEMON */ ! syslog(LOG_NOTICE, "%s version $Revision: 3.4.1.4 $", prog_name); syslog(LOG_NOTICE, "patchlevel %d", PATCHLEVEL); #ifdef DEBUG if (debug) ! printf("%s version $Revision: 3.4.1.4 $ patchlevel %d\n", prog_name, PATCHLEVEL); #endif (void) setpriority(PRIO_PROCESS, 0, -10); --- 247,258 ---- setlogmask(LOG_UPTO(LOG_INFO)); #endif /* LOG_DAEMON */ ! syslog(LOG_NOTICE, "%s version $Revision: 3.4.1.5 $", prog_name); syslog(LOG_NOTICE, "patchlevel %d", PATCHLEVEL); #ifdef DEBUG if (debug) ! printf("%s version $Revision: 3.4.1.5 $ patchlevel %d\n", prog_name, PATCHLEVEL); #endif (void) setpriority(PRIO_PROCESS, 0, -10); *************** *** 692,697 **** --- 697,713 ---- if (strcmp(name, "maxpeers") == 0) { if (fscanf(fp, "%d", &sys.maxpeers) != 1) error = TRUE; + } else if (strcmp(name, "trusting") == 0) { + if (fscanf(fp, "%s", name) != 1) + error = TRUE; + else { + if (*name == 'Y' || *name == 'y') { + trusting = 1; + } else if (*name == 'N' || *name == 'n') { + trusting = 0; + } else + trusting = atoi(name); + } } else if (strcmp(name, "debuglevel") == 0) { if (fscanf(fp, "%d", &debuglevel) != 1) error = TRUE; *************** *** 798,811 **** --- 814,830 ---- peer->hmode = MODE_SYM_ACT; peer->stopwatch = stagger; stagger += (1<flags |= PEER_FL_SYNC; break; case MODE_CLIENT: /* "server" */ peer->hmode = MODE_CLIENT; peer->stopwatch = stagger; stagger += (1<flags |= PEER_FL_SYNC; break; case MODE_SYM_PAS: /* "passive" */ peer->hmode = MODE_SYM_PAS; + peer->flags |= PEER_FL_SYNC; break; default: printf("can't happen\n"); Index: stat.pl Prereq: 3.4.1.3 *** stat.pl.old Fri Mar 31 16:39:51 1989 --- stat.pl Fri Mar 31 16:39:52 1989 *************** *** 1,5 **** #!/usr/bin/perl ! # $Source: /usr/users/louie/ntp/RCS/stat.pl,v $ $Revision: 3.4.1.3 $ $Date: 89/03/29 12:47:32 $ # # Make plots from ntpd syslog messages. Invoked as: # --- 1,5 ---- #!/usr/bin/perl ! # $Source: /usr/users/louie/ntp/RCS/stat.pl,v $ $Revision: 3.4.1.4 $ $Date: 89/03/31 16:38:42 $ # # Make plots from ntpd syslog messages. Invoked as: # *************** *** 94,100 **** $clk{$in[8]} = $clocks++; } $t = $t - $start; ! print CLK $t,$clk{$in[8]},"\n"; } if (/.* ntpd\[[0-9]*\]: adjust:/) { --- 94,100 ---- $clk{$in[8]} = $clocks++; } $t = $t - $start; ! print CLK $t," ",$clk{$in[8]},"\n"; } if (/.* ntpd\[[0-9]*\]: adjust:/) { *************** *** 123,128 **** --- 123,131 ---- # # Scale compliance by T (2**18) # + if ( $in[15] < 0 ) { + $in[15] = -$in[15]; + } print COMP $t," ",$in[15] * 2**18, "\n"; } } *************** *** 132,138 **** } else { $last = int($t); } ! print "$recs records spanning %t hours.\n"; close OFF; close DRIFT; --- 135,141 ---- } else { $last = int($t); } ! print "$recs records spanning $t hours.\n"; close OFF; close DRIFT; *************** *** 206,213 **** unlink "stats.clk"; } - ;# $Header: /usr/users/louie/ntp/RCS/stat.pl,v 3.4.1.3 89/03/29 12:47:32 louie Exp $ - ;# Process single-character switches with switch clustering. Pass one argument ;# which is a string containing all switches that take an argument. For each ;# switch found, sets $opt_x (where x is the switch name) to the value of the --- 209,214 ---- Index: test.c *** test.c.old Fri Mar 31 16:39:55 1989 --- test.c Fri Mar 31 16:39:55 1989 *************** *** 1,9 **** #ifndef lint ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/test.c,v $ $Revision: 3.4.1.1 $ $Date: 89/03/22 18:32:26 $"; #endif /* * $Log: test.c,v $ * Revision 3.4.1.1 89/03/22 18:32:26 louie * patch3: Use new RCS headers. * --- 1,12 ---- #ifndef lint ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/test.c,v $ $Revision: 3.4.1.2 $ $Date: 89/03/31 16:39:19 $"; #endif /* * $Log: test.c,v $ + * Revision 3.4.1.2 89/03/31 16:39:19 louie + * Bug fix for VAX_COMPILER_FLT_BUG test, start of test for Sun problem. + * * Revision 3.4.1.1 89/03/22 18:32:26 louie * patch3: Use new RCS headers. * *************** *** 70,78 **** --- 73,85 ---- exit(2); if (test3(1)) exit(3); + if (test4(1)) + exit(4); } else { if (test3(0)) exit(3); + if (test4(0)) + exit(4); } exit(0); } *************** *** 124,134 **** dbl = ul; #ifdef VAX_COMPILER_FLT_BUG ! if (dbl < 0.0) a += 4.294967296e9; #endif if (dbl != 2147483648.0) { ! printf("test3 fails %lu != %f - can't convert from unsigned long to float\n", ! ul, dbl); return 1; } else { if (v) --- 131,142 ---- dbl = ul; #ifdef VAX_COMPILER_FLT_BUG ! if (dbl < 0.0) dbl += 4.294967296e9; #endif if (dbl != 2147483648.0) { ! printf("test3 fails: can't convert from unsigned long to float\n"); ! printf(" (%lu != %f)\n", ul, dbl); ! printf("Try defining VAX_COMPILER_FLT_BUG in the Makefile.\n"); return 1; } else { if (v) *************** *** 137,140 **** --- 145,163 ---- } } + test4(v) + int v; + { + /* + * Need a test for the SUN 2^31 - 2^32 problem (in ntpsubs.c). Anyone + * with a Sun out there that can come up with one? + * + */ + if (0) { + printf("test4 fails:\n"); + printf("Try defining SUN_FLT_BUG in the Makefile\n"); + return 1; + } + return 0; + } .