]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
conf: adopt default bind*address values
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 13 Jul 2020 12:19:45 +0000 (14:19 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 16 Jul 2020 10:07:43 +0000 (12:07 +0200)
Move the default values of the bind*address settings from the
ntp/nts/cmdmon code to conf.

cmdmon.c
conf.c
ntp_io.c
nts_ke_client.c
nts_ke_server.c

index 2fdb86780980d5400fd39722b9b572bba9218384..1e2f7abb43493f6537f1da8c063a2562459914e2 100644 (file)
--- a/cmdmon.c
+++ b/cmdmon.c
@@ -169,10 +169,7 @@ open_socket(int family)
         return INVALID_SOCK_FD;
 
       CNF_GetBindCommandAddress(family, &local_addr.ip_addr);
-      if (local_addr.ip_addr.family != family)
-        SCK_GetLoopbackIPAddress(family, &local_addr.ip_addr);
       local_addr.port = port;
-
       iface = CNF_GetBindCommandInterface();
 
       sock_fd = SCK_OpenUdpSocket(NULL, &local_addr, iface, SCK_FLAG_RX_DEST_ADDR);
diff --git a/conf.c b/conf.c
index 21df4572a305ab81a8d1d496d5767edb19079125..9b0c3a6d550834df6d42b5d73f2cacaf1a82a5ab 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -36,6 +36,7 @@
 #include "nts_ke.h"
 #include "refclock.h"
 #include "cmdmon.h"
+#include "socket.h"
 #include "srcparams.h"
 #include "logging.h"
 #include "nameserv.h"
@@ -393,6 +394,13 @@ CNF_Initialise(int r, int client_only)
     bind_cmd_path = Strdup(DEFAULT_COMMAND_SOCKET);
     pidfile = Strdup(DEFAULT_PID_FILE);
   }
+
+  SCK_GetAnyLocalIPAddress(IPADDR_INET4, &bind_address4);
+  SCK_GetAnyLocalIPAddress(IPADDR_INET6, &bind_address6);
+  SCK_GetAnyLocalIPAddress(IPADDR_INET4, &bind_acq_address4);
+  SCK_GetAnyLocalIPAddress(IPADDR_INET6, &bind_acq_address6);
+  SCK_GetLoopbackIPAddress(IPADDR_INET4, &bind_cmd_address4);
+  SCK_GetLoopbackIPAddress(IPADDR_INET6, &bind_cmd_address6);
 }
 
 /* ================================================== */
index 4bf3457ee0fd77f266fc2ff9173ee3ebecca5616..075f0cf714c70a4231a2016ac380f9a5a38c1378 100644 (file)
--- a/ntp_io.c
+++ b/ntp_io.c
@@ -98,9 +98,6 @@ open_socket(int family, int local_port, int client_only, IPSockAddr *remote_addr
     iface = CNF_GetBindAcquisitionInterface();
   }
 
-  if (local_addr.ip_addr.family != family)
-    SCK_GetAnyLocalIPAddress(family, &local_addr.ip_addr);
-
   local_addr.port = local_port;
 
   sock_flags = SCK_FLAG_RX_DEST_ADDR | SCK_FLAG_PRIV_BIND;
index 5b5441ea8ba77b17285157ba5e531144e0297d3b..896c64dd4a2c6c3be135b8db8ef26df685216503 100644 (file)
@@ -320,9 +320,6 @@ NKC_Start(NKC_Instance inst)
 
   /* Follow the bindacqaddress and bindacqdevice settings */
   CNF_GetBindAcquisitionAddress(inst->address.ip_addr.family, &local_addr.ip_addr);
-  if (local_addr.ip_addr.family != inst->address.ip_addr.family)
-    SCK_GetAnyLocalIPAddress(inst->address.ip_addr.family, &local_addr.ip_addr);
-
   local_addr.port = 0;
   iface = CNF_GetBindAcquisitionInterface();
 
index 7dc6d704573775452b21366b763887b75cc0c8d5..44c9c24b8f67ca27ab5dd0107e0dd096dc3b96e3 100644 (file)
@@ -265,9 +265,6 @@ open_socket(int family, int port)
   CNF_GetBindAddress(family, &local_addr.ip_addr);
   iface = CNF_GetBindNtpInterface();
 
-  if (local_addr.ip_addr.family != family)
-    SCK_GetAnyLocalIPAddress(family, &local_addr.ip_addr);
-
   local_addr.port = port;
 
   sock_fd = SCK_OpenTcpSocket(NULL, &local_addr, iface, 0);