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 <vedang.pa...@intel.com>
---
 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 cac0a74683c6..639ddc1290de 100644
--- a/config.c
+++ b/config.c
@@ -231,6 +231,7 @@ struct config_item config_tab[] = {
        PORT_ITEM_INT("G.8275.portDS.localPriority", 128, 1, UINT8_MAX),
        GLOB_ITEM_INT("gmCapable", 1, 0, 1),
        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 c51da0345343..77b6e546de38 100644
--- a/configs/default.cfg
+++ b/configs/default.cfg
@@ -34,6 +34,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 ea40b5c6a91a..f6266062619a 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");
@@ -1880,10 +1881,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:
@@ -1898,8 +1909,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;
        }
 
@@ -2188,7 +2199,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:
@@ -2203,8 +2213,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 ca3c906a0006..593eb76fbe48 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 ee1d00b8bdd2..804e12cb7b61 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -684,6 +684,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_port_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
 
-- 
2.7.3



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to