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