conf: adopt default bind*address values

Move the default values of the bind*address settings from the
ntp/nts/cmdmon code to conf.
This commit is contained in:
Miroslav Lichvar 2020-07-13 14:19:45 +02:00
parent c10b66b579
commit 58da0c0ad2
5 changed files with 8 additions and 12 deletions

View file

@ -169,10 +169,7 @@ open_socket(int family)
return INVALID_SOCK_FD; return INVALID_SOCK_FD;
CNF_GetBindCommandAddress(family, &local_addr.ip_addr); 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; local_addr.port = port;
iface = CNF_GetBindCommandInterface(); iface = CNF_GetBindCommandInterface();
sock_fd = SCK_OpenUdpSocket(NULL, &local_addr, iface, SCK_FLAG_RX_DEST_ADDR); sock_fd = SCK_OpenUdpSocket(NULL, &local_addr, iface, SCK_FLAG_RX_DEST_ADDR);

8
conf.c
View file

@ -36,6 +36,7 @@
#include "nts_ke.h" #include "nts_ke.h"
#include "refclock.h" #include "refclock.h"
#include "cmdmon.h" #include "cmdmon.h"
#include "socket.h"
#include "srcparams.h" #include "srcparams.h"
#include "logging.h" #include "logging.h"
#include "nameserv.h" #include "nameserv.h"
@ -393,6 +394,13 @@ CNF_Initialise(int r, int client_only)
bind_cmd_path = Strdup(DEFAULT_COMMAND_SOCKET); bind_cmd_path = Strdup(DEFAULT_COMMAND_SOCKET);
pidfile = Strdup(DEFAULT_PID_FILE); 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);
} }
/* ================================================== */ /* ================================================== */

View file

@ -98,9 +98,6 @@ open_socket(int family, int local_port, int client_only, IPSockAddr *remote_addr
iface = CNF_GetBindAcquisitionInterface(); iface = CNF_GetBindAcquisitionInterface();
} }
if (local_addr.ip_addr.family != family)
SCK_GetAnyLocalIPAddress(family, &local_addr.ip_addr);
local_addr.port = local_port; local_addr.port = local_port;
sock_flags = SCK_FLAG_RX_DEST_ADDR | SCK_FLAG_PRIV_BIND; sock_flags = SCK_FLAG_RX_DEST_ADDR | SCK_FLAG_PRIV_BIND;

View file

@ -320,9 +320,6 @@ NKC_Start(NKC_Instance inst)
/* Follow the bindacqaddress and bindacqdevice settings */ /* Follow the bindacqaddress and bindacqdevice settings */
CNF_GetBindAcquisitionAddress(inst->address.ip_addr.family, &local_addr.ip_addr); 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; local_addr.port = 0;
iface = CNF_GetBindAcquisitionInterface(); iface = CNF_GetBindAcquisitionInterface();

View file

@ -265,9 +265,6 @@ open_socket(int family, int port)
CNF_GetBindAddress(family, &local_addr.ip_addr); CNF_GetBindAddress(family, &local_addr.ip_addr);
iface = CNF_GetBindNtpInterface(); iface = CNF_GetBindNtpInterface();
if (local_addr.ip_addr.family != family)
SCK_GetAnyLocalIPAddress(family, &local_addr.ip_addr);
local_addr.port = port; local_addr.port = port;
sock_fd = SCK_OpenTcpSocket(NULL, &local_addr, iface, 0); sock_fd = SCK_OpenTcpSocket(NULL, &local_addr, iface, 0);