From bf8c7ce41f8371ef3ceb425ec9e672bc62a52590 Mon Sep 17 00:00:00 2001 From: David Cemin Date: Mon, 14 Mar 2016 15:08:27 -0400 Subject: Abort when received clkid is not the same as src According to subclause 11.2.15.3, figure 11-8, a condition to leave the state WAITING_FOR_PDELAY_RESP is that the received clock id is the same as the source. This commit adds this verification. This patch fixes part A of gPTP.15.4, which is addressed by Issue #139. --- daemons/gptp/common/ptp_message.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/daemons/gptp/common/ptp_message.cpp b/daemons/gptp/common/ptp_message.cpp index 01dcb49f..7fb75f01 100644 --- a/daemons/gptp/common/ptp_message.cpp +++ b/daemons/gptp/common/ptp_message.cpp @@ -1340,6 +1340,8 @@ void PTPMessagePathDelayRespFollowUp::processMessage(IEEE1588Port * port) PortIdentity req_id; PortIdentity resp_id; + ClockIdentity req_clkId; + ClockIdentity resp_clkId; if (req == NULL) { /* Shouldn't happen */ @@ -1358,6 +1360,8 @@ void PTPMessagePathDelayRespFollowUp::processMessage(IEEE1588Port * port) req->getPortIdentity(&req_id); resp->getRequestingPortIdentity(&resp_id); + req_clkId = req_id.getClockIdentity(); + resp_clkId = resp_id.getClockIdentity(); if( req->getSequenceId() != sequenceId ) { XPTPD_ERROR @@ -1381,6 +1385,18 @@ void PTPMessagePathDelayRespFollowUp::processMessage(IEEE1588Port * port) goto abort; } + /* + * According to Figure 11-8 of subclause 11.2.15.3, a condition to leave the state + * WAITING_FOR_PDELAY_RESP is if the clock identity in the response is the same + * as this clock + */ + if (req_clkId != resp_clkId ) { + XPTPD_ERROR + ("ClockID Resp/Req differs. PDelay Response ClockID: %s PDelay Request ClockID: %s", + req_clkId.getIdentityString().c_str(), resp_clkId.getIdentityString().c_str() ); + goto abort; + } + port->getClock()->deleteEventTimerLocked (port, PDELAY_RESP_RECEIPT_TIMEOUT_EXPIRES); -- cgit v1.2.1 From cf8b9ee882dd6356e3680e88c00f60495a55f561 Mon Sep 17 00:00:00 2001 From: David Cemin Date: Mon, 14 Mar 2016 15:30:47 -0400 Subject: Abort if recv portID differs from req portID Another condition to leave the WAITING_FOR_PDELAY_RESP state is that the requested port ID is the same as the response port ID. This commit fixes this issue. This patch fixes part B of gPTP 15.4, which is addressed by Issue #139 --- daemons/gptp/common/ptp_message.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/daemons/gptp/common/ptp_message.cpp b/daemons/gptp/common/ptp_message.cpp index 7fb75f01..684130d5 100644 --- a/daemons/gptp/common/ptp_message.cpp +++ b/daemons/gptp/common/ptp_message.cpp @@ -1343,6 +1343,9 @@ void PTPMessagePathDelayRespFollowUp::processMessage(IEEE1588Port * port) ClockIdentity req_clkId; ClockIdentity resp_clkId; + uint16_t resp_port_number; + uint16_t req_port_number; + if (req == NULL) { /* Shouldn't happen */ XPTPD_ERROR @@ -1362,6 +1365,8 @@ void PTPMessagePathDelayRespFollowUp::processMessage(IEEE1588Port * port) resp->getRequestingPortIdentity(&resp_id); req_clkId = req_id.getClockIdentity(); resp_clkId = resp_id.getClockIdentity(); + resp_id.getPortNumber(&resp_port_number); + requestingPortIdentity->getPortNumber(&req_port_number); if( req->getSequenceId() != sequenceId ) { XPTPD_ERROR @@ -1370,12 +1375,11 @@ void PTPMessagePathDelayRespFollowUp::processMessage(IEEE1588Port * port) goto abort; } + /* + * According to Figure 11-8 of subclause 11.2.15.3, a condition to leave the state + * WAITING_FOR_PDELAY_RESP is if the response seqID is the same as the requested. + */ if (resp->getSequenceId() != sequenceId) { - uint16_t resp_port_number; - uint16_t req_port_number; - resp_id.getPortNumber(&resp_port_number); - requestingPortIdentity->getPortNumber(&req_port_number); - XPTPD_ERROR ("Received PDelay Response Follow Up but cannot find " "corresponding response"); @@ -1397,6 +1401,18 @@ void PTPMessagePathDelayRespFollowUp::processMessage(IEEE1588Port * port) goto abort; } + /* + * According to Figure 11-8 of subclause 11.2.15.3, a condition to leave the state + * WAITING_FOR_PDELAY_RESP is if the response portID is the same as the requested. + */ + if ( resp_port_number != req_port_number ) { + XPTPD_ERROR + ("Request portID (%hu) is different from Response portID (%hu)", + resp_port_number, req_port_number); + + goto abort; + } + port->getClock()->deleteEventTimerLocked (port, PDELAY_RESP_RECEIPT_TIMEOUT_EXPIRES); -- cgit v1.2.1 From 3f21a229a63f297ea6725cca5322c62bd15f9660 Mon Sep 17 00:00:00 2001 From: David Cemin Date: Mon, 14 Mar 2016 16:39:04 -0400 Subject: Abort in case sourcePortIdentity differns in response/fup messages This commit adds a condition to leave the state WAITING_FOR_PDELAY_RESP_FOLLOW_UP from the figure 11-8 of subclause 11.2.15.3 of 802.1AS-2011. In both PDelay response and PDelay response foloow up, the sourcePortIdentity value must be the same. This patch fixes parts E, F1 and F2 from gPTP 15.4, tracked by Issue #139 --- daemons/gptp/common/ptp_message.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/daemons/gptp/common/ptp_message.cpp b/daemons/gptp/common/ptp_message.cpp index 684130d5..7476abae 100644 --- a/daemons/gptp/common/ptp_message.cpp +++ b/daemons/gptp/common/ptp_message.cpp @@ -1340,6 +1340,8 @@ void PTPMessagePathDelayRespFollowUp::processMessage(IEEE1588Port * port) PortIdentity req_id; PortIdentity resp_id; + PortIdentity fup_sourcePortIdentity; + PortIdentity resp_sourcePortIdentity; ClockIdentity req_clkId; ClockIdentity resp_clkId; @@ -1367,6 +1369,8 @@ void PTPMessagePathDelayRespFollowUp::processMessage(IEEE1588Port * port) resp_clkId = resp_id.getClockIdentity(); resp_id.getPortNumber(&resp_port_number); requestingPortIdentity->getPortNumber(&req_port_number); + resp->getPortIdentity(&resp_sourcePortIdentity); + getPortIdentity(&fup_sourcePortIdentity); if( req->getSequenceId() != sequenceId ) { XPTPD_ERROR @@ -1407,12 +1411,23 @@ void PTPMessagePathDelayRespFollowUp::processMessage(IEEE1588Port * port) */ if ( resp_port_number != req_port_number ) { XPTPD_ERROR - ("Request portID (%hu) is different from Response portID (%hu)", + ("Request port number (%hu) is different from Response port number (%hu)", resp_port_number, req_port_number); goto abort; } + /* + * According to Figure 11-8 of subclause 11.2.15.3, a condition to leave the state + * WAITING_FOR_PDELAY_RESP is if the sourcePortIdentity from PDelay Response and PDelay + * response Follow-UP (FUP) are the same. + */ + if ( fup_sourcePortIdentity != resp_sourcePortIdentity ) { + XPTPD_ERROR("Source port identity from PDelay Response/FUP differ"); + + goto abort; + } + port->getClock()->deleteEventTimerLocked (port, PDELAY_RESP_RECEIPT_TIMEOUT_EXPIRES); -- cgit v1.2.1