integ/base/linuxptp/debian/patches/0057-Fix-uninitialized-variable-in-nmea_scan_rmc.patch
Cole Walker aca42c6d4c Implement logic to skip updates with offset spike in ts2phc.
This change allows ts2phc to be configured to ignore timing updates that
have a large offset spike in order to mitigate the resulting timing
skew.

In some circumstances on realtime systems with high CPU load, the
timestamp consumed by ts2phc can be delayed in reaching ts2phc and
results in the offset calculation attempting to speed the clock up by a
large margin.

This change causes ts2phc to ignore updates that would greatly skew the
clock when ts2phc is already in a synchronized state.

The global configuration option "max_phc_update_skip_cnt" is provided to
allow users to specify how many consecutive offset spike incidents will
be ignored before adjusting the clock. The default value is 120. The
behaviour can be disabled by setting max_phc_update_skip_cnt to 0.

This code is ported from a proposed upstream patch found here:
https://sourceforge.net/p/linuxptp/mailman/message/44114092/

Test-plan:
Pass: Verify linuxptp package build
Pass: Deploy ts2phc binary and verify system time sync
Pass: Manually trigger offset spike and verify that ts2phc maintains
stable time sync

Closes-bug: https://bugs.launchpad.net/starlingx/+bug/2059955

Change-Id: I13cd5c3440682ec9256e11449fe62d5fe28f66fa
Signed-off-by: Cole Walker <cole.walker@windriver.com>
2024-04-01 14:53:06 -04:00

36 lines
1.1 KiB
Diff

From 8dd4e2b6c8b99952296319a0e0c0e0f3e6160e32 Mon Sep 17 00:00:00 2001
From: cwalker <cole.walker@windriver.com>
Date: Fri, 1 Mar 2024 17:50:29 +0000
Subject: [PATCH 57/58] Fix uninitialized variable in nmea_scan_rmc
Initialize the tm_isdst variable to ensure that mktime does not fail on
recent versions of glibc.
This change initializes tm_isdst to 0 for compatibility with UTC.
Previously, a positive value in the uninitialized tm_isdst would cause
mktime to fail and ts2phc would repeatedly log "invalid master time
stamp". This resulted in intermittent synchronization errors.
[commit 63fc1ef4fd5e5fc45dd4de3bf27920bb109a4357 upstream]
Signed-off-by: cwalker <cole.walker@windriver.com>
---
nmea.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/nmea.c b/nmea.c
index dc865d0..d86d81c 100644
--- a/nmea.c
+++ b/nmea.c
@@ -157,6 +157,7 @@ static int nmea_scan_rmc(struct nmea_parser *np, struct nmea_rmc *result)
}
tm.tm_year += 100;
tm.tm_mon--;
+ tm.tm_isdst = 0;
result->ts.tv_sec = mktime(&tm);
result->ts.tv_nsec = msec * 1000000UL;
result->fix_valid = status == 'A' ? true : false;
--
2.30.2