The UDS interface is currently associated with a clock ID of zeros and a 16-bit port number which is the process id. However, the process id on Linux can easily by bigger than 16 bits (supposed to be limited to 22 bits). This means that several linuxptp processes (pmc and phc2sys for instance) can collide and use the same port id.
Hence, use the lower 2 bytes of the process id for the port number, and the top 2 bytes as bytes 7 and 8 of the Clock ID. Signed-off-by: Eyal Itkin <eit...@nvidia.com> --- pmc_common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pmc_common.c b/pmc_common.c index 9e251c4..694edf6 100644 --- a/pmc_common.c +++ b/pmc_common.c @@ -486,13 +486,17 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type, int zero_datalen) { struct pmc *pmc; + UInteger32 proc_id; pmc = calloc(1, sizeof *pmc); if (!pmc) return NULL; if (transport_type == TRANS_UDS) { - pmc->port_identity.portNumber = getpid(); + proc_id = getpid(); + pmc->port_identity.clockIdentity.id[6] = (proc_id & 0xFF000000) >> 24; + pmc->port_identity.clockIdentity.id[7] = (proc_id & 0x00FF0000) >> 16; + pmc->port_identity.portNumber = proc_id & 0xFFFF; } else { if (generate_clock_identity(&pmc->port_identity.clockIdentity, iface_name)) { -- 2.21.0 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel