timemaster: Allow ptp4l-specific sections in [ptp4l.conf].

Remove > from beginning of lines specified in the *.conf sections in
order to allow a ptp4l-specific section (e.g. [unicast_master_table]) to
be included there.

After inserting the lines to the generated ptp4l.conf, switch back to
the [global] section.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
master
Miroslav Lichvar 2018-09-25 18:16:20 +02:00 committed by Richard Cochran
parent 241d8a064e
commit 78a720f2b3
2 changed files with 31 additions and 7 deletions

View File

@ -253,9 +253,13 @@ Specify extra options that should be added to all \fBptp4l\fR command lines. By
default, \fB\-l 5\fR is added to the command lines.
.SS [ptp4l.conf]
Settings specified in this section are copied directly to the configuration
files generated for all \fBptp4l\fR instances. There is no default content of
this section.
Settings specified in this section are copied directly to the global section of
the configuration files generated for all \fBptp4l\fR instances. There is no
default content of this section.
Other sections (e.g. \fB[unicast_master_table]\fR) may be specified here, but
lines beginning with the bracket need to be prefixed with the \fB>\fR character
to prevent \fBtimemaster\fR from parsing it as a beginning of another section.
.SH NOTES
For best accuracy, \fBchronyd\fR is usually preferred over \fBntpd\fR, it also

View File

@ -405,6 +405,23 @@ static int parse_timemaster_settings(char **settings,
return 0;
}
static char **parse_raw_settings(char **settings)
{
char **setting, *s, **parsed_settings;
parsed_settings = (char **)parray_new();
for (setting = settings; *setting; setting++) {
s = *setting;
/* Unescape lines beginning with '>' */
if (s[0] == '>')
s++;
parray_append((void ***)&parsed_settings, xstrdup(s));
}
return parsed_settings;
}
static int parse_section(char **settings, char *name,
struct timemaster_config *config)
{
@ -451,8 +468,7 @@ static int parse_section(char **settings, char *name,
if (settings_dst) {
free_parray((void **)*settings_dst);
*settings_dst = (char **)parray_new();
extend_string_array(settings_dst, settings);
*settings_dst = parse_raw_settings(settings);
}
return 0;
@ -802,9 +818,13 @@ static int add_ptp_source(struct ptp_domain *source,
config_file = xmalloc(sizeof(*config_file));
config_file->path = string_newf("%s/ptp4l.%d.conf",
config->rundir, *shm_segment);
config_file->content = xstrdup("[global]\n");
if (*config->ptp4l.settings) {
extend_config_string(&config_file->content,
config->ptp4l.settings);
string_appendf(&config_file->content, "\n[global]\n");
}
extend_config_string(&config_file->content,
source->ptp4l_settings);
string_appendf(&config_file->content,