Ignore signaling messages on target port mismatch.

IEEE 1588 specifies dropping signaling messages if the
targetPortIdentity does not match the receiving port.  Up until now
the unicast code did check that field, but only for the unicast
transmission request and cancel operations.

This patch moves the target port identity check so that it applies to
each and every received signaling message.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2019-05-06 21:04:25 -07:00
parent cc54cdef27
commit b59a739d0f
2 changed files with 13 additions and 11 deletions

View File

@ -21,6 +21,13 @@
#include "unicast_client.h"
#include "unicast_service.h"
static struct PortIdentity wildcard = {
.clockIdentity = {
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
},
.portNumber = 0xffff,
};
struct ptp_message *port_signaling_construct(struct port *p,
struct address *address,
struct PortIdentity *tpid)
@ -67,6 +74,12 @@ int process_signaling(struct port *p, struct ptp_message *m)
break;
}
/* Ignore signaling messages not addressed to this port. */
if (!pid_eq(&m->signaling.targetPortIdentity, &p->portIdentity) &&
!pid_eq(&m->signaling.targetPortIdentity, &wildcard)) {
return 0;
}
TAILQ_FOREACH(extra, &m->tlv_list, list) {
switch (extra->tlv->type) {
case TLV_REQUEST_UNICAST_TRANSMISSION:

View File

@ -25,13 +25,6 @@
#define E2E_SYDY_MASK (1 << ANNOUNCE | 1 << SYNC | 1 << DELAY_RESP)
#define P2P_SYDY_MASK (1 << ANNOUNCE | 1 << SYNC)
static struct PortIdentity wildcard = {
.clockIdentity = {
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
},
.portNumber = 0xffff,
};
static int attach_ack(struct ptp_message *msg, uint8_t message_type_flags)
{
struct ack_cancel_unicast_xmit_tlv *ack;
@ -101,10 +94,6 @@ static struct unicast_master_address *unicast_client_ok(struct port *p,
if (!unicast_client_enabled(p)) {
return NULL;
}
if (!pid_eq(&m->signaling.targetPortIdentity, &p->portIdentity) &&
!pid_eq(&m->signaling.targetPortIdentity, &wildcard)) {
return NULL;
}
STAILQ_FOREACH(ucma, &p->unicast_master_table->addrs, list) {
if (addreq(transport_type(p->trp), &ucma->address, &m->address)) {
break;