This option will lock chronyd into RAM so that it will never be paged
out. This mode is only supported on Linux.
@item -4
-With this option hostnames will be resolved only to IPv4 addresses.
+With this option hostnames will be resolved only to IPv4 addresses and only
+IPv4 sockets will be created.
@item -6
-With this option hostnames will be resolved only to IPv6 addresses.
+With this option hostnames will be resolved only to IPv6 addresses and only
+IPv6 sockets will be created.
@end table
On systems that support an @file{/etc/rc.local} file for starting
This option displays \fBchronyd\fR's version number to the terminal and exits
.TP
.B \-4
-Resolve hostnames only to IPv4 addresses.
+Resolve hostnames only to IPv4 addresses and create only IPv4 sockets.
.TP
.B \-6
-Resolve hostnames only to IPv6 addresses.
+Resolve hostnames only to IPv6 addresses and create only IPv6 sockets.
.SH FILES
\fI@SYSCONFDIR@/chrony.conf\fR
/* ================================================== */
void
-CAM_Initialise(void)
+CAM_Initialise(int family)
{
assert(!initialised);
initialised = 1;
free_replies = NULL;
kept_replies.next = NULL;
- sock_fd4 = prepare_socket(AF_INET);
+ if (family == IPADDR_UNSPEC || family == IPADDR_INET4)
+ sock_fd4 = prepare_socket(AF_INET);
+ else
+ sock_fd4 = -1;
#ifdef HAVE_IPV6
- sock_fd6 = prepare_socket(AF_INET6);
+ if (family == IPADDR_UNSPEC || family == IPADDR_INET6)
+ sock_fd6 = prepare_socket(AF_INET6);
+ else
+ sock_fd6 = -1;
#endif
if (sock_fd4 < 0
#include "addressing.h"
-extern void CAM_Initialise(void);
+extern void CAM_Initialise(int family);
extern void CAM_Finalise(void);
{
const char *conf_file = DEFAULT_CONF_FILE;
char *user = NULL;
- int debug = 0, nofork = 0;
+ int debug = 0, nofork = 0, address_family = IPADDR_UNSPEC;
int do_init_rtc = 0, restarted = 0;
int other_pid;
int lock_memory = 0, sched_priority = 0;
debug = 1;
nofork = 1;
} else if (!strcmp("-4", *argv)) {
- DNS_SetAddressFamily(IPADDR_INET4);
+ address_family = IPADDR_INET4;
} else if (!strcmp("-6", *argv)) {
- DNS_SetAddressFamily(IPADDR_INET6);
+ address_family = IPADDR_INET6;
} else {
LOG_FATAL(LOGF_Main, "Unrecognized command line option [%s]", *argv);
}
LOG(LOGS_INFO, LOGF_Main, "chronyd version %s starting", CHRONY_VERSION);
+ DNS_SetAddressFamily(address_family);
+
CNF_SetRestarted(restarted);
CNF_ReadFile(conf_file);
LCL_Initialise();
SCH_Initialise();
SYS_Initialise();
- NIO_Initialise();
- CAM_Initialise();
+ NIO_Initialise(address_family);
+ CAM_Initialise(address_family);
RTC_Initialise();
SRC_Initialise();
RCL_Initialise();
return sock_fd;
}
+/* ================================================== */
+
void
-NIO_Initialise(void)
+NIO_Initialise(int family)
{
assert(!initialised);
initialised = 1;
do_size_checks();
- sock_fd4 = prepare_socket(AF_INET);
+ if (family == IPADDR_UNSPEC || family == IPADDR_INET4)
+ sock_fd4 = prepare_socket(AF_INET);
+ else
+ sock_fd4 = -1;
#ifdef HAVE_IPV6
- sock_fd6 = prepare_socket(AF_INET6);
+ if (family == IPADDR_UNSPEC || family == IPADDR_INET6)
+ sock_fd6 = prepare_socket(AF_INET6);
+ else
+ sock_fd6 = -1;
#endif
if (sock_fd4 < 0
#include "addressing.h"
/* Function to initialise the module. */
-extern void NIO_Initialise(void);
+extern void NIO_Initialise(int family);
/* Function to finalise the module */
extern void NIO_Finalise(void);