dcavalca / rpms / linuxptp

Forked from rpms/linuxptp 2 years ago
Clone
4693f0
commit 0309a880fb4389e869ae0ba431d3d17b1ec5a272
4693f0
Author: Miroslav Lichvar <mlichvar@redhat.com>
4693f0
Date:   Thu Jan 5 10:15:53 2017 +0100
4693f0
4693f0
    Update TAI-UTC offset
4693f0
    
4693f0
    A leap second was applied to UTC on 2016-12-31 and the offset between
4693f0
    TAI and UTC is now 37 seconds.
4693f0
    
4693f0
    Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
4693f0
4693f0
diff --git a/ds.h b/ds.h
4693f0
index b36862d..0e48d05 100644
4693f0
--- a/ds.h
4693f0
+++ b/ds.h
4693f0
@@ -84,7 +84,7 @@ struct parent_ds {
4693f0
 	unsigned int path_length;
4693f0
 };
4693f0
 
4693f0
-#define CURRENT_UTC_OFFSET  36 /* 1 Jul 2015 */
4693f0
+#define CURRENT_UTC_OFFSET  37 /* 1 Jan 2017 */
4693f0
 #define INTERNAL_OSCILLATOR 0xA0
4693f0
 
4693f0
 struct timePropertiesDS {
4693f0
commit 33e62f992542ac5ce6bdbb8ae6c34dec7011b543
4693f0
Author: Viliam Lejcik <viliam.lejcik@kistler.com>
4693f0
Date:   Tue Jan 17 18:25:26 2017 +0100
4693f0
4693f0
    ptp4l: Make UTC offset configurable.
4693f0
    
4693f0
    Currently UTC offset is defined as a constant - CURRENT_UTC_OFFSET, and if
4693f0
    a leap second is added, that constant is no longer valid. Ptp4l was
4693f0
    updated to read the UTC offset from configuration instead.
4693f0
    
4693f0
    Signed-off-by: Viliam Lejcik <viliam.lejcik@kistler.com>
4693f0
4693f0
diff --git a/clock.c b/clock.c
4693f0
index c716f01..a6a1a1a 100644
4693f0
--- a/clock.c
4693f0
+++ b/clock.c
4693f0
@@ -105,6 +105,7 @@ struct clock {
4693f0
 	int leap_set;
4693f0
 	int kernel_leap;
4693f0
 	int utc_offset;  /* grand master role */
4693f0
+	int current_utc_offset;  /* UTC offset fallback */
4693f0
 	int time_flags;  /* grand master role */
4693f0
 	int time_source; /* grand master role */
4693f0
 	enum servo_state servo_state;
4693f0
@@ -681,7 +682,7 @@ static void clock_update_slave(struct clock *c)
4693f0
 	if (!(c->tds.flags & PTP_TIMESCALE)) {
4693f0
 		pr_warning("foreign master not using PTP timescale");
4693f0
 	}
4693f0
-	if (c->tds.currentUtcOffset < CURRENT_UTC_OFFSET) {
4693f0
+	if (c->tds.currentUtcOffset < c->current_utc_offset) {
4693f0
 		pr_warning("running in a temporal vortex");
4693f0
 	}
4693f0
 }
4693f0
@@ -697,10 +698,10 @@ static int clock_utc_correct(struct clock *c, tmv_t ingress)
4693f0
 
4693f0
 	if (c->tds.flags & UTC_OFF_VALID && c->tds.flags & TIME_TRACEABLE) {
4693f0
 		utc_offset = c->tds.currentUtcOffset;
4693f0
-	} else if (c->tds.currentUtcOffset > CURRENT_UTC_OFFSET) {
4693f0
+	} else if (c->tds.currentUtcOffset > c->current_utc_offset) {
4693f0
 		utc_offset = c->tds.currentUtcOffset;
4693f0
 	} else {
4693f0
-		utc_offset = CURRENT_UTC_OFFSET;
4693f0
+		utc_offset = c->current_utc_offset;
4693f0
 	}
4693f0
 
4693f0
 	if (c->tds.flags & LEAP_61) {
4693f0
@@ -1035,7 +1036,7 @@ struct clock *clock_create(enum clock_type type, struct config *config,
4693f0
 	c->freq_est_interval = config_get_int(config, NULL, "freq_est_interval");
4693f0
 	c->grand_master_capable = config_get_int(config, NULL, "gmCapable");
4693f0
 	c->kernel_leap = config_get_int(config, NULL, "kernel_leap");
4693f0
-	c->utc_offset = CURRENT_UTC_OFFSET;
4693f0
+	c->utc_offset = c->current_utc_offset = config_get_int(config, NULL, "utc_offset");
4693f0
 	c->time_source = config_get_int(config, NULL, "timeSource");
4693f0
 
4693f0
 	if (c->free_running) {
4693f0
diff --git a/config.c b/config.c
4693f0
index b19f3ad..7bb949d 100644
4693f0
--- a/config.c
4693f0
+++ b/config.c
4693f0
@@ -237,6 +237,7 @@ struct config_item config_tab[] = {
4693f0
 	GLOB_ITEM_STR("uds_address", "/var/run/ptp4l"),
4693f0
 	GLOB_ITEM_INT("use_syslog", 1, 0, 1),
4693f0
 	GLOB_ITEM_STR("userDescription", ""),
4693f0
+	GLOB_ITEM_INT("utc_offset", CURRENT_UTC_OFFSET, 0, INT_MAX),
4693f0
 	GLOB_ITEM_INT("verbose", 0, 0, 1),
4693f0
 };
4693f0
 
4693f0
diff --git a/default.cfg b/default.cfg
4693f0
index 12542c0..ebb263a 100644
4693f0
--- a/default.cfg
4693f0
+++ b/default.cfg
4693f0
@@ -7,6 +7,7 @@ slaveOnly		0
4693f0
 priority1		128
4693f0
 priority2		128
4693f0
 domainNumber		0
4693f0
+#utc_offset		37
4693f0
 clockClass		248
4693f0
 clockAccuracy		0xFE
4693f0
 offsetScaledLogVariance	0xFFFF
4693f0
diff --git a/gPTP.cfg b/gPTP.cfg
4693f0
index 75e996c..142996a 100644
4693f0
--- a/gPTP.cfg
4693f0
+++ b/gPTP.cfg
4693f0
@@ -7,6 +7,7 @@ gmCapable		1
4693f0
 priority1		248
4693f0
 priority2		248
4693f0
 domainNumber		0
4693f0
+#utc_offset		37
4693f0
 clockClass		248
4693f0
 clockAccuracy		0xFE
4693f0
 offsetScaledLogVariance	0xFFFF
4693f0
diff --git a/ptp4l.8 b/ptp4l.8
4693f0
index f53fc6e..53d5f28 100644
4693f0
--- a/ptp4l.8
4693f0
+++ b/ptp4l.8
4693f0
@@ -327,6 +327,10 @@ The default is 0xFFFF.
4693f0
 The domain attribute of the local clock.
4693f0
 The default is 0.
4693f0
 .TP
4693f0
+.B utc_offset
4693f0
+The current offset between TAI and UTC.
4693f0
+The default is 37.
4693f0
+.TP
4693f0
 .B free_running
4693f0
 Don't adjust the local clock if enabled.
4693f0
 The default is 0 (disabled).