]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: use one socket with random port when acquisitionport is 0
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 14 Aug 2014 13:57:09 +0000 (15:57 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 15 Aug 2014 08:58:44 +0000 (10:58 +0200)
chrony.texi.in
conf.c
ntp_io.c

index eb93c3b162ef5ee61c5b70a84f9192f012d7c89f..43bde8855142105068d409713eb8b8c5381971aa 100644 (file)
@@ -1199,7 +1199,8 @@ By default, @code{chronyd} uses a separate client socket for each configured
 server and their source port is chosen arbitrarily by the operating system.
 However, you can use the @code{acquisitionport} directive to explicitly specify
 a port and use only one socket (per IPv4/IPv6 address family) for all
-configured servers.  This may be useful for getting through firewalls.
+configured servers.  This may be useful for getting through firewalls.  If set
+to 0, the source port of the socket will be chosen arbitrarily.
 
 It may be set to the same port as used by the NTP server (@pxref{port
 directive}) to use only one socket for all NTP packets.
diff --git a/conf.c b/conf.c
index ee6895d1ad0690a426cdfbbfcc547201cd2fe4c8..46a765d4d4f44d61e5352b9381d3776ab4e7845c 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -79,7 +79,7 @@ static void parse_tempcomp(char *);
 static int restarted = 0;
 static int generate_command_key = 0;
 static char *rtc_device = "/dev/rtc";
-static int acquisition_port = 0; /* 0 means let kernel choose port */
+static int acquisition_port = -1;
 static int ntp_port = 123;
 static char *keys_file = NULL;
 static char *drift_file = NULL;
index a0a670ec64c963ec881802f5eee2065a0f8528a2..0100a90b10d70c70a90cf66ca74b6faccce2ac5b 100644 (file)
--- a/ntp_io.c
+++ b/ntp_io.c
@@ -328,8 +328,10 @@ NIO_Initialise(int family)
   server_port = CNF_GetNTPPort();
   client_port = CNF_GetAcquisitionPort();
 
-  /* Use separate connected sockets if client port is not set */
-  separate_client_sockets = client_port == 0;
+  /* Use separate connected sockets if client port is negative */
+  separate_client_sockets = client_port < 0;
+  if (client_port < 0)
+    client_port = 0;
 
   server_sock_fd4 = INVALID_SOCK_FD;
   client_sock_fd4 = INVALID_SOCK_FD;