a1dcd3
commit 2ef188d3f196f2713c5f664f26e18e574992f04f
a1dcd3
Author: Vadim Fedorenko <vadfed@meta.com>
a1dcd3
Date:   Fri Jan 13 12:38:44 2023 -0800
a1dcd3
a1dcd3
    port: start sync rx timer on grant
a1dcd3
    
a1dcd3
    In case of broken network there is a possibility of having management
a1dcd3
    packets with proper data but absolute absence of sync packets. In such
a1dcd3
    case the selected best master will stuck in HAVE_SYDY state without
a1dcd3
    actually synchronising and will never fail because sync rx timeout timer
a1dcd3
    is armed just after first receive of both SYNC and FOLLOW-UP packets.
a1dcd3
    
a1dcd3
    The patch arms sync rx timeout timer once sync grant is received.
a1dcd3
    
a1dcd3
    Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
a1dcd3
a1dcd3
diff --git a/port.c b/port.c
a1dcd3
index 02b49a1..558a422 100644
a1dcd3
--- a/port.c
a1dcd3
+++ b/port.c
a1dcd3
@@ -1235,7 +1235,7 @@ int port_set_qualification_tmo(struct port *p)
a1dcd3
 		       1+clock_steps_removed(p->clock), p->logAnnounceInterval);
a1dcd3
 }
a1dcd3
 
a1dcd3
-static int port_set_sync_rx_tmo(struct port *p)
a1dcd3
+int port_set_sync_rx_tmo(struct port *p)
a1dcd3
 {
a1dcd3
 	return set_tmo_log(p->fda.fd[FD_SYNC_RX_TIMER],
a1dcd3
 			   p->syncReceiptTimeout, p->logSyncInterval);
a1dcd3
diff --git a/port_private.h b/port_private.h
a1dcd3
index d27dceb..24d0045 100644
a1dcd3
--- a/port_private.h
a1dcd3
+++ b/port_private.h
a1dcd3
@@ -182,6 +182,7 @@ int port_is_enabled(struct port *p);
a1dcd3
 void port_link_status(void *ctx, int index, int linkup);
a1dcd3
 int port_set_announce_tmo(struct port *p);
a1dcd3
 int port_set_delay_tmo(struct port *p);
a1dcd3
+int port_set_sync_rx_tmo(struct port *p);
a1dcd3
 int port_set_qualification_tmo(struct port *p);
a1dcd3
 void port_show_transition(struct port *p, enum port_state next,
a1dcd3
 			  enum fsm_event event);
a1dcd3
diff --git a/unicast_client.c b/unicast_client.c
a1dcd3
index 633a4fe..5b46d1c 100644
a1dcd3
--- a/unicast_client.c
a1dcd3
+++ b/unicast_client.c
a1dcd3
@@ -512,6 +512,7 @@ void unicast_client_grant(struct port *p, struct ptp_message *m,
a1dcd3
 			}
a1dcd3
 			unicast_client_set_renewal(p, ucma, g->durationField);
a1dcd3
 			clock_sync_interval(p->clock, g->logInterMessagePeriod);
a1dcd3
+			port_set_sync_rx_tmo(p);
a1dcd3
 			break;
a1dcd3
 		}
a1dcd3
 		break;