|
|
63b4e9 |
diff --git a/unicast_client.c b/unicast_client.c
|
|
|
63b4e9 |
index 71dd18e..a7efef6 100644
|
|
|
63b4e9 |
--- a/unicast_client.c
|
|
|
63b4e9 |
+++ b/unicast_client.c
|
|
|
63b4e9 |
@@ -339,11 +339,16 @@ int unicast_client_cancel(struct port *p, struct ptp_message *m,
|
|
|
63b4e9 |
if (cancel->message_type_flags & CANCEL_UNICAST_MAINTAIN_GRANT) {
|
|
|
63b4e9 |
return 0;
|
|
|
63b4e9 |
}
|
|
|
63b4e9 |
+
|
|
|
63b4e9 |
pr_warning("%s: server unilaterally canceled unicast %s grant",
|
|
|
63b4e9 |
p->log_name, msg_type_string(mtype));
|
|
|
63b4e9 |
|
|
|
63b4e9 |
+ int state = ucma->state;
|
|
|
63b4e9 |
ucma->state = unicast_fsm(ucma->state, UC_EV_CANCEL);
|
|
|
63b4e9 |
+ pr_notice("unicast client state change CANCEL, ucma = %s->%s, id=%s", ustate2str(state), ustate2str(ucma->state), cid2str(&ucma->portIdentity.clockIdentity));
|
|
|
63b4e9 |
ucma->granted &= ~(1 << mtype);
|
|
|
63b4e9 |
+ // trigger clock state change event
|
|
|
63b4e9 |
+ clock_set_sde(p->clock, 1);
|
|
|
63b4e9 |
|
|
|
63b4e9 |
/* Respond with ACK. */
|
|
|
63b4e9 |
msg = port_signaling_uc_construct(p, &ucma->address, &ucma->portIdentity);
|
|
|
63b4e9 |
@@ -446,6 +451,8 @@ void unicast_client_grant(struct port *p, struct ptp_message *m,
|
|
|
63b4e9 |
p->log_name, msg_type_string(mtype));
|
|
|
63b4e9 |
if (mtype != PDELAY_RESP) {
|
|
|
63b4e9 |
ucma->state = UC_WAIT;
|
|
|
63b4e9 |
+ // trigger clock state change event
|
|
|
63b4e9 |
+ clock_set_sde(p->clock, 1);
|
|
|
63b4e9 |
}
|
|
|
63b4e9 |
return;
|
|
|
63b4e9 |
}
|
|
|
63b4e9 |
@@ -473,10 +480,30 @@ void unicast_client_grant(struct port *p, struct ptp_message *m,
|
|
|
63b4e9 |
|
|
|
63b4e9 |
switch (ucma->state) {
|
|
|
63b4e9 |
case UC_HAVE_ANN:
|
|
|
63b4e9 |
+ if (mtype == ANNOUNCE) {
|
|
|
63b4e9 |
+ int state = ucma->state;
|
|
|
63b4e9 |
+ struct PortIdentity pid;
|
|
|
63b4e9 |
+ pid = clock_parent_identity(p->clock);
|
|
|
63b4e9 |
+ // if we are current master and stuck in HAVE_ANN state,
|
|
|
63b4e9 |
+ // kick the state up to NEED_SYDY, this will either trigger
|
|
|
63b4e9 |
+ // master re-election after sync timeout, or fix things.
|
|
|
63b4e9 |
+ if (pid_eq(&ucma->portIdentity, &pid)) {
|
|
|
63b4e9 |
+ pr_warning("received ANNOUNCE grant for current master in UC_HAVE_ANN state, unblocking");
|
|
|
63b4e9 |
+ ucma->state = UC_NEED_SYDY;
|
|
|
63b4e9 |
+ } else {
|
|
|
63b4e9 |
+ ucma->state = unicast_fsm(ucma->state, UC_EV_GRANT_ANN);
|
|
|
63b4e9 |
+ }
|
|
|
63b4e9 |
+ ucma->portIdentity = m->header.sourcePortIdentity;
|
|
|
63b4e9 |
+ pr_notice("unicast client state change GRANT_ANN, ucma = %s->%s, id=%s", ustate2str(state), ustate2str(ucma->state), cid2str(&ucma->portIdentity.clockIdentity));
|
|
|
63b4e9 |
+ unicast_client_set_renewal(p, ucma, g->durationField);
|
|
|
63b4e9 |
+ }
|
|
|
63b4e9 |
+ break;
|
|
|
63b4e9 |
case UC_WAIT:
|
|
|
63b4e9 |
if (mtype == ANNOUNCE) {
|
|
|
63b4e9 |
+ int state = ucma->state;
|
|
|
63b4e9 |
ucma->state = unicast_fsm(ucma->state, UC_EV_GRANT_ANN);
|
|
|
63b4e9 |
ucma->portIdentity = m->header.sourcePortIdentity;
|
|
|
63b4e9 |
+ pr_notice("unicast client state change GRANT_ANN, ucma = %s->%s, id=%s", ustate2str(state), ustate2str(ucma->state), cid2str(&ucma->portIdentity.clockIdentity));
|
|
|
63b4e9 |
unicast_client_set_renewal(p, ucma, g->durationField);
|
|
|
63b4e9 |
}
|
|
|
63b4e9 |
break;
|
|
|
63b4e9 |
@@ -484,16 +511,20 @@ void unicast_client_grant(struct port *p, struct ptp_message *m,
|
|
|
63b4e9 |
switch (mtype) {
|
|
|
63b4e9 |
case DELAY_RESP:
|
|
|
63b4e9 |
if ((ucma->granted & ucma->sydymsk) == ucma->sydymsk) {
|
|
|
63b4e9 |
+ int state = ucma->state;
|
|
|
63b4e9 |
ucma->state = unicast_fsm(ucma->state,
|
|
|
63b4e9 |
UC_EV_GRANT_SYDY);
|
|
|
63b4e9 |
+ pr_notice("unicast client state change GRANT_SYDY DELAY_RESP, ucma = %s->%s, id=%s", ustate2str(state), ustate2str(ucma->state), cid2str(&ucma->portIdentity.clockIdentity));
|
|
|
63b4e9 |
}
|
|
|
63b4e9 |
unicast_client_set_renewal(p, ucma, g->durationField);
|
|
|
63b4e9 |
p->logMinDelayReqInterval = g->logInterMessagePeriod;
|
|
|
63b4e9 |
break;
|
|
|
63b4e9 |
case SYNC:
|
|
|
63b4e9 |
if ((ucma->granted & ucma->sydymsk) == ucma->sydymsk) {
|
|
|
63b4e9 |
+ int state = ucma->state;
|
|
|
63b4e9 |
ucma->state = unicast_fsm(ucma->state,
|
|
|
63b4e9 |
UC_EV_GRANT_SYDY);
|
|
|
63b4e9 |
+ pr_notice("unicast client state change GRANT_SYDY SYNC, ucma = %s->%s, id=%s", ustate2str(state), ustate2str(ucma->state), cid2str(&ucma->portIdentity.clockIdentity));
|
|
|
63b4e9 |
}
|
|
|
63b4e9 |
unicast_client_set_renewal(p, ucma, g->durationField);
|
|
|
63b4e9 |
clock_sync_interval(p->clock, g->logInterMessagePeriod);
|
|
|
63b4e9 |
@@ -529,10 +560,13 @@ void unicast_client_state_changed(struct port *p)
|
|
|
63b4e9 |
pid = clock_parent_identity(p->clock);
|
|
|
63b4e9 |
|
|
|
63b4e9 |
STAILQ_FOREACH(ucma, &p->unicast_master_table->addrs, list) {
|
|
|
63b4e9 |
+ int state = ucma->state;
|
|
|
63b4e9 |
if (pid_eq(&ucma->portIdentity, &pid)) {
|
|
|
63b4e9 |
ucma->state = unicast_fsm(ucma->state, UC_EV_SELECTED);
|
|
|
63b4e9 |
+ pr_notice("unicast client state change SELECTED, ucma = %s->%s, id=%s, pid=%s", ustate2str(state), ustate2str(ucma->state), cid2str(&ucma->portIdentity.clockIdentity), cid2str(&pid.clockIdentity));
|
|
|
63b4e9 |
} else {
|
|
|
63b4e9 |
ucma->state = unicast_fsm(ucma->state, UC_EV_UNSELECTED);
|
|
|
63b4e9 |
+ pr_notice("unicast client state change UNSELECTED, ucma = %s->%s, id=%s, pid=%s", ustate2str(state), ustate2str(ucma->state), cid2str(&ucma->portIdentity.clockIdentity), cid2str(&pid.clockIdentity));
|
|
|
63b4e9 |
}
|
|
|
63b4e9 |
}
|
|
|
63b4e9 |
}
|