Different devices may have the same physical addresses of L2 interfaces, thus
clock IDs will be identical. The solution is to use address of VLAN interface
for clock ID generation as it is more flexible in configuration.

Signed-off-by: Andriy Kohut <andr...@mellanox.com>
---
 clock.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/clock.c b/clock.c
index 745ba9a..f0beb29 100644
--- a/clock.c
+++ b/clock.c
@@ -860,6 +860,8 @@ struct clock *clock_create(enum clock_type type, struct 
config *config,
        struct interface *iface, *udsif = &c->uds_interface;
        struct timespec ts;
        int sfl;
+       const char * vlan_intf = "";
+       const char * clkid_src = NULL;
 
        clock_gettime(CLOCK_REALTIME, &ts);
        srandom(ts.tv_sec ^ ts.tv_nsec);
@@ -962,6 +964,10 @@ struct clock *clock_create(enum clock_type type, struct 
config *config,
                               "requested timestamping mode", iface->netdev);
                        return NULL;
                }
+
+               if (strlen(vlan_intf) == 0) {
+                       vlan_intf = config_get_string(config, iface->name, 
"vlan_intf");
+               }
        }
 
        iface = STAILQ_FIRST(&config->interfaces);
@@ -987,7 +993,13 @@ struct clock *clock_create(enum clock_type type, struct 
config *config,
                pr_info("selected /dev/ptp%d as PTP clock", phc_index);
        }
 
-       if (generate_clock_identity(&c->dds.clockIdentity, iface->netdev)) {
+       if (strlen(vlan_intf) > 0) {
+               clkid_src = vlan_intf;
+       } else {
+               clkid_src = iface->netdev;
+       }
+
+       if (generate_clock_identity(&c->dds.clockIdentity, clkid_src)) {
                pr_err("failed to generate a clock identity");
                return NULL;
        }
-- 
2.8.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to