Blob Blame History Raw
commit 3760f8b6537ec4f614d9aa07d957716ee2e51059
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date:   Wed Jul 9 16:25:08 2014 +0200

    Add option to set NTP SHM segment number.
    
    Instead of setting it to the PTP domain number, add a new option to
    ptp4l and phc2sys to set it as needed. The default value is 0. This
    allows multiple ptp4l/phc2sys instances running in the same domain.
    
    Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>

diff --git a/config.c b/config.c
index 0bc85c1..0983c62 100644
--- a/config.c
+++ b/config.c
@@ -284,7 +284,6 @@ static enum parser_result parse_global_setting(const char *option,
 		if (r != PARSED_OK)
 			return r;
 		dds->domainNumber = uval;
-		*cfg->ntpshm_segment = uval;
 
 	} else if (!strcmp(option, "clockClass")) {
 		r = get_ranged_uint(value, &uval, 0, UINT8_MAX);
@@ -408,6 +407,12 @@ static enum parser_result parse_global_setting(const char *option,
 			return r;
 		cfg->dds.sanity_freq_limit = val;
 
+	} else if (!strcmp(option, "ntpshm_segment")) {
+		r = get_ranged_int(value, &val, INT_MIN, INT_MAX);
+		if (r != PARSED_OK)
+			return r;
+		*cfg->ntpshm_segment = val;
+
 	} else if (!strcmp(option, "ptp_dst_mac")) {
 		if (MAC_LEN != sscanf(value, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
 				      &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]))
diff --git a/default.cfg b/default.cfg
index 9f01eda..9e794ba 100644
--- a/default.cfg
+++ b/default.cfg
@@ -53,6 +53,7 @@ first_step_threshold	0.00002
 max_frequency		900000000
 clock_servo		pi
 sanity_freq_limit	200000000
+ntpshm_segment		0
 #
 # Transport options
 #
diff --git a/gPTP.cfg b/gPTP.cfg
index 4d0a38c..e15a05a 100644
--- a/gPTP.cfg
+++ b/gPTP.cfg
@@ -53,6 +53,7 @@ first_step_threshold	0.00002
 max_frequency		900000000
 clock_servo		pi
 sanity_freq_limit	200000000
+ntpshm_segment		0
 #
 # Transport options
 #
diff --git a/phc2sys.8 b/phc2sys.8
index c4fb6f6..22d02c2 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -116,7 +116,7 @@ option.
 Specify which clock servo should be used. Valid values are pi for a PI
 controller, linreg for an adaptive controller using linear regression, and
 ntpshm for the NTP SHM reference clock to allow another process to synchronize
-the local clock (the SHM segment number is set to the domain number).
+the local clock.
 The default is pi.
 .TP
 .BI \-P " kp"
@@ -166,6 +166,10 @@ the synchronized clock. When a larger offset is measured, a warning message
 will be printed and the servo will be reset. When set to 0, the sanity check is
 disabled. The default is 200000000 (20%).
 .TP
+.BI \-M " segment"
+The number of the SHM segment used by ntpshm servo.
+The default is 0.
+.TP
 .BI \-u " summary-updates"
 Specify the number of clock updates included in summary statistics. The
 statistics include offset root mean square (RMS), maximum absolute offset,
diff --git a/phc2sys.c b/phc2sys.c
index 391ae62..22eb9c9 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1159,6 +1159,7 @@ static void usage(char *progname)
 		" -R [rate]      slave clock update rate in HZ (1.0)\n"
 		" -N [num]       number of master clock readings per update (5)\n"
 		" -L [limit]     sanity frequency limit in ppb (200000000)\n"
+		" -M [num]       NTP SHM segment number (0)\n"
 		" -u [num]       number of clock updates in summary stats (0)\n"
 		" -n [num]       domain number (0)\n"
 		" -x             apply leap seconds by servo instead of kernel\n"
@@ -1199,7 +1200,7 @@ int main(int argc, char *argv[])
 	progname = strrchr(argv[0], '/');
 	progname = progname ? 1+progname : argv[0];
 	while (EOF != (c = getopt(argc, argv,
-				  "arc:d:s:E:P:I:S:F:R:N:O:L:i:u:wn:xz:l:mqvh"))) {
+				  "arc:d:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:mqvh"))) {
 		switch (c) {
 		case 'a':
 			autocfg = 1;
@@ -1276,6 +1277,10 @@ int main(int argc, char *argv[])
 			if (get_arg_val_i(c, optarg, &node.sanity_freq_limit, 0, INT_MAX))
 				return -1;
 			break;
+		case 'M':
+			if (get_arg_val_i(c, optarg, &ntpshm_segment, INT_MIN, INT_MAX))
+				return -1;
+			break;
 		case 'u':
 			if (get_arg_val_ui(c, optarg, &node.stats_max_count,
 					  0, UINT_MAX))
@@ -1287,7 +1292,6 @@ int main(int argc, char *argv[])
 		case 'n':
 			if (get_arg_val_i(c, optarg, &domain_number, 0, 255))
 				return -1;
-			ntpshm_segment = domain_number;
 			break;
 		case 'x':
 			node.kernel_leap = 0;
diff --git a/ptp4l.8 b/ptp4l.8
index 1bae78c..687beb6 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -376,6 +376,10 @@ the synchronized clock. When a larger offset is measured, a warning message
 will be printed and the servo will be reset. When set to 0, the sanity check is
 disabled. The default is 200000000 (20%).
 .TP
+.B ntpshm_segment
+The number of the SHM segment used by ntpshm servo.
+The default is 0.
+.TP
 .B ptp_dst_mac
 The MAC address where should be PTP messages sent.
 Relevant only with L2 transport. The default is 01:1B:19:00:00:00.