Blob Blame History Raw
commit 0309a880fb4389e869ae0ba431d3d17b1ec5a272
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date:   Thu Jan 5 10:15:53 2017 +0100

    Update TAI-UTC offset
    
    A leap second was applied to UTC on 2016-12-31 and the offset between
    TAI and UTC is now 37 seconds.
    
    Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>

diff --git a/ds.h b/ds.h
index b36862d..0e48d05 100644
--- a/ds.h
+++ b/ds.h
@@ -84,7 +84,7 @@ struct parent_ds {
 	unsigned int path_length;
 };
 
-#define CURRENT_UTC_OFFSET  36 /* 1 Jul 2015 */
+#define CURRENT_UTC_OFFSET  37 /* 1 Jan 2017 */
 #define INTERNAL_OSCILLATOR 0xA0
 
 struct timePropertiesDS {
commit 33e62f992542ac5ce6bdbb8ae6c34dec7011b543
Author: Viliam Lejcik <viliam.lejcik@kistler.com>
Date:   Tue Jan 17 18:25:26 2017 +0100

    ptp4l: Make UTC offset configurable.
    
    Currently UTC offset is defined as a constant - CURRENT_UTC_OFFSET, and if
    a leap second is added, that constant is no longer valid. Ptp4l was
    updated to read the UTC offset from configuration instead.
    
    Signed-off-by: Viliam Lejcik <viliam.lejcik@kistler.com>

diff --git a/clock.c b/clock.c
index c716f01..a6a1a1a 100644
--- a/clock.c
+++ b/clock.c
@@ -105,6 +105,7 @@ struct clock {
 	int leap_set;
 	int kernel_leap;
 	int utc_offset;  /* grand master role */
+	int current_utc_offset;  /* UTC offset fallback */
 	int time_flags;  /* grand master role */
 	int time_source; /* grand master role */
 	enum servo_state servo_state;
@@ -681,7 +682,7 @@ static void clock_update_slave(struct clock *c)
 	if (!(c->tds.flags & PTP_TIMESCALE)) {
 		pr_warning("foreign master not using PTP timescale");
 	}
-	if (c->tds.currentUtcOffset < CURRENT_UTC_OFFSET) {
+	if (c->tds.currentUtcOffset < c->current_utc_offset) {
 		pr_warning("running in a temporal vortex");
 	}
 }
@@ -697,10 +698,10 @@ static int clock_utc_correct(struct clock *c, tmv_t ingress)
 
 	if (c->tds.flags & UTC_OFF_VALID && c->tds.flags & TIME_TRACEABLE) {
 		utc_offset = c->tds.currentUtcOffset;
-	} else if (c->tds.currentUtcOffset > CURRENT_UTC_OFFSET) {
+	} else if (c->tds.currentUtcOffset > c->current_utc_offset) {
 		utc_offset = c->tds.currentUtcOffset;
 	} else {
-		utc_offset = CURRENT_UTC_OFFSET;
+		utc_offset = c->current_utc_offset;
 	}
 
 	if (c->tds.flags & LEAP_61) {
@@ -1035,7 +1036,7 @@ struct clock *clock_create(enum clock_type type, struct config *config,
 	c->freq_est_interval = config_get_int(config, NULL, "freq_est_interval");
 	c->grand_master_capable = config_get_int(config, NULL, "gmCapable");
 	c->kernel_leap = config_get_int(config, NULL, "kernel_leap");
-	c->utc_offset = CURRENT_UTC_OFFSET;
+	c->utc_offset = c->current_utc_offset = config_get_int(config, NULL, "utc_offset");
 	c->time_source = config_get_int(config, NULL, "timeSource");
 
 	if (c->free_running) {
diff --git a/config.c b/config.c
index b19f3ad..7bb949d 100644
--- a/config.c
+++ b/config.c
@@ -237,6 +237,7 @@ struct config_item config_tab[] = {
 	GLOB_ITEM_STR("uds_address", "/var/run/ptp4l"),
 	GLOB_ITEM_INT("use_syslog", 1, 0, 1),
 	GLOB_ITEM_STR("userDescription", ""),
+	GLOB_ITEM_INT("utc_offset", CURRENT_UTC_OFFSET, 0, INT_MAX),
 	GLOB_ITEM_INT("verbose", 0, 0, 1),
 };
 
diff --git a/default.cfg b/default.cfg
index 12542c0..ebb263a 100644
--- a/default.cfg
+++ b/default.cfg
@@ -7,6 +7,7 @@ slaveOnly		0
 priority1		128
 priority2		128
 domainNumber		0
+#utc_offset		37
 clockClass		248
 clockAccuracy		0xFE
 offsetScaledLogVariance	0xFFFF
diff --git a/gPTP.cfg b/gPTP.cfg
index 75e996c..142996a 100644
--- a/gPTP.cfg
+++ b/gPTP.cfg
@@ -7,6 +7,7 @@ gmCapable		1
 priority1		248
 priority2		248
 domainNumber		0
+#utc_offset		37
 clockClass		248
 clockAccuracy		0xFE
 offsetScaledLogVariance	0xFFFF
diff --git a/ptp4l.8 b/ptp4l.8
index f53fc6e..53d5f28 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -327,6 +327,10 @@ The default is 0xFFFF.
 The domain attribute of the local clock.
 The default is 0.
 .TP
+.B utc_offset
+The current offset between TAI and UTC.
+The default is 37.
+.TP
 .B free_running
 Don't adjust the local clock if enabled.
 The default is 0 (disabled).