From a1dcd3e844b049a591382f183430459886fca2e2 Mon Sep 17 00:00:00 2001 From: Davide Cavalca Date: Jan 13 2023 21:16:41 +0000 Subject: Backport two more bugfix patches --- diff --git a/linuxptp.spec b/linuxptp.spec index 3a2979e..53f9088 100644 --- a/linuxptp.spec +++ b/linuxptp.spec @@ -7,7 +7,7 @@ Name: linuxptp Version: 3.1.1^%{gitdate}git%{gitver} -Release: 1.1%{?dist} +Release: 1.2%{?dist} Summary: PTP implementation for Linux License: GPLv2+ @@ -46,6 +46,10 @@ Patch204: 08-filter-timers.patch Patch206: tx-timestamp-fail.patch # filter: treat negative path_delay as a spike Patch207: path-delay-spike.patch +# unicast_client: further improve CANCEL logic +Patch208: unicast-cancel.patch +# port: start sync rx timer on grant +Patch209: set-sync-rx-timer.patch BuildRequires: gcc gcc-c++ make systemd @@ -134,6 +138,9 @@ PATH=..:$PATH ./run || true %{_mandir}/man8/*.8* %changelog +* Fri Jan 13 2023 Davide Cavalca - 3.1.1^20221207git6bac46-1.2 +- Backport two more bugfix patches + * Thu Jan 12 2023 Davide Cavalca - 3.1.1^20221207git6bac46-1.1 - Update to the latest git snapshot and drop merged patches - Backport two more bugfix patches diff --git a/set-sync-rx-timer.patch b/set-sync-rx-timer.patch new file mode 100644 index 0000000..6018531 --- /dev/null +++ b/set-sync-rx-timer.patch @@ -0,0 +1,53 @@ +commit 2ef188d3f196f2713c5f664f26e18e574992f04f +Author: Vadim Fedorenko +Date: Fri Jan 13 12:38:44 2023 -0800 + + port: start sync rx timer on grant + + In case of broken network there is a possibility of having management + packets with proper data but absolute absence of sync packets. In such + case the selected best master will stuck in HAVE_SYDY state without + actually synchronising and will never fail because sync rx timeout timer + is armed just after first receive of both SYNC and FOLLOW-UP packets. + + The patch arms sync rx timeout timer once sync grant is received. + + Signed-off-by: Vadim Fedorenko + +diff --git a/port.c b/port.c +index 02b49a1..558a422 100644 +--- a/port.c ++++ b/port.c +@@ -1235,7 +1235,7 @@ int port_set_qualification_tmo(struct port *p) + 1+clock_steps_removed(p->clock), p->logAnnounceInterval); + } + +-static int port_set_sync_rx_tmo(struct port *p) ++int port_set_sync_rx_tmo(struct port *p) + { + return set_tmo_log(p->fda.fd[FD_SYNC_RX_TIMER], + p->syncReceiptTimeout, p->logSyncInterval); +diff --git a/port_private.h b/port_private.h +index d27dceb..24d0045 100644 +--- a/port_private.h ++++ b/port_private.h +@@ -182,6 +182,7 @@ int port_is_enabled(struct port *p); + void port_link_status(void *ctx, int index, int linkup); + int port_set_announce_tmo(struct port *p); + int port_set_delay_tmo(struct port *p); ++int port_set_sync_rx_tmo(struct port *p); + int port_set_qualification_tmo(struct port *p); + void port_show_transition(struct port *p, enum port_state next, + enum fsm_event event); +diff --git a/unicast_client.c b/unicast_client.c +index 633a4fe..5b46d1c 100644 +--- a/unicast_client.c ++++ b/unicast_client.c +@@ -512,6 +512,7 @@ void unicast_client_grant(struct port *p, struct ptp_message *m, + } + unicast_client_set_renewal(p, ucma, g->durationField); + clock_sync_interval(p->clock, g->logInterMessagePeriod); ++ port_set_sync_rx_tmo(p); + break; + } + break; diff --git a/unicast-cancel.patch b/unicast-cancel.patch new file mode 100644 index 0000000..c3a3a01 --- /dev/null +++ b/unicast-cancel.patch @@ -0,0 +1,68 @@ +commit c304dbe4060da421a9bf089188c5016ef97aacf1 +Author: Vadim Fedorenko +Date: Fri Jan 13 12:34:34 2023 -0800 + + unicast_client: further improve CANCEL logic + + bc_dispatch should work right after recieving CANCEL otherwise + state machine can stuck in HAVE_ANN state. + + Also another code to be safe on this side and recover selected + best master from being stuck in HAVE_ANN state. + + Signed-off-by: Vadim Fedorenko + +diff --git a/port.c b/port.c +index 6b5483f..02b49a1 100644 +--- a/port.c ++++ b/port.c +@@ -2982,8 +2982,11 @@ static enum fsm_event bc_event(struct port *p, int fd_index) + event = EV_STATE_DECISION_EVENT; + break; + case SIGNALING: +- if (process_signaling(p, msg)) { ++ err = process_signaling(p, msg); ++ if (err < 0) { + event = EV_FAULT_DETECTED; ++ } else if (err) { ++ event = EV_STATE_DECISION_EVENT; + } + break; + case MANAGEMENT: +diff --git a/unicast_client.c b/unicast_client.c +index 81113ae..633a4fe 100644 +--- a/unicast_client.c ++++ b/unicast_client.c +@@ -363,7 +363,7 @@ int unicast_client_cancel(struct port *p, struct ptp_message *m, + } + out: + msg_put(msg); +- return err; ++ return err ? err : 1; + } + + int unicast_client_initialize(struct port *p) +@@ -433,6 +433,7 @@ int unicast_client_enabled(struct port *p) + void unicast_client_grant(struct port *p, struct ptp_message *m, + struct tlv_extra *extra) + { ++ struct PortIdentity pid = clock_parent_identity(p->clock); + struct unicast_master_address *ucma; + struct grant_unicast_xmit_tlv *g; + int mtype; +@@ -478,6 +479,15 @@ void unicast_client_grant(struct port *p, struct ptp_message *m, + + switch (ucma->state) { + case UC_HAVE_ANN: ++ if (mtype == ANNOUNCE) { ++ if (pid_eq(&ucma->portIdentity, &pid)) { ++ ucma->state = UC_NEED_SYDY; ++ pr_warning("received ANNOUNCE grant for current master in UC_HAVE_ANN state, unblocking"); ++ } ++ ucma->portIdentity = m->header.sourcePortIdentity; ++ unicast_client_set_renewal(p, ucma, g->durationField); ++ } ++ break; + case UC_WAIT: + if (mtype == ANNOUNCE) { + ucma->state = unicast_fsm(ucma->state, UC_EV_GRANT_ANN);