Ignore messages from ourselves and from the wrong domain.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2011-12-30 11:04:20 +01:00
parent 851675833a
commit e47549e73f
1 changed files with 24 additions and 1 deletions

25
port.c
View File

@ -229,6 +229,26 @@ static int port_clr_tmo(int fd)
return timerfd_settime(fd, 0, &tmo, NULL); return timerfd_settime(fd, 0, &tmo, NULL);
} }
static int port_ignore(struct port *p, struct ptp_message *m)
{
struct ClockIdentity c1, c2;
if (pid_eq(&m->header.sourcePortIdentity, &p->portIdentity)) {
return 1;
}
if (m->header.domainNumber != clock_domain_number(p->clock)) {
return 1;
}
c1 = clock_identity(p->clock);
c2 = m->header.sourcePortIdentity.clockIdentity;
if (0 == memcmp(&c1, &c2, sizeof(c1))) {
return 1;
}
return 0;
}
static int port_set_announce_tmo(struct port *p) static int port_set_announce_tmo(struct port *p)
{ {
struct itimerspec tmo = { struct itimerspec tmo = {
@ -876,12 +896,15 @@ enum fsm_event port_event(struct port *p, int fd_index)
msg_put(msg); msg_put(msg);
return EV_FAULT_DETECTED; return EV_FAULT_DETECTED;
} }
if (msg_post_recv(msg, cnt)) { if (msg_post_recv(msg, cnt)) {
pr_err("port %hu: bad message", portnum(p)); pr_err("port %hu: bad message", portnum(p));
msg_put(msg); msg_put(msg);
return EV_NONE; return EV_NONE;
} }
if (port_ignore(p, msg)) {
msg_put(msg);
return EV_NONE;
}
switch (msg_type(msg)) { switch (msg_type(msg)) {
case SYNC: case SYNC: