On Fri, Nov 18, 2022 at 08:43:19AM +0100, Luigi Mantellini wrote:
> From: Luigi Mantellini <luigi.mantell...@gmail.com>
> 
> The PortId is defined as a couple of ClockId (an 8-bytes opaque) and the 
> PortNumber (UInterger16).
> 
> The current implementation compares the entire PortId, consisting of ClockId 
> and PortNumber, using a byte-to-byte comparison (memcmp).
> This way doesn't consider the HOST's endianess on PortId part, giving wrong 
> results in same case.
> 
> Consider the following setup (assuming the same ClockId)
> 
> PortId_a = (ClockId, PortNumber=0x1234)
> PortId_b = (ClockId, PortNumber=0x4512)
> 
> On a LittleEndian HOST, we obtain the following memory setup:
> 
> PortId_a = ... ClockId ... 0x34 0x12
> PortId_b = ... ClockId ... 0x12 0x45
> 
> Using just a memcmp() call we obtain the WRONG result PortId_a > PortId_b, 
> because the byte-to-byte comparison will check the PortNumber Lower-Byte 
> (0x34 vs 0x12) first.
> 
> To fix the BCMA implementation we need to split the PortId comparison in:
> 
>  - ClockId comparison, still using memcmp() on a opaque byte stream
>  - PortNumber, using a natural semantic comparison between integer numbers.

Applied.

Thanks,
Richard


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

Reply via email to