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 <mlich...@redhat.com>
---
 timemaster.8 |  8 ++++++++
 timemaster.c | 14 +++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/timemaster.8 b/timemaster.8
index 5987d26..e0e22eb 100644
--- a/timemaster.8
+++ b/timemaster.8
@@ -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
diff --git a/timemaster.c b/timemaster.c
index 53f4275..7a22a8b 100644
--- a/timemaster.c
+++ b/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) {
-- 
2.5.5


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to