The SHM is not cleared upon servo release when exiting the tool. This
leaves the last update in the shared memory region marked as valid.

Users may not expect such behavior. If the configuration changed, or the
tool was restarted to reset the state after an unexpected clock step
(e.g. after system suspend), an incorrec timestamp might be accepted by
the consumer

To prevent such behavior - invalidate the SHM data when releasing
the SHM servo.

v2: Fix commit message

Signed-off-by: Maciek Machnikowski <mac...@machnikowski.net>
---
 ntpshm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ntpshm.c b/ntpshm.c
index 3b62a3f..6453ac4 100644
--- a/ntpshm.c
+++ b/ntpshm.c
@@ -69,6 +69,9 @@ static void ntpshm_destroy(struct servo *servo)
 {
        struct ntpshm_servo *s = container_of(servo, struct ntpshm_servo, 
servo);
 
+       /* Invalidate the SHM data before exiting */
+       s->shm->valid = 0;
+
        shmdt(s->shm);
        free(s);
 }
-- 
2.37.1 (Apple Git-137.1)



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to