[Linuxptp-devel] [PATCH v3 1/5] clock: Reset state when switching port with same best clock.
When the best port is changed, but the ID of the best clock doesn't change (e.g. a passive port is activated on link failure), reset the current delay and other master/link-specific state to avoid the switch throwing the clock off. Reviewed-by: Jacob Keller Signed-off-by: Miroslav Lichvar --- clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clock.c b/clock.c index e545a9b..a073575 100644 --- a/clock.c +++ b/clock.c @@ -1947,7 +1947,7 @@ static void handle_state_decision_event(struct clock *c) cid2str(_id)); } - if (!cid_eq(_id, >best_id)) { + if (!cid_eq(_id, >best_id) || best != c->best) { clock_freq_est_reset(c); tsproc_reset(c->tsproc, 1); if (!tmv_is_zero(c->initial_delay)) -- 2.26.3 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH v3 3/5] port: Don't check timestamps from non-slave ports.
Don't perform the sanity check on receive timestamps from ports in non-slave states to avoid false positives in the jbod mode, where the timestamps can be generated by different clocks. Reviewed-by: Jacob Keller Signed-off-by: Miroslav Lichvar --- port.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/port.c b/port.c index 10bb9e1..fb420fb 100644 --- a/port.c +++ b/port.c @@ -2744,7 +2744,10 @@ static enum fsm_event bc_event(struct port *p, int fd_index) } if (msg_sots_valid(msg)) { ts_add(>hwts.ts, -p->rx_timestamp_offset); - clock_check_ts(p->clock, tmv_to_nanoseconds(msg->hwts.ts)); + if (p->state == PS_SLAVE) { + clock_check_ts(p->clock, + tmv_to_nanoseconds(msg->hwts.ts)); + } } switch (msg_type(msg)) { -- 2.26.3 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH v3 5/5] clockcheck: Increase minimum interval.
Increase the minimum check interval to 1 second to measure the frequency offset more accurately and with default configuration make false positives less likely due to a heavily overloaded system. Signed-off-by: Miroslav Lichvar --- clockcheck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clockcheck.c b/clockcheck.c index d0b4714..f0141be 100644 --- a/clockcheck.c +++ b/clockcheck.c @@ -23,7 +23,7 @@ #include "clockcheck.h" #include "print.h" -#define CHECK_MIN_INTERVAL 1 +#define CHECK_MIN_INTERVAL 10 #define CHECK_MAX_FREQ 9 struct clockcheck { -- 2.26.3 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH v3 4/5] port: Don't renew raw transport.
Renewing of the transport on announce/sync timeout is needed in the client-only mode to avoid getting stuck with a broken multicast socket when the link goes down. This shouldn't be necessary with the raw transport. Closing and binding of raw sockets can apparently be so slow that it triggers a false positive in the clock check. Reported-by: Amar Subramanyam Signed-off-by: Miroslav Lichvar --- port.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/port.c b/port.c index fb420fb..6bf0684 100644 --- a/port.c +++ b/port.c @@ -1806,6 +1806,12 @@ static int port_renew_transport(struct port *p) if (!port_is_enabled(p)) { return 0; } + + /* Closing and binding of raw sockets is too slow and unnecessary */ + if (transport_type(p->trp) == TRANS_IEEE_802_3) { + return 0; + } + transport_close(p->trp, >fda); port_clear_fda(p, FD_FIRST_TIMER); res = transport_open(p->trp, p->iface, >fda, p->timestamping); -- 2.26.3 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH v3 0/5] Fixes for sanity clock check
v3 - added patch to avoid slow renewal of raw sockets - added patch to increase the minimum check interval v2 - improved commit message - added missing NULL check These patches make the clock check more reliable in several different cases. The first patch is not strictly related to the clock check, e.g. it also fixes the path delay after switching the slave port. Miroslav Lichvar (5): clock: Reset state when switching port with same best clock. clock: Reset clock check on best clock/port change. port: Don't check timestamps from non-slave ports. port: Don't renew raw transport. clockcheck: Increase minimum interval. clock.c | 4 +++- clockcheck.c | 11 +-- clockcheck.h | 6 ++ port.c | 11 ++- 4 files changed, 28 insertions(+), 4 deletions(-) -- 2.26.3 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH v3 2/5] clock: Reset clock check on best clock/port change.
Reset the clock check when the best clock or port changes, together with the other state like current estimated delay and frequency. This avoids false positives if the clock is controlled by an external process when not synchronized by PTP (e.g. phc2sys -rr). Reviewed-by: Jacob Keller Signed-off-by: Miroslav Lichvar --- clock.c | 2 ++ clockcheck.c | 9 - clockcheck.h | 6 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/clock.c b/clock.c index a073575..2dd7ef9 100644 --- a/clock.c +++ b/clock.c @@ -1949,6 +1949,8 @@ static void handle_state_decision_event(struct clock *c) if (!cid_eq(_id, >best_id) || best != c->best) { clock_freq_est_reset(c); + if (c->sanity_check) + clockcheck_reset(c->sanity_check); tsproc_reset(c->tsproc, 1); if (!tmv_is_zero(c->initial_delay)) tsproc_set_delay(c->tsproc, c->initial_delay); diff --git a/clockcheck.c b/clockcheck.c index d48a578..d0b4714 100644 --- a/clockcheck.c +++ b/clockcheck.c @@ -47,9 +47,16 @@ struct clockcheck *clockcheck_create(int freq_limit) if (!cc) return NULL; cc->freq_limit = freq_limit; + clockcheck_reset(cc); + return cc; +} + +void clockcheck_reset(struct clockcheck *cc) +{ + cc->freq_known = 0; cc->max_freq = -CHECK_MAX_FREQ; cc->min_freq = CHECK_MAX_FREQ; - return cc; + cc->last_ts = 0; } int clockcheck_sample(struct clockcheck *cc, uint64_t ts) diff --git a/clockcheck.h b/clockcheck.h index 78aca48..1ff86eb 100644 --- a/clockcheck.h +++ b/clockcheck.h @@ -33,6 +33,12 @@ struct clockcheck; */ struct clockcheck *clockcheck_create(int freq_limit); +/** + * Reset a clock check. + * @param cc Pointer to a clock check obtained via @ref clockcheck_create(). + */ +void clockcheck_reset(struct clockcheck *cc); + /** * Perform the sanity check on a time stamp. * @param cc Pointer to a clock check obtained via @ref clockcheck_create(). -- 2.26.3 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel