Skip to content

Commit

Permalink
Maintain one Announce sequence counter per destination address.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
richardcochran committed Oct 11, 2021
1 parent 63592ef commit 8018892
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 4 additions & 3 deletions port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ int port_delay_request(struct port *p)
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);
Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion port_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion unicast_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 8018892

Please sign in to comment.