timemaster: add option to specify first SHM segment.
This allows using a sequence of SHM segments that starts with a number larger than zero, which can be useful to avoid conflicts with time sources that are not started by timemaster, e.g. gpsd using segments number 0 and 1. Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>master
parent
ac77099493
commit
395544d117
|
@ -80,6 +80,13 @@ Specify the directory where should be generated \fBchronyd\fR, \fBntpd\fR and
|
|||
\fBptp4l\fR configuration files and sockets. The directory will be created if
|
||||
it doesn't exist. The default value is \fB/var/run/timemaster\fR.
|
||||
|
||||
.TP
|
||||
.B first_shm_segment
|
||||
Specify the first number in a sequence of SHM segments that will be used by
|
||||
\fBptp4l\fR and \fBphc2sys\fR. The default value is 0. Increasing the number
|
||||
can be useful to avoid conflicts with time sources that are not started by
|
||||
\fBtimemaster\fR, e.g. \fBgpsd\fR using segments number 0 and 1.
|
||||
|
||||
.SS [ntp_server address]
|
||||
|
||||
The \fBntp_server\fR section specifies an NTP server that should be used as a
|
||||
|
@ -310,6 +317,7 @@ ptp4l_option delay_mechanism P2P
|
|||
[timemaster]
|
||||
ntp_program chronyd
|
||||
rundir /var/run/timemaster
|
||||
first_shm_segment 1
|
||||
|
||||
[chronyd]
|
||||
path /usr/sbin/chronyd
|
||||
|
|
14
timemaster.c
14
timemaster.c
|
@ -41,6 +41,8 @@
|
|||
|
||||
#define DEFAULT_RUNDIR "/var/run/timemaster"
|
||||
|
||||
#define DEFAULT_FIRST_SHM_SEGMENT 0
|
||||
|
||||
#define DEFAULT_NTP_PROGRAM CHRONYD
|
||||
#define DEFAULT_NTP_MINPOLL 6
|
||||
#define DEFAULT_NTP_MAXPOLL 10
|
||||
|
@ -103,6 +105,7 @@ struct timemaster_config {
|
|||
struct source **sources;
|
||||
enum ntp_program ntp_program;
|
||||
char *rundir;
|
||||
int first_shm_segment;
|
||||
struct program_config chronyd;
|
||||
struct program_config ntpd;
|
||||
struct program_config phc2sys;
|
||||
|
@ -363,6 +366,7 @@ static int parse_timemaster_settings(char **settings,
|
|||
struct timemaster_config *config)
|
||||
{
|
||||
char *name, *value;
|
||||
int r = 0;
|
||||
|
||||
for (; *settings; settings++) {
|
||||
parse_setting(*settings, &name, &value);
|
||||
|
@ -377,10 +381,16 @@ static int parse_timemaster_settings(char **settings,
|
|||
}
|
||||
} else if (!strcasecmp(name, "rundir")) {
|
||||
replace_string(value, &config->rundir);
|
||||
} else if (!strcasecmp(name, "first_shm_segment")) {
|
||||
r = parse_int(value, &config->first_shm_segment);
|
||||
} else {
|
||||
pr_err("unknown timemaster setting %s", name);
|
||||
return 1;
|
||||
}
|
||||
if (r) {
|
||||
pr_err("invalid value %s for %s", value, name);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -495,6 +505,7 @@ static struct timemaster_config *config_parse(char *path)
|
|||
config->sources = (struct source **)parray_new();
|
||||
config->ntp_program = DEFAULT_NTP_PROGRAM;
|
||||
config->rundir = xstrdup(DEFAULT_RUNDIR);
|
||||
config->first_shm_segment = DEFAULT_FIRST_SHM_SEGMENT;
|
||||
|
||||
init_program_config(&config->chronyd, "chronyd",
|
||||
NULL, DEFAULT_CHRONYD_SETTINGS, NULL);
|
||||
|
@ -876,12 +887,13 @@ static struct script *script_create(struct timemaster_config *config)
|
|||
struct source *source, **sources;
|
||||
struct config_file *ntp_config = NULL;
|
||||
int **allocated_phcs = (int **)parray_new();
|
||||
int ret = 0, shm_segment = 0;
|
||||
int ret = 0, shm_segment;
|
||||
|
||||
script->configs = (struct config_file **)parray_new();
|
||||
script->commands = (char ***)parray_new();
|
||||
|
||||
ntp_config = add_ntp_program(config, script);
|
||||
shm_segment = config->first_shm_segment;
|
||||
|
||||
for (sources = config->sources; (source = *sources); sources++) {
|
||||
switch (source->type) {
|
||||
|
|
Loading…
Reference in New Issue