dcavalca / rpms / linuxptp

Forked from rpms/linuxptp 2 years ago
Clone
df976e
commit 7e8eba5332671abfd95d06dd191059eded1d2cca
df976e
Author: Miroslav Lichvar <mlichvar@redhat.com>
df976e
Date:   Mon May 31 11:07:52 2021 +0200
df976e
df976e
    clock: Reset state when switching port with same best clock.
df976e
    
df976e
    When the best port is changed, but the ID of the best clock doesn't
df976e
    change (e.g. a passive port is activated on link failure), reset the
df976e
    current delay and other master/link-specific state to avoid the switch
df976e
    throwing the clock off.
df976e
    
df976e
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
df976e
    Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
df976e
df976e
diff --git a/clock.c b/clock.c
df976e
index d428ae2..f14006f 100644
df976e
--- a/clock.c
df976e
+++ b/clock.c
df976e
@@ -1940,7 +1940,7 @@ static void handle_state_decision_event(struct clock *c)
df976e
 		best_id = c->dds.clockIdentity;
df976e
 	}
df976e
 
df976e
-	if (!cid_eq(&best_id, &c->best_id)) {
df976e
+	if (!cid_eq(&best_id, &c->best_id) || best != c->best) {
df976e
 		clock_freq_est_reset(c);
df976e
 		tsproc_reset(c->tsproc, 1);
df976e
 		if (!tmv_is_zero(c->initial_delay))
df976e
df976e
commit 262a49b07eaccc0f0237e3cd4df01b185b8f664f
df976e
Author: Miroslav Lichvar <mlichvar@redhat.com>
df976e
Date:   Mon May 31 11:07:53 2021 +0200
df976e
df976e
    clock: Reset clock check on best clock/port change.
df976e
    
df976e
    Reset the clock check when the best clock or port changes, together with
df976e
    the other state like current estimated delay and frequency. This avoids
df976e
    false positives if the clock is controlled by an external process when
df976e
    not synchronized by PTP (e.g. phc2sys -rr).
df976e
    
df976e
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
df976e
    Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
df976e
df976e
diff --git a/clock.c b/clock.c
df976e
index f14006f..7d0f985 100644
df976e
--- a/clock.c
df976e
+++ b/clock.c
df976e
@@ -1942,6 +1942,8 @@ static void handle_state_decision_event(struct clock *c)
df976e
 
df976e
 	if (!cid_eq(&best_id, &c->best_id) || best != c->best) {
df976e
 		clock_freq_est_reset(c);
df976e
+		if (c->sanity_check)
df976e
+			clockcheck_reset(c->sanity_check);
df976e
 		tsproc_reset(c->tsproc, 1);
df976e
 		if (!tmv_is_zero(c->initial_delay))
df976e
 			tsproc_set_delay(c->tsproc, c->initial_delay);
df976e
diff --git a/clockcheck.c b/clockcheck.c
df976e
index d48a578..d0b4714 100644
df976e
--- a/clockcheck.c
df976e
+++ b/clockcheck.c
df976e
@@ -47,9 +47,16 @@ struct clockcheck *clockcheck_create(int freq_limit)
df976e
 	if (!cc)
df976e
 		return NULL;
df976e
 	cc->freq_limit = freq_limit;
df976e
+	clockcheck_reset(cc);
df976e
+	return cc;
df976e
+}
df976e
+
df976e
+void clockcheck_reset(struct clockcheck *cc)
df976e
+{
df976e
+	cc->freq_known = 0;
df976e
 	cc->max_freq = -CHECK_MAX_FREQ;
df976e
 	cc->min_freq = CHECK_MAX_FREQ;
df976e
-	return cc;
df976e
+	cc->last_ts = 0;
df976e
 }
df976e
 
df976e
 int clockcheck_sample(struct clockcheck *cc, uint64_t ts)
df976e
diff --git a/clockcheck.h b/clockcheck.h
df976e
index 78aca48..1ff86eb 100644
df976e
--- a/clockcheck.h
df976e
+++ b/clockcheck.h
df976e
@@ -33,6 +33,12 @@ struct clockcheck;
df976e
  */
df976e
 struct clockcheck *clockcheck_create(int freq_limit);
df976e
 
df976e
+/**
df976e
+ * Reset a clock check.
df976e
+ * @param cc Pointer to a clock check obtained via @ref clockcheck_create().
df976e
+ */
df976e
+void clockcheck_reset(struct clockcheck *cc);
df976e
+
df976e
 /**
df976e
  * Perform the sanity check on a time stamp.
df976e
  * @param cc Pointer to a clock check obtained via @ref clockcheck_create().
df976e
df976e
commit e117e37e379556fa23337db2518bb44d8793e039
df976e
Author: Miroslav Lichvar <mlichvar@redhat.com>
df976e
Date:   Mon May 31 11:07:54 2021 +0200
df976e
df976e
    port: Don't check timestamps from non-slave ports.
df976e
    
df976e
    Don't perform the sanity check on receive timestamps from ports in
df976e
    non-slave states to avoid false positives in the jbod mode, where
df976e
    the timestamps can be generated by different clocks.
df976e
    
df976e
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
df976e
    Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
df976e
df976e
diff --git a/port.c b/port.c
df976e
index b5b775f..ec5c92e 100644
df976e
--- a/port.c
df976e
+++ b/port.c
df976e
@@ -2749,7 +2749,10 @@ static enum fsm_event bc_event(struct port *p, int fd_index)
df976e
 	}
df976e
 	if (msg_sots_valid(msg)) {
df976e
 		ts_add(&msg->hwts.ts, -p->rx_timestamp_offset);
df976e
-		clock_check_ts(p->clock, tmv_to_nanoseconds(msg->hwts.ts));
df976e
+		if (p->state == PS_SLAVE) {
df976e
+			clock_check_ts(p->clock,
df976e
+				       tmv_to_nanoseconds(msg->hwts.ts));
df976e
+		}
df976e
 	}
df976e
 
df976e
 	switch (msg_type(msg)) {
df976e
df976e
commit 6df84259647757bc53818a039734f8ff85618c02
df976e
Author: Miroslav Lichvar <mlichvar@redhat.com>
df976e
Date:   Mon May 31 11:07:55 2021 +0200
df976e
df976e
    port: Don't renew raw transport.
df976e
    
df976e
    Renewing of the transport on announce/sync timeout is needed in the
df976e
    client-only mode to avoid getting stuck with a broken multicast socket
df976e
    when the link goes down.
df976e
    
df976e
    This shouldn't be necessary with the raw transport. Closing and binding
df976e
    of raw sockets can apparently be so slow that it triggers a false
df976e
    positive in the clock check.
df976e
    
df976e
    Reported-by: Amar Subramanyam <asubramanyam@altiostar.com>
df976e
    Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
df976e
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
df976e
df976e
diff --git a/port.c b/port.c
df976e
index ec5c92e..c057591 100644
df976e
--- a/port.c
df976e
+++ b/port.c
df976e
@@ -1811,6 +1811,12 @@ static int port_renew_transport(struct port *p)
df976e
 	if (!port_is_enabled(p)) {
df976e
 		return 0;
df976e
 	}
df976e
+
df976e
+	/* Closing and binding of raw sockets is too slow and unnecessary */
df976e
+	if (transport_type(p->trp) == TRANS_IEEE_802_3) {
df976e
+		return 0;
df976e
+	}
df976e
+
df976e
 	transport_close(p->trp, &p->fda);
df976e
 	port_clear_fda(p, FD_FIRST_TIMER);
df976e
 	res = transport_open(p->trp, p->iface, &p->fda, p->timestamping);
df976e
df976e
commit a082bcd700e4955ebaa00d7039bf4bce92048ac4
df976e
Author: Miroslav Lichvar <mlichvar@redhat.com>
df976e
Date:   Mon May 31 11:07:56 2021 +0200
df976e
df976e
    clockcheck: Increase minimum interval.
df976e
    
df976e
    Increase the minimum check interval to 1 second to measure the frequency
df976e
    offset more accurately and with default configuration make false
df976e
    positives less likely due to a heavily overloaded system.
df976e
    
df976e
    Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
df976e
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
df976e
df976e
diff --git a/clockcheck.c b/clockcheck.c
df976e
index d0b4714..f0141be 100644
df976e
--- a/clockcheck.c
df976e
+++ b/clockcheck.c
df976e
@@ -23,7 +23,7 @@
df976e
 #include "clockcheck.h"
df976e
 #include "print.h"
df976e
 
df976e
-#define CHECK_MIN_INTERVAL 100000000
df976e
+#define CHECK_MIN_INTERVAL 1000000000
df976e
 #define CHECK_MAX_FREQ 900000000
df976e
 
df976e
 struct clockcheck {