From d72e795727d40353feb31933bd8cad73138d8026 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 1 Dec 2013 20:47:10 +0100 Subject: [PATCH] Inhibit sync messages from unwilling 802.1AS ports. According to 802.1AS, ports are always expected to transmit announce messages, even if they never want to become the grand master. Instead of using a slave only BMC state machine as in 1588, 802.1AS offers a "grand master capable" flag which allows clocks to not send sync messages. This patch keeps a port from transmitting sync (but not announce) messages when there is no other master. Signed-off-by: Richard Cochran --- port.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/port.c b/port.c index 13a34a2..36655d3 100644 --- a/port.c +++ b/port.c @@ -532,6 +532,31 @@ static int port_ignore(struct port *p, struct ptp_message *m) return 0; } +/* + * Test whether a 802.1AS port may transmit a sync message. + */ +static int port_sync_incapable(struct port *p) +{ + struct ClockIdentity cid; + struct PortIdentity pid; + + if (!port_is_ieee8021as(p)) { + return 0; + } + if (clock_gm_capable(p->clock)) { + return 0; + } + cid = clock_identity(p->clock); + pid = clock_parent_identity(p->clock); + if (!memcmp(&cid, &pid.clockIdentity, sizeof(cid))) { + /* + * We are the GM, but without gmCapable set. + */ + return 1; + } + return 0; +} + static int port_is_ieee8021as(struct port *p) { return p->pod.follow_up_info ? 1 : 0; @@ -1148,6 +1173,9 @@ static int port_tx_sync(struct port *p) if (!port_capable(p)) { return 0; } + if (port_sync_incapable(p)) { + return 0; + } msg = msg_allocate(); if (!msg) return -1;