According to IEEE 1588, each destination should have its own, unique
message sequence with respect to the sequenceId field.  The current
code will generate skips in the number sequence in the presence of
unicast clients.  Fix the issue by giving each client its own
sequence of Announce messages.

Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
---
 port.c            | 7 ++++---
 port_private.h    | 2 +-
 unicast_service.c | 6 +++++-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/port.c b/port.c
index 6e6b0aa..eed0293 100644
--- a/port.c
+++ b/port.c
@@ -1455,7 +1455,7 @@ out:
        return -1;
 }
 
-int port_tx_announce(struct port *p, struct address *dst)
+int port_tx_announce(struct port *p, struct address *dst, uint16_t sequence_id)
 {
        struct timePropertiesDS tp = clock_time_properties(p->clock);
        struct parent_ds *dad = clock_parent_ds(p->clock);
@@ -1480,7 +1480,7 @@ int port_tx_announce(struct port *p, struct address *dst)
        msg->header.messageLength      = sizeof(struct announce_msg);
        msg->header.domainNumber       = clock_domain_number(p->clock);
        msg->header.sourcePortIdentity = p->portIdentity;
-       msg->header.sequenceId         = p->seqnum.announce++;
+       msg->header.sequenceId         = sequence_id;
        msg->header.control            = CTL_OTHER;
        msg->header.logMessageInterval = p->logAnnounceInterval;
 
@@ -2706,7 +2706,8 @@ static enum fsm_event bc_event(struct port *p, int 
fd_index)
                pr_debug("%s: master tx announce timeout", p->log_name);
                port_set_manno_tmo(p);
                clock_update_leap_status(p->clock);
-               return port_tx_announce(p, NULL) ? EV_FAULT_DETECTED : EV_NONE;
+               return port_tx_announce(p, NULL, p->seqnum.announce++) ?
+                       EV_FAULT_DETECTED : EV_NONE;
 
        case FD_SYNC_TX_TIMER:
                pr_debug("%s: master sync timeout", p->log_name);
diff --git a/port_private.h b/port_private.h
index 5391879..ca5ba2d 100644
--- a/port_private.h
+++ b/port_private.h
@@ -187,7 +187,7 @@ void port_show_transition(struct port *p, enum port_state 
next,
 struct ptp_message *port_signaling_uc_construct(struct port *p,
                                                struct address *address,
                                                struct PortIdentity *tpid);
-int port_tx_announce(struct port *p, struct address *dst);
+int port_tx_announce(struct port *p, struct address *dst, uint16_t 
sequence_id);
 int port_tx_interval_request(struct port *p,
                             Integer8 announceInterval,
                             Integer8 timeSyncInterval,
diff --git a/unicast_service.c b/unicast_service.c
index 2078740..f122b10 100644
--- a/unicast_service.c
+++ b/unicast_service.c
@@ -36,6 +36,9 @@
 struct unicast_client_address {
        LIST_ENTRY(unicast_client_address) list;
        struct PortIdentity portIdentity;
+       struct {
+               UInteger16 announce;
+       } seqnum;
        unsigned int message_types;
        struct address addr;
        time_t grant_tmo;
@@ -181,7 +184,8 @@ static int unicast_service_clients(struct port *p,
                        continue;
                }
                if (client->message_types & (1 << ANNOUNCE)) {
-                       if (port_tx_announce(p, &client->addr)) {
+                       if (port_tx_announce(p, &client->addr,
+                                            client->seqnum.announce++)) {
                                err = -1;
                        }
                }
-- 
2.20.1



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to