Re: [Linuxptp-devel] [PATCH v2] ntpshm: Invalidate SHM data before releasing the servo

2023-04-30 Thread Richard Cochran
On Thu, Mar 16, 2023 at 03:47:47PM +0100, Maciek Machnikowski wrote:
> 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 

Applied.

Thanks,
Richard


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


[Linuxptp-devel] [PATCH v2] ntpshm: Invalidate SHM data before releasing the servo

2023-03-16 Thread Maciek Machnikowski
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 
---
 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