From d58b1080bce54c60cd4375d74d32688c9e289491 Mon Sep 17 00:00:00 2001 From: Vedang Patel Date: Wed, 3 Oct 2018 09:41:52 -0700 Subject: [PATCH] Add ignore_source_id config option. This config option will skip the source port identity verification in the Sync and Follow_up messages. This option is needed when the announce messages are disabled because the slave cannot know the identity of master without announce messages. This is required by Automotive Profile as part of skipping the Best Master Clock Algorithm (BMCA). Signed-off-by: Vedang Patel --- config.c | 1 + configs/default.cfg | 1 + port.c | 22 ++++++++++++++++------ port_private.h | 1 + ptp4l.8 | 6 ++++++ 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/config.c b/config.c index a018066..2321310 100644 --- a/config.c +++ b/config.c @@ -240,6 +240,7 @@ struct config_item config_tab[] = { GLOB_ITEM_INT("gmCapable", 1, 0, 1), GLOB_ITEM_ENU("hwts_filter", HWTS_FILTER_NORMAL, hwts_filter_enu), PORT_ITEM_INT("hybrid_e2e", 0, 0, 1), + PORT_ITEM_INT("ignore_source_id", 0, 0, 1), PORT_ITEM_INT("ignore_transport_specific", 0, 0, 1), PORT_ITEM_INT("ingressLatency", 0, INT_MIN, INT_MAX), PORT_ITEM_INT("inhibit_announce", 0, 0, 1), diff --git a/configs/default.cfg b/configs/default.cfg index b791ea3..3ee3a9b 100644 --- a/configs/default.cfg +++ b/configs/default.cfg @@ -35,6 +35,7 @@ G.8275.portDS.localPriority 128 asCapable auto BMCA ptp inhibit_announce 0 +ignore_source_id 0 # # Run time options # diff --git a/port.c b/port.c index bf6860c..3e61179 100644 --- a/port.c +++ b/port.c @@ -1593,6 +1593,7 @@ int port_initialize(struct port *p) p->peerMeanPathDelay = 0; p->logAnnounceInterval = config_get_int(cfg, p->name, "logAnnounceInterval"); p->inhibit_announce = config_get_int(cfg, p->name, "inhibit_announce"); + p->ignore_source_id = config_get_int(cfg, p->name, "ignore_source_id"); p->announceReceiptTimeout = config_get_int(cfg, p->name, "announceReceiptTimeout"); p->syncReceiptTimeout = config_get_int(cfg, p->name, "syncReceiptTimeout"); p->transportSpecific = config_get_int(cfg, p->name, "transportSpecific"); @@ -1877,10 +1878,20 @@ void process_delay_resp(struct port *p, struct ptp_message *m) port_set_delay_tmo(p); } +static int check_source_identity(struct port *p, struct ptp_message *m) +{ + struct PortIdentity master; + + if (p->ignore_source_id) { + return 0; + } + master = clock_parent_identity(p->clock); + return pid_eq(&master, &m->header.sourcePortIdentity) ? 0 : -1; +} + void process_follow_up(struct port *p, struct ptp_message *m) { enum syfu_event event; - struct PortIdentity master; switch (p->state) { case PS_INITIALIZING: case PS_FAULTY: @@ -1895,8 +1906,8 @@ void process_follow_up(struct port *p, struct ptp_message *m) case PS_SLAVE: break; } - master = clock_parent_identity(p->clock); - if (!pid_eq(&master, &m->header.sourcePortIdentity)) { + + if (check_source_identity(p, m)) { return; } @@ -2185,7 +2196,6 @@ void process_pdelay_resp_fup(struct port *p, struct ptp_message *m) void process_sync(struct port *p, struct ptp_message *m) { enum syfu_event event; - struct PortIdentity master; switch (p->state) { case PS_INITIALIZING: case PS_FAULTY: @@ -2200,8 +2210,8 @@ void process_sync(struct port *p, struct ptp_message *m) case PS_SLAVE: break; } - master = clock_parent_identity(p->clock); - if (!pid_eq(&master, &m->header.sourcePortIdentity)) { + + if (check_source_identity(p, m)) { return; } diff --git a/port_private.h b/port_private.h index ca3c906..593eb76 100644 --- a/port_private.h +++ b/port_private.h @@ -99,6 +99,7 @@ struct port { enum fsm_event event, int mdiff); int bmca; int inhibit_announce; + int ignore_source_id; /* portDS */ struct PortIdentity portIdentity; enum port_state state; /*portState*/ diff --git a/ptp4l.8 b/ptp4l.8 index d4133a8..99b085c 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -709,6 +709,12 @@ by the Automotive profile as part of switching over to a static BMCA. if this option is enabled, ignore_source_id has to be enabled in the slave because it has no way to identify master identity in Sync and Follow_Up messages. The default is 0 (disabled). +.TP +.B ignore_source_id +This will disable source port identity checking for Sync and Follow_Up +messages. This is useful when the announce messages are disabled in the master +and the slave does not have any way to know it's identity. The default is 0 +(disabled). .SH UNICAST DISCOVERY OPTIONS