[Git][NTPsec/ntpsec][depun] 4 commits: Restore support for peer (MODE_ACTIVE) packets, Issue #482

Ian Bruene gitlab at mg.gitlab.com
Tue May 8 17:03:26 UTC 2018


Ian Bruene pushed to branch depun at NTPsec / ntpsec


Commits:
7f1a350a by Hal Murray at 2018-05-02T19:32:36Z
Restore support for peer (MODE_ACTIVE) packets, Issue #482

- - - - -
0cac4804 by Hal Murray at 2018-05-03T04:06:42Z
Fix compiler warnings, Issue #479

- - - - -
42384096 by Matt Selsky at 2018-05-03T06:22:49Z
Gitlab default docker image now explicitly requires the netbase package

...in order to get /etc/services

- - - - -
1925aa36 by Ian Bruene at 2018-05-08T17:03:13Z
Changed fast_xmit to use recv_buf->pkt structure.

- - - - -


3 changed files:

- .gitlab-ci.yml
- ntpd/ntp_proto.c
- tests/ntpd/leapsec.c


Changes:

=====================================
.gitlab-ci.yml
=====================================
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -64,7 +64,7 @@ gitlab-alpine-basic:
 gitlab-basic:
   <<: *job_definition
   script:
-    - apt-get update -qq && apt-get install -y -qq bison libcap-dev pps-tools python-dev
+    - apt-get update -qq && apt-get install -y -qq netbase bison libcap-dev pps-tools python-dev
     - python ./waf configure build check
   tags:
     - gitlab-org
@@ -72,7 +72,7 @@ gitlab-basic:
 gitlab-refclocks:
   <<: *job_definition
   script:
-    - apt-get update -qq && apt-get install -y -qq bison libcap-dev pps-tools python-dev
+    - apt-get update -qq && apt-get install -y -qq netbase bison libcap-dev pps-tools python-dev
     - python ./waf configure --refclock=all build check
   tags:
     - gitlab-org
@@ -397,7 +397,7 @@ python3:
 python-coverage:
   <<: *job_definition
   script:
-    - apt-get update -qq && apt-get install -y -qq bison python-dev python-coverage
+    - apt-get update -qq && apt-get install -y -qq netbase bison python-dev python-coverage
     - python ./waf configure build check
     - for i in build/main/tests/pylib/test_*; do python-coverage run -a --source build/main/pylib $i; done
     - python-coverage report
@@ -407,7 +407,7 @@ python-coverage:
 clang-basic:
   <<: *job_definition
   script:
-    - apt-get update -qq && apt-get install -y -qq bison libcap-dev pps-tools python-dev clang
+    - apt-get update -qq && apt-get install -y -qq netbase bison libcap-dev pps-tools python-dev clang
     - python ./waf configure --check-c-compiler=clang build check
   tags:
     - gitlab-org
@@ -415,7 +415,7 @@ clang-basic:
 clang-refclocks:
   <<: *job_definition
   script:
-    - apt-get update -qq && apt-get install -y -qq bison libcap-dev pps-tools python-dev clang
+    - apt-get update -qq && apt-get install -y -qq netbase bison libcap-dev pps-tools python-dev clang
     - python ./waf configure --check-c-compiler=clang --refclock=all build check
   tags:
     - gitlab-org


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -792,13 +792,12 @@ receive(
 	}
 
 	switch (PKT_MODE(rbufp->pkt.li_vn_mode)) {
-	    case MODE_CLIENT:
-		/* Request for us as a server. */
+	    case MODE_ACTIVE:  /* remote site using "peer" in config file */
+	    case MODE_CLIENT:  /* Request for us as a server. */
 		handle_fastxmit(rbufp, restrict_mask, authenticated);
 		sys_processed++;
 		break;
-	    case MODE_SERVER:
-		/* Reply to our request. */
+	    case MODE_SERVER:  /* Reply to our request. */
 		handle_procpkt(rbufp, peer);
 		sys_processed++;
 		peer->processed++;
@@ -2212,8 +2211,6 @@ fast_xmit(
 	)
 {
 	struct pkt xpkt;	/* transmit packet structure */
-	struct pkt *rpkt;	/* receive packet structure */
-	struct pkt pkt_core; /* recieve packet copy target */
 	l_fp	xmt_tx, xmt_ty;
 	size_t	sendlen;
 
@@ -2225,8 +2222,6 @@ fast_xmit(
 	 * control and not strictly specification compliant, but doesn't
 	 * break anything.
 	 */
-	unmarshall_pkt(&pkt_core, rbufp);
-	rpkt = &pkt_core;
 
 	/*
 	 * If this is a kiss-o'-death (KoD) packet, show leap
@@ -2238,17 +2233,21 @@ fast_xmit(
 	if (flags & RES_KOD) {
 		sys_kodsent++;
 		xpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOTINSYNC,
-		    PKT_VERSION(rpkt->li_vn_mode), xmode);
+		    PKT_VERSION(rbufp->pkt.li_vn_mode), xmode);
 		xpkt.stratum = STRATUM_PKT_UNSPEC;
-		xpkt.ppoll = max(rpkt->ppoll, ntp_minpoll);
-		xpkt.precision = rpkt->precision;
+		xpkt.ppoll = max(rbufp->pkt.ppoll, ntp_minpoll);
+		xpkt.precision = rbufp->pkt.precision;
 		memcpy(&xpkt.refid, "RATE", REFIDLEN);
-		xpkt.rootdelay = rpkt->rootdelay;
-		xpkt.rootdisp = rpkt->rootdisp;
-		xpkt.reftime = rpkt->reftime;
-		xpkt.org = rpkt->xmt;
-		xpkt.rec = rpkt->xmt;
-		xpkt.xmt = rpkt->xmt;
+		xpkt.rootdelay = htonl(rbufp->pkt.rootdelay);
+		xpkt.rootdisp = htonl(rbufp->pkt.rootdisp);
+		xpkt.reftime.l_ui = htonl(rbufp->pkt.reftime >> 32);
+		xpkt.reftime.l_uf = htonl(rbufp->pkt.reftime & 0xFFFFFFFF);
+		xpkt.org.l_ui = htonl(rbufp->pkt.xmt >> 32);
+		xpkt.org.l_uf = htonl(rbufp->pkt.xmt & 0xFFFFFFFF);
+		xpkt.rec.l_ui = htonl(rbufp->pkt.xmt >> 32);
+		xpkt.rec.l_uf = htonl(rbufp->pkt.xmt & 0xFFFFFFFF);
+		xpkt.xmt.l_ui = htonl(rbufp->pkt.xmt >> 32);
+		xpkt.xmt.l_uf = htonl(rbufp->pkt.xmt & 0xFFFFFFFF);
 
 	/*
 	 * This is a normal packet. Use the system variables.
@@ -2270,9 +2269,9 @@ fast_xmit(
 		 * the transmit/receive times.
 		 */
 		xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_leap,
-		    PKT_VERSION(rpkt->li_vn_mode), xmode);
+		    PKT_VERSION(rbufp->pkt.li_vn_mode), xmode);
 		xpkt.stratum = STRATUM_TO_PKT(sys_stratum);
-		xpkt.ppoll = max(rpkt->ppoll, ntp_minpoll);
+		xpkt.ppoll = max(rbufp->pkt.ppoll, ntp_minpoll);
 		xpkt.precision = sys_precision;
 		xpkt.refid = sys_refid;
 		xpkt.rootdelay = HTONS_FP(DTOUFP(sys_rootdelay));
@@ -2293,7 +2292,8 @@ fast_xmit(
 		xpkt.reftime = htonl_fp(sys_reftime);
 #endif
 
-		xpkt.org = rpkt->xmt;
+		xpkt.org.l_ui = htonl(rbufp->pkt.xmt >> 32);
+		xpkt.org.l_uf = htonl(rbufp->pkt.xmt & 0xFFFFFFFF);
 
 #ifdef ENABLE_LEAP_SMEAR
 		this_recv_time = rbufp->recv_time;


=====================================
tests/ntpd/leapsec.c
=====================================
--- a/tests/ntpd/leapsec.c
+++ b/tests/ntpd/leapsec.c
@@ -1,3 +1,5 @@
+#include <stdarg.h>
+
 #include "config.h"
 
 #include "unity.h"
@@ -424,6 +426,23 @@ TEST(leapsec, loadFileTTL) {
 	TEST_ASSERT_EQUAL(-1, rc);
 }
 
+
+// Hack to avoid compiler warnings from gcc 8.0
+// We should be able to cast fprintf, but that gets:
+// ../../tests/ntpd/leapsec.c: In function ‘TEST_leapsec_lsQueryPristineState_’:
+// ../../tests/ntpd/leapsec.c:434:19: warning: cast between incompatible function types from ‘int (*)(FILE * restrict,  const char * restrict,  ...)’ {aka ‘int (*)(struct _IO_FILE * restrict,  const char * restrict,  ...)’} to ‘void (*)(void *, const char *, ...)’ [-Wcast-function-type]
+//   leapsec_dump(pt, (leapsec_dumper)fprintf, stdout);
+static void
+my_fprintf(FILE *stream, const char *fmt, ...) {
+	va_list  ap;
+
+	va_start(ap, fmt);
+	vfprintf(stream, fmt, ap);
+	va_end(ap);
+
+};
+
+
 // ----------------------------------------------------------------------
 // test query in pristine state (bug#2745 misbehaviour)
 TEST(leapsec, lsQueryPristineState) {
@@ -431,7 +450,7 @@ TEST(leapsec, lsQueryPristineState) {
 	leap_result_t  qr;
 
 	leap_table_t * pt = leapsec_get_table(0);
-	leapsec_dump(pt, (leapsec_dumper)fprintf, stdout);
+	leapsec_dump(pt, (leapsec_dumper)my_fprintf, stdout);
 
 	rc = leapsec_query(&qr, lsec2012);
 	TEST_ASSERT_FALSE(rc);
@@ -551,7 +570,7 @@ TEST(leapsec, ls2009limdata) {
 
 	rc = setup_load_table(leap1);
 	pt = leapsec_get_table(0);
-	leapsec_dump(pt, (leapsec_dumper)fprintf, stdout);
+	leapsec_dump(pt, (leapsec_dumper)my_fprintf, stdout);
 
 	// FIXME
 	// This used to check against build date
@@ -607,9 +626,9 @@ TEST(leapsec, addDynamic) {
 	rc = leapsec_add_dyn(true, insns[0] - (time_t)JAN_1970 -
                              20*SECSPERDAY - 100);
 	TEST_ASSERT_FALSE(rc);
-	//leapsec_dump(pt, (leapsec_dumper)fprintf, stdout);
+	//leapsec_dump(pt, (leapsec_dumper)my_fprintf, stdout);
 	pt = leapsec_get_table(0);
-	leapsec_dump(pt, (leapsec_dumper)fprintf, stdout);
+	leapsec_dump(pt, (leapsec_dumper)my_fprintf, stdout);
 }
 
 // ----------------------------------------------------------------------
@@ -662,7 +681,7 @@ TEST(leapsec, addFixed) {
 	    insns[0].tt,
 	    insns[0].tt + SECSPERDAY);
 	TEST_ASSERT_FALSE(rc);
-	//leapsec_dump(pt, (leapsec_dumper)fprintf, stdout);
+	//leapsec_dump(pt, (leapsec_dumper)my_fprintf, stdout);
 }
 
 // =====================================================================



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/500be55f645ec0a7f7ab2c2fdb60cf9259747c94...1925aa36e4a1c95e9d72f43764ae4c8fb99f62fa

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/500be55f645ec0a7f7ab2c2fdb60cf9259747c94...1925aa36e4a1c95e9d72f43764ae4c8fb99f62fa
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180508/9f02b886/attachment.html>


More information about the vc mailing list