Add a separate function for the update of the grandmaster's state after
a leap second to avoid making modifications in clock_time_properties()
and call it on each master announce tx timeout.

Suggested-by: Richard Cochran <richardcoch...@gmail.com>
Signed-off-by: Miroslav Lichvar <mlich...@redhat.com>
---
 clock.c | 8 ++------
 clock.h | 7 +++++++
 port.c  | 1 +
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/clock.c b/clock.c
index 61c9563..bbfd1a8 100644
--- a/clock.c
+++ b/clock.c
@@ -1897,7 +1897,7 @@ void clock_sync_interval(struct clock *c, int n)
        servo_sync_interval(c->servo, n < 0 ? 1.0 / (1 << -n) : 1 << n);
 }
 
-static void clock_update_utc_offset(struct clock *c)
+void clock_update_leap_status(struct clock *c)
 {
        struct timespec ts;
        int leap;
@@ -1932,11 +1932,7 @@ static void clock_update_utc_offset(struct clock *c)
 
 struct timePropertiesDS clock_time_properties(struct clock *c)
 {
-       struct timePropertiesDS tds;
-
-       clock_update_utc_offset(c);
-
-       tds = c->tds;
+       struct timePropertiesDS tds = c->tds;
 
        switch (c->local_sync_uncertain) {
        case SYNC_UNCERTAIN_DONTCARE:
diff --git a/clock.h b/clock.h
index e2a3e36..0534f21 100644
--- a/clock.h
+++ b/clock.h
@@ -339,6 +339,13 @@ enum servo_state clock_synchronize(struct clock *c, tmv_t 
ingress,
  */
 void clock_sync_interval(struct clock *c, int n);
 
+/**
+ * Update the clock leap bits and UTC offset after a leap second
+ * if operating as a grandmaster.
+ * @param c  The clock instance.
+ */
+void clock_update_leap_status(struct clock *c);
+
 /**
  * Obtain a clock's time properties data set.
  * @param c  The clock instance.
diff --git a/port.c b/port.c
index d5119b7..6e6b0aa 100644
--- a/port.c
+++ b/port.c
@@ -2705,6 +2705,7 @@ static enum fsm_event bc_event(struct port *p, int 
fd_index)
        case FD_MANNO_TIMER:
                pr_debug("%s: master tx announce timeout", p->log_name);
                port_set_manno_tmo(p);
+               clock_update_leap_status(p->clock);
                return port_tx_announce(p, NULL) ? EV_FAULT_DETECTED : EV_NONE;
 
        case FD_SYNC_TX_TIMER:
-- 
2.26.3



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

Reply via email to