From 5e5c98b3dabb7f4379fb337783016475b27bcb89 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Wed, 3 Aug 2016 14:00:04 +0200 Subject: [PATCH] port: Fix input to the BMC for forming the spanning tree. If a non-slave port on a boundary clock see an announce message, then it must decide whether it should take on the MASTER or the PASSIVE role. When the GM fields from the local clock are identical to those in the announce, then the sender/receiver ports are used as a tie breaker. Following a typographical error in 1588, the code wrongly uses the port identity of the upstream parent as the "receiver" id. As a result, a port that should be PASSIVE may choose MASTER instead. This patch fixes the code to use local port id. Signed-off-by: Richard Cochran --- port.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/port.c b/port.c index 9f07cea..5868983 100644 --- a/port.c +++ b/port.c @@ -145,7 +145,7 @@ static int announce_compare(struct ptp_message *m1, struct ptp_message *m2) return memcmp(&a->grandmasterPriority1, &b->grandmasterPriority1, len); } -static void announce_to_dataset(struct ptp_message *m, struct clock *c, +static void announce_to_dataset(struct ptp_message *m, struct port *p, struct dataset *out) { struct announce_msg *a = &m->announce; @@ -155,7 +155,7 @@ static void announce_to_dataset(struct ptp_message *m, struct clock *c, out->priority2 = a->grandmasterPriority2; out->stepsRemoved = a->stepsRemoved; out->sender = m->header.sourcePortIdentity; - out->receiver = clock_parent_identity(c); + out->receiver = p->portIdentity; } static int msg_current(struct ptp_message *m, struct timespec now) @@ -2032,7 +2032,7 @@ struct foreign_clock *port_compute_best(struct port *p) if (!tmp) continue; - announce_to_dataset(tmp, p->clock, &fc->dataset); + announce_to_dataset(tmp, p, &fc->dataset); fc_prune(fc);