Latch the UTC offset.

When acting as a slave, we accept the foreign master's advertised
TAI-UTC offset for as long as that master is present.  However, when
the master disappears, we fall back to the initial offset value.  As a
result of this behavior, when starting with an out of date initial
offset, losing a foreign master causes a sudden UTC offset error (in
phc2sys for example) in the range of whole seconds.

This patch fixes the issue by remembering the UTC offset when assuming
the slave role.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2017-07-22 22:30:10 +02:00
parent 97e4242361
commit fa575b60f6
1 changed files with 5 additions and 0 deletions

View File

@ -658,6 +658,11 @@ static void clock_update_slave(struct clock *c)
if (c->tds.currentUtcOffset < c->utc_offset) { if (c->tds.currentUtcOffset < c->utc_offset) {
pr_warning("running in a temporal vortex"); pr_warning("running in a temporal vortex");
} }
if ((c->tds.flags & UTC_OFF_VALID && c->tds.flags & TIME_TRACEABLE) ||
(c->tds.currentUtcOffset > c->utc_offset)) {
pr_info("updating UTC offset to %d", c->tds.currentUtcOffset);
c->utc_offset = c->tds.currentUtcOffset;
}
} }
static int clock_utc_correct(struct clock *c, tmv_t ingress) static int clock_utc_correct(struct clock *c, tmv_t ingress)