|
|
63489c |
Backport of commit 73318c5b99571c8da01474ad665e2e2e06ab12bb
|
|
|
63489c |
Author: Richard Cochran <richardcochran@gmail.com>
|
|
|
63489c |
Date: Sun Feb 5 18:31:27 2017 +0100
|
|
|
63489c |
|
|
|
63489c |
clock: Force a BMC election when a port link goes down.
|
|
|
63489c |
|
|
|
63489c |
Having one fewer port may affect the result of the BMCA. This patch
|
|
|
63489c |
changes the main loop so that a link down event also causes a state
|
|
|
63489c |
decision event.
|
|
|
63489c |
|
|
|
63489c |
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
|
|
|
63489c |
Reported-by: Henry Jesuiter <Henry.Jesuiter@alcnetworx.de>
|
|
|
63489c |
|
|
|
63489c |
diff -up linuxptp-1.8/clock.c.linkdown linuxptp-1.8/clock.c
|
|
|
63489c |
--- linuxptp-1.8/clock.c.linkdown 2017-03-15 08:37:03.017542152 +0100
|
|
|
63489c |
+++ linuxptp-1.8/clock.c 2017-03-15 08:42:53.238682318 +0100
|
|
|
63489c |
@@ -96,6 +96,7 @@ struct clock {
|
|
|
63489c |
int pollfd_valid;
|
|
|
63489c |
int nports; /* does not include the UDS port */
|
|
|
63489c |
int last_port_number;
|
|
|
63489c |
+ int sde;
|
|
|
63489c |
struct hash *index2port;
|
|
|
63489c |
int free_running;
|
|
|
63489c |
int freq_est_interval;
|
|
|
63489c |
@@ -341,6 +342,11 @@ static void clock_link_status(void *ctx,
|
|
|
63489c |
port_dispatch(p, EV_FAULT_CLEARED, 0);
|
|
|
63489c |
} else {
|
|
|
63489c |
port_dispatch(p, EV_FAULT_DETECTED, 0);
|
|
|
63489c |
+ /*
|
|
|
63489c |
+ * A port going down can affect the BMCA result.
|
|
|
63489c |
+ * Force a state decision event.
|
|
|
63489c |
+ */
|
|
|
63489c |
+ c->sde = 1;
|
|
|
63489c |
}
|
|
|
63489c |
}
|
|
|
63489c |
|
|
|
63489c |
@@ -1465,7 +1471,7 @@ struct PortIdentity clock_parent_identit
|
|
|
63489c |
|
|
|
63489c |
int clock_poll(struct clock *c)
|
|
|
63489c |
{
|
|
|
63489c |
- int cnt, err, i, sde = 0;
|
|
|
63489c |
+ int cnt, err, i;
|
|
|
63489c |
enum fsm_event event;
|
|
|
63489c |
struct pollfd *cur;
|
|
|
63489c |
struct port *p;
|
|
|
63489c |
@@ -1496,9 +1502,9 @@ int clock_poll(struct clock *c)
|
|
|
63489c |
if (cur[i].revents & (POLLIN|POLLPRI)) {
|
|
|
63489c |
event = port_event(p, i);
|
|
|
63489c |
if (EV_STATE_DECISION_EVENT == event)
|
|
|
63489c |
- sde = 1;
|
|
|
63489c |
+ c->sde = 1;
|
|
|
63489c |
if (EV_ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES == event)
|
|
|
63489c |
- sde = 1;
|
|
|
63489c |
+ c->sde = 1;
|
|
|
63489c |
err = port_dispatch(p, event, 0);
|
|
|
63489c |
/* Clear any fault after a little while. */
|
|
|
63489c |
if (PS_FAULTY == port_state(p)) {
|
|
|
63489c |
@@ -1527,13 +1533,14 @@ int clock_poll(struct clock *c)
|
|
|
63489c |
if (cur[i].revents & (POLLIN|POLLPRI)) {
|
|
|
63489c |
event = port_event(c->uds_port, i);
|
|
|
63489c |
if (EV_STATE_DECISION_EVENT == event)
|
|
|
63489c |
- sde = 1;
|
|
|
63489c |
+ c->sde = 1;
|
|
|
63489c |
}
|
|
|
63489c |
}
|
|
|
63489c |
|
|
|
63489c |
- if (sde)
|
|
|
63489c |
+ if (c->sde) {
|
|
|
63489c |
handle_state_decision_event(c);
|
|
|
63489c |
-
|
|
|
63489c |
+ c->sde = 0;
|
|
|
63489c |
+ }
|
|
|
63489c |
clock_prune_subscriptions(c);
|
|
|
63489c |
return 0;
|
|
|
63489c |
}
|