From: Vincent Cheng <vincent.cheng...@renesas.com> On termination of a ptp4l unicast session, ptp4l sends CANCEL_UNICAST_TRANSMISSION for announce, sync and delay response messages for all entries of the unicast master table regardless if the service is active or inactive.
This patch modifies unicast_client_tx_cancel() to only send CANCEL_UNICAST_TRANSMISSION for the unicast services that have been granted, ie. stop sending abnormal contract cancel requests. Signed-off-by: Vincent Cheng <vincent.cheng...@renesas.com> --- port.c | 4 ++-- unicast_client.c | 27 +++++++++++++++++++-------- unicast_client.h | 12 +++++++++--- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/port.c b/port.c index 1866a20..fe1f9a8 100644 --- a/port.c +++ b/port.c @@ -177,7 +177,7 @@ static void port_cancel_unicast(struct port *p) STAILQ_FOREACH(ucma, &p->unicast_master_table->addrs, list) { if (ucma) { - unicast_client_tx_cancel(p, ucma); + unicast_client_tx_cancel(p, ucma, UNICAST_CANCEL_ALL); } } } @@ -194,7 +194,7 @@ static int port_unicast_message_valid(struct port *p, struct ptp_message *m) pr_warning("%s: new foreign master %s not in unicast master table", p->log_name, pid2str(&m->header.sourcePortIdentity)); - if (unicast_client_tx_cancel(p, &master)) { + if (unicast_client_tx_cancel(p, &master, (1 << msg_type(m)))) { pr_warning("%s: cancel unicast transmission to %s failed", p->log_name, pid2str(&m->header.sourcePortIdentity)); } diff --git a/unicast_client.c b/unicast_client.c index 039967f..fcaeb65 100644 --- a/unicast_client.c +++ b/unicast_client.c @@ -592,28 +592,39 @@ int unicast_client_msg_is_from_master_table_entry(struct port *p, struct ptp_mes } int unicast_client_tx_cancel(struct port *p, - struct unicast_master_address *dst) + struct unicast_master_address *dst, + unsigned int bitmask) { struct ptp_message *msg; int err; + if (!(dst->granted & bitmask)) { + return 0; + } msg = port_signaling_uc_construct(p, &dst->address, &dst->portIdentity); if (!msg) { return -1; } - err = attach_cancel(msg, ANNOUNCE); - if (err) { - goto out; + if (dst->granted & (bitmask & (1 << ANNOUNCE))) { + err = attach_cancel(msg, ANNOUNCE); + if (err) { + goto out; + } + dst->granted &= ~(1 << ANNOUNCE); } - err = attach_cancel(msg, SYNC); - if (err) { - goto out; + if (dst->granted & (bitmask & (1 << SYNC))) { + err = attach_cancel(msg, SYNC); + if (err) { + goto out; + } + dst->granted &= ~(1 << SYNC); } - if (p->delayMechanism != DM_P2P) { + if (dst->granted & (bitmask & (1 << DELAY_RESP))) { err = attach_cancel(msg, DELAY_RESP); if (err) { goto out; } + dst->granted &= ~(1 << DELAY_RESP); } err = port_prepare_and_send(p, msg, TRANS_GENERAL); diff --git a/unicast_client.h b/unicast_client.h index 18a12c8..e643cb2 100644 --- a/unicast_client.h +++ b/unicast_client.h @@ -20,6 +20,9 @@ #ifndef HAVE_UNICAST_CLIENT_H #define HAVE_UNICAST_CLIENT_H +#define UNICAST_CANCEL_ALL (1 << ANNOUNCE | 1 << SYNC | 1 << DELAY_RESP) +#define UNICAST_CANCEL_SYDY (1 << SYNC | 1 << DELAY_RESP) + /** * Handles a CANCEL_UNICAST_TRANSMISSION TLV from the grantor. * @param p The port on which the signaling message was received. @@ -95,10 +98,13 @@ int unicast_client_msg_is_from_master_table_entry(struct port *p, /** * Transmit CANCEL_UNICAST_TRANSMISSION TLV to destination address. - * @param p The port in question. - * @param dst The destination address. + * @param p The port in question. + * @param dst The destination address. + * @param bitmask Cancel message type bitmask + * @param * @return Zero on success, non-zero otherwise. */ int unicast_client_tx_cancel(struct port *p, - struct unicast_master_address *dst); + struct unicast_master_address *dst, + unsigned int bitmask); #endif -- 2.34.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel