Commit 8bd9b76e authored by Alessandro Rubini's avatar Alessandro Rubini

bugfix: state-fault must delay a while before reinitializing ppi

This is a long-standing bug introduced when fsm.c was changed to
immediately enter a new state (before that, we had a grace period in
state-faulty).  The problem is exposed by running the suggested
config file, if eth1 and/or eth2 exist but are currently down.

This patch introduces a specific timeout, so we wait 4 seconds before
reinitializing the pp instance; we thus avoid burning 100% CPU Time in
trying again and again.

As a side effect, this reduces timeouts provided to extensions from 4
to 3. I could have reused one of the other timeouts, as faulty state
does not use them, but I'd better have proper timeout names in
diagnostics.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 1d28bc0e
...@@ -50,11 +50,11 @@ enum pp_timeouts { ...@@ -50,11 +50,11 @@ enum pp_timeouts {
PP_TO_SYNC, PP_TO_SYNC,
PP_TO_ANN_RECEIPT, PP_TO_ANN_RECEIPT,
PP_TO_ANN_INTERVAL, PP_TO_ANN_INTERVAL,
PP_TO_FAULTY,
/* A few timeouts for the protocol extension */ /* A few timeouts for the protocol extension */
PP_TO_EXT_0, PP_TO_EXT_0,
PP_TO_EXT_1, PP_TO_EXT_1,
PP_TO_EXT_2, PP_TO_EXT_2,
PP_TO_EXT_3,
__PP_TO_ARRAY_SIZE, __PP_TO_ARRAY_SIZE,
}; };
......
...@@ -10,12 +10,19 @@ ...@@ -10,12 +10,19 @@
/* /*
* Fault troubleshooting. Now only prints an error messages and comes back to * Fault troubleshooting. Now only prints an error messages and comes back to
* PTP_INITIALIZING state * PTP_INITIALIZING state after a 4-seconds grace period
*/ */
int pp_faulty(struct pp_instance *ppi, unsigned char *pkt, int plen) int pp_faulty(struct pp_instance *ppi, unsigned char *pkt, int plen)
{ {
pp_diag(ppi, fsm, 1, "Faulty state detected\n"); if (ppi->is_new_state) {
ppi->next_state = PPS_INITIALIZING; pp_timeout_set(ppi, PP_TO_FAULTY, 4000);
}
if (pp_timeout(ppi, PP_TO_FAULTY)) {
ppi->next_state = PPS_INITIALIZING;
return 0;
}
ppi->next_delay = pp_ms_to_timeout(ppi, PP_TO_FAULTY);
return 0; return 0;
} }
...@@ -13,10 +13,10 @@ static char *timeout_names[__PP_TO_ARRAY_SIZE] __attribute__((used)) = { ...@@ -13,10 +13,10 @@ static char *timeout_names[__PP_TO_ARRAY_SIZE] __attribute__((used)) = {
N(PP_TO_SYNC), N(PP_TO_SYNC),
N(PP_TO_ANN_RECEIPT), N(PP_TO_ANN_RECEIPT),
N(PP_TO_ANN_INTERVAL), N(PP_TO_ANN_INTERVAL),
N(PP_TO_FAULTY),
N(PP_TO_EXT_0), N(PP_TO_EXT_0),
N(PP_TO_EXT_1), N(PP_TO_EXT_1),
N(PP_TO_EXT_2), N(PP_TO_EXT_2),
N(PP_TO_EXT_3),
}; };
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment