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>
master
Viliam Lejcik 2017-01-17 18:25:26 +01:00 committed by Richard Cochran
parent b738afb604
commit 33e62f9925
5 changed files with 12 additions and 4 deletions

View File

@ -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) {

View File

@ -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),
};

View File

@ -7,6 +7,7 @@ slaveOnly 0
priority1 128
priority2 128
domainNumber 0
#utc_offset 37
clockClass 248
clockAccuracy 0xFE
offsetScaledLogVariance 0xFFFF

View File

@ -7,6 +7,7 @@ gmCapable 1
priority1 248
priority2 248
domainNumber 0
#utc_offset 37
clockClass 248
clockAccuracy 0xFE
offsetScaledLogVariance 0xFFFF

View File

@ -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).