Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/ntp merge conflicts between ntp-4.2.8p1{4,5}
details: https://anonhg.NetBSD.org/src/rev/5928c6b7f277
branches: trunk
changeset: 371783:5928c6b7f277
user: christos <christos%NetBSD.org@localhost>
date: Sun Oct 09 21:41:03 2022 +0000
description:
merge conflicts between ntp-4.2.8p1{4,5}
diffstat:
external/bsd/ntp/dist/configure.ac | 2 +-
external/bsd/ntp/dist/include/l_stdlib.h | 11 +-
external/bsd/ntp/dist/include/ntp.h | 4 +-
external/bsd/ntp/dist/include/ntp_config.h | 3 +-
external/bsd/ntp/dist/include/recvbuff.h | 32 ++-
external/bsd/ntp/dist/lib/isc/win32/include/isc/int.h | 6 +-
external/bsd/ntp/dist/libntp/a_md5encrypt.c | 4 +-
external/bsd/ntp/dist/libntp/decodenetnum.c | 210 ++++++++++-------
external/bsd/ntp/dist/libntp/recvbuff.c | 206 +++++++++++------
external/bsd/ntp/dist/libntp/strdup.c | 36 ++-
external/bsd/ntp/dist/libntp/timexsup.c | 5 +-
external/bsd/ntp/dist/ntpd/ntp_config.c | 12 +-
external/bsd/ntp/dist/ntpd/ntp_io.c | 38 ++-
external/bsd/ntp/dist/ntpd/ntp_proto.c | 59 ++--
external/bsd/ntp/dist/ntpd/ntp_refclock.c | 74 +++---
external/bsd/ntp/dist/ntpd/ntp_request.c | 4 +-
external/bsd/ntp/dist/ntpd/ntp_timer.c | 37 ++-
external/bsd/ntp/dist/ntpd/ntpd-opts.c | 16 +-
external/bsd/ntp/dist/ntpd/ntpd-opts.h | 8 +-
external/bsd/ntp/dist/ntpd/refclock_jjy.c | 110 ++++++--
external/bsd/ntp/dist/ntpd/refclock_nmea.c | 4 +-
external/bsd/ntp/dist/ntpd/refclock_palisade.c | 50 ++--
external/bsd/ntp/dist/ntpd/refclock_parse.c | 4 +-
external/bsd/ntp/dist/ntpdate/ntpdate.c | 7 +-
external/bsd/ntp/dist/ntpdc/ntpdc-opts.c | 16 +-
external/bsd/ntp/dist/ntpdc/ntpdc-opts.h | 8 +-
external/bsd/ntp/dist/ntpq/ntpq-opts.c | 16 +-
external/bsd/ntp/dist/ntpq/ntpq-opts.h | 8 +-
external/bsd/ntp/dist/ntpsnmpd/ntpsnmpd-opts.c | 16 +-
external/bsd/ntp/dist/ntpsnmpd/ntpsnmpd-opts.h | 8 +-
external/bsd/ntp/dist/sntp/crypto.c | 5 +-
external/bsd/ntp/dist/sntp/sntp-opts.c | 16 +-
external/bsd/ntp/dist/sntp/sntp-opts.h | 8 +-
external/bsd/ntp/dist/sntp/version.c | 4 +-
external/bsd/ntp/dist/tests/libntp/decodenetnum.c | 102 ++++++++-
external/bsd/ntp/dist/tests/libntp/netof.c | 4 +-
external/bsd/ntp/dist/tests/libntp/recvbuff.c | 6 +-
external/bsd/ntp/dist/tests/libntp/run-decodenetnum.c | 12 +-
external/bsd/ntp/dist/tests/libntp/sockaddrtest.c | 15 +-
external/bsd/ntp/dist/util/ntp-keygen-opts.c | 16 +-
external/bsd/ntp/dist/util/ntp-keygen-opts.h | 8 +-
external/bsd/ntp/importdate | 2 +-
external/bsd/ntp/include/config.h | 13 +-
external/bsd/ntp/ntp2netbsd | 4 +-
external/bsd/ntp/scripts/mkver | 38 +-
45 files changed, 814 insertions(+), 453 deletions(-)
diffs (truncated from 2892 to 300 lines):
diff -r eb75201420d1 -r 5928c6b7f277 external/bsd/ntp/dist/configure.ac
--- a/external/bsd/ntp/dist/configure.ac Sun Oct 09 21:00:00 2022 +0000
+++ b/external/bsd/ntp/dist/configure.ac Sun Oct 09 21:41:03 2022 +0000
@@ -912,7 +912,7 @@
;;
esac
AC_CHECK_FUNCS([setlinebuf setpgid setpriority setsid setvbuf])
-AC_CHECK_FUNCS([strdup strerror setrlimit strchr])
+AC_CHECK_FUNCS([strdup strnlen memchr strerror setrlimit strchr])
case "$host" in
*-*-aix[[4-9]]*)
# XXX only verified thru AIX6.
diff -r eb75201420d1 -r 5928c6b7f277 external/bsd/ntp/dist/include/l_stdlib.h
--- a/external/bsd/ntp/dist/include/l_stdlib.h Sun Oct 09 21:00:00 2022 +0000
+++ b/external/bsd/ntp/dist/include/l_stdlib.h Sun Oct 09 21:41:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: l_stdlib.h,v 1.5 2020/05/25 20:47:19 christos Exp $ */
+/* $NetBSD: l_stdlib.h,v 1.6 2022/10/09 21:41:03 christos Exp $ */
/*
* Proto types for machines that are not ANSI and POSIX compliant.
@@ -223,4 +223,13 @@
extern int h_errno;
#endif
+#ifndef HAVE_MEMCHR
+extern void *memchr(const void *s, int c, size_t n);
+#endif
+
+#ifndef HAVE_STRNLEN
+extern size_t strnlen(const char *s, size_t n);
+#endif
+
+
#endif /* L_STDLIB_H */
diff -r eb75201420d1 -r 5928c6b7f277 external/bsd/ntp/dist/include/ntp.h
--- a/external/bsd/ntp/dist/include/ntp.h Sun Oct 09 21:00:00 2022 +0000
+++ b/external/bsd/ntp/dist/include/ntp.h Sun Oct 09 21:41:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntp.h,v 1.11 2020/05/25 20:47:19 christos Exp $ */
+/* $NetBSD: ntp.h,v 1.12 2022/10/09 21:41:03 christos Exp $ */
/*
* ntp.h - NTP definitions for the masses
@@ -130,7 +130,7 @@
#define MAX_TTL 8 /* max ttl mapping vector size */
#define BEACON 7200 /* manycast beacon interval */
#define NTP_MAXEXTEN 2048 /* max extension field size */
-#define NTP_ORPHWAIT 300 /* orphan wair (s) */
+#define NTP_ORPHWAIT 300 /* orphan wait (s) */
/*
* Miscellaneous stuff
diff -r eb75201420d1 -r 5928c6b7f277 external/bsd/ntp/dist/include/ntp_config.h
--- a/external/bsd/ntp/dist/include/ntp_config.h Sun Oct 09 21:00:00 2022 +0000
+++ b/external/bsd/ntp/dist/include/ntp_config.h Sun Oct 09 21:41:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntp_config.h,v 1.13 2020/05/30 23:52:09 joerg Exp $ */
+/* $NetBSD: ntp_config.h,v 1.14 2022/10/09 21:41:03 christos Exp $ */
#ifndef NTP_CONFIG_H
#define NTP_CONFIG_H
@@ -277,6 +277,7 @@
int ifaddr_nonnull;
} settrap_parms;
+
/*
** Data Minimization Items
*/
diff -r eb75201420d1 -r 5928c6b7f277 external/bsd/ntp/dist/include/recvbuff.h
--- a/external/bsd/ntp/dist/include/recvbuff.h Sun Oct 09 21:00:00 2022 +0000
+++ b/external/bsd/ntp/dist/include/recvbuff.h Sun Oct 09 21:41:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: recvbuff.h,v 1.7 2020/05/25 20:47:20 christos Exp $ */
+/* $NetBSD: recvbuff.h,v 1.8 2022/10/09 21:41:03 christos Exp $ */
#ifndef RECVBUFF_H
#define RECVBUFF_H
@@ -12,10 +12,26 @@
/*
* recvbuf memory management
*/
-#define RECV_INIT 10 /* 10 buffers initially */
+#define RECV_INIT 64 /* 64 buffers initially */
#define RECV_LOWAT 3 /* when we're down to three buffers get more */
-#define RECV_INC 5 /* get 5 more at a time */
-#define RECV_TOOMANY 40 /* this is way too many buffers */
+#define RECV_INC 32 /* [power of 2] get 32 more at a time */
+#define RECV_BATCH 128 /* [power of 2] max increment in one sweep */
+#define RECV_TOOMANY 4096 /* this should suffice, really. TODO: tos option? */
+
+/* If we have clocks, keep an iron reserve of receive buffers for
+ * clocks only.
+ */
+#if defined(REFCLOCK)
+# if !defined(RECV_CLOCK) || RECV_CLOCK == 0
+# undef RECV_CLOCK
+# define RECV_CLOCK 16
+# endif
+#else
+# if defined(RECV_CLOCK)
+# undef RECV_CLOCK
+# endif
+# define RECV_CLOCK 0
+#endif
#if defined HAVE_IO_COMPLETION_PORT
# include "ntp_iocompletionport.h"
@@ -92,10 +108,10 @@
* you put it back with freerecvbuf() or
*/
-/* signal safe - no malloc */
-extern struct recvbuf *get_free_recv_buffer(void);
-/* signal unsafe - may malloc, never returs NULL */
-extern struct recvbuf *get_free_recv_buffer_alloc(void);
+/* signal safe - no malloc, returns NULL when no bufs */
+extern struct recvbuf *get_free_recv_buffer(int /*BOOL*/ urgent);
+/* signal unsafe - may malloc, returns NULL when no bufs */
+extern struct recvbuf *get_free_recv_buffer_alloc(int /*BOOL*/ urgent);
/* Add a buffer to the full list
*/
diff -r eb75201420d1 -r 5928c6b7f277 external/bsd/ntp/dist/lib/isc/win32/include/isc/int.h
--- a/external/bsd/ntp/dist/lib/isc/win32/include/isc/int.h Sun Oct 09 21:00:00 2022 +0000
+++ b/external/bsd/ntp/dist/lib/isc/win32/include/isc/int.h Sun Oct 09 21:41:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: int.h,v 1.6 2020/05/25 20:47:23 christos Exp $ */
+/* $NetBSD: int.h,v 1.7 2022/10/09 21:41:03 christos Exp $ */
/*
* Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
@@ -22,7 +22,9 @@
#ifndef ISC_INT_H
#define ISC_INT_H 1
-#define _INTEGRAL_MAX_BITS 64
+#ifndef _INTEGRAL_MAX_BITS
+# define _INTEGRAL_MAX_BITS 64
+#endif
#include <limits.h>
typedef __int8 isc_int8_t;
diff -r eb75201420d1 -r 5928c6b7f277 external/bsd/ntp/dist/libntp/a_md5encrypt.c
--- a/external/bsd/ntp/dist/libntp/a_md5encrypt.c Sun Oct 09 21:00:00 2022 +0000
+++ b/external/bsd/ntp/dist/libntp/a_md5encrypt.c Sun Oct 09 21:41:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: a_md5encrypt.c,v 1.11 2020/05/25 20:47:24 christos Exp $ */
+/* $NetBSD: a_md5encrypt.c,v 1.12 2022/10/09 21:41:03 christos Exp $ */
/*
* digest support for NTP, MD5 and with OpenSSL more
@@ -95,7 +95,7 @@
}
cmac_fail:
if (ctx)
- CMAC_CTX_cleanup(ctx);
+ CMAC_CTX_free(ctx);
}
else
# endif /*ENABLE_CMAC*/
diff -r eb75201420d1 -r 5928c6b7f277 external/bsd/ntp/dist/libntp/decodenetnum.c
--- a/external/bsd/ntp/dist/libntp/decodenetnum.c Sun Oct 09 21:00:00 2022 +0000
+++ b/external/bsd/ntp/dist/libntp/decodenetnum.c Sun Oct 09 21:41:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decodenetnum.c,v 1.6 2020/05/25 20:47:24 christos Exp $ */
+/* $NetBSD: decodenetnum.c,v 1.7 2022/10/09 21:41:03 christos Exp $ */
/*
* decodenetnum - return a net number (this is crude, but careful)
@@ -15,106 +15,152 @@
#include "ntp.h"
#include "ntp_stdlib.h"
-#include "ntp_assert.h"
+
-#define PORTSTR(x) _PORTSTR(x)
-#define _PORTSTR(x) #x
-
-static int
-isnumstr(
- const char *s
+/* If the given string position points to a decimal digit, parse the
+ * number. If this is not possible, or the parsing did not consume the
+ * whole string, or if the result exceeds the maximum value, return the
+ * default value.
+ */
+static unsigned long
+_num_or_dflt(
+ char * sval,
+ unsigned long maxval,
+ unsigned long defval
)
{
- while (*s >= '0' && *s <= '9')
- ++s;
- return !*s;
+ char * ep;
+ unsigned long num;
+
+ if (!(sval && isdigit(*(unsigned char*)sval)))
+ return defval;
+
+ num = strtoul(sval, &ep, 10);
+ if (!*ep && num <= maxval)
+ return num;
+
+ return defval;
+}
+
+/* If the given string position is not NULL and does not point to the
+ * terminator, replace the character with NUL and advance the pointer.
+ * Return the resulting position.
+ */
+static inline char*
+_chop(
+ char * sp)
+{
+ if (sp && *sp)
+ *sp++ = '\0';
+ return sp;
+}
+
+/* If the given string position points to the given char, advance the
+ * pointer and return the result. Otherwise, return NULL.
+ */
+static inline char*
+_skip(
+ char * sp,
+ int ch)
+{
+ if (sp && *(unsigned char*)sp == ch)
+ return (sp + 1);
+ return NULL;
}
/*
* decodenetnum convert text IP address and port to sockaddr_u
*
- * Returns 0 for failure, 1 for success.
+ * Returns FALSE (->0) for failure, TRUE (->1) for success.
*/
int
decodenetnum(
const char *num,
- sockaddr_u *netnum
+ sockaddr_u *net
)
{
- static const char * const servicename = "ntp";
- static const char * const serviceport = PORTSTR(NTP_PORT);
+ /* Building a parser is more fun in Haskell, but here we go...
+ *
+ * This works through 'inet_pton()' taking the brunt of the
+ * work, after some string manipulations to split off URI
+ * brackets, ports and scope identifiers. The heuristics are
+ * simple but must hold for all _VALID_ addresses. inet_pton()
+ * will croak on bad ones later, but replicating the whole
+ * parser logic to detect errors is wasteful.
+ */
+
+ sockaddr_u netnum;
+ char buf[64]; /* working copy of input */
+ char *haddr=buf;
+ unsigned int port=NTP_PORT, scope=0;
+ unsigned short afam=AF_UNSPEC;
- struct addrinfo hints, *ai = NULL;
- int err;
- const char *host_str;
- const char *port_str;
- char *pp;
- char *np;
- char nbuf[80];
+ /* copy input to working buffer with length check */
+ if (strlcpy(buf, num, sizeof(buf)) >= sizeof(buf))
+ return FALSE;
- REQUIRE(num != NULL);
+ /* Identify address family and possibly the port, if given. If
+ * this results in AF_UNSPEC, we will fail in the next step.
+ */
+ if (*haddr == '[') {
+ char * endp = strchr(++haddr, ']');
+ if (endp) {
+ port = _num_or_dflt(_skip(_chop(endp), ':'),
+ 0xFFFFu, port);
+ afam = strchr(haddr, ':') ? AF_INET6 : AF_INET;
+ }
+ } else {
+ char *col = strchr(haddr, ':');
+ char *dot = strchr(haddr, '.');
+ if (col == dot) {
+ /* no dot, no colon: bad! */
+ afam = AF_UNSPEC;
+ } else if (!col) {
+ /* no colon, only dot: IPv4! */
+ afam = AF_INET;
Home |
Main Index |
Thread Index |
Old Index