On Wed, 2016-08-03 at 14:49 +0200, Richard Cochran wrote:
> Contrary to the letter of the standard, we do not throw a state
> decision
> event every announce interval, but only when the inputs to the
> algorithm
> have changed.  When a port on a BC forms a spanning tree by deciding
> between the MASTER and PASSIVE states, the identity of the port which
> sent
> the announce message acts as a tie breaker.
> 
> However, the current code ignores that field when deciding whether
> the
> inputs have changed or not.  This patch fixes the comparison to
> include
> the source port id.
> 

Makes sense to me, and code does what it says.

Acked-by: Jacob Keller <jacob.e.kel...@intel.com>

> Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
> ---
>  port.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/port.c b/port.c
> index 5868983..b9f6497 100644
> --- a/port.c
> +++ b/port.c
> @@ -135,14 +135,20 @@ static void port_nrate_initialize(struct port
> *p);
>  static int announce_compare(struct ptp_message *m1, struct
> ptp_message *m2)
>  {
>       struct announce_msg *a = &m1->announce, *b = &m2->announce;
> -     int len =
> +     int diff, len =
>               sizeof(a->grandmasterPriority1) +
>               sizeof(a->grandmasterClockQuality) +
>               sizeof(a->grandmasterPriority2) +
>               sizeof(a->grandmasterIdentity) +
>               sizeof(a->stepsRemoved);
>  
> -     return memcmp(&a->grandmasterPriority1, &b-
> >grandmasterPriority1, len);
> +     diff = memcmp(&a->grandmasterPriority1, &b-
> >grandmasterPriority1, len);
> +     if (diff) {
> +             return diff;
> +     }
> +     return memcmp(&m1->header.sourcePortIdentity,
> +                   &m2->header.sourcePortIdentity,
> +                   sizeof(m1->header.sourcePortIdentity));
>  }
>  
>  static void announce_to_dataset(struct ptp_message *m, struct port
> *p,
------------------------------------------------------------------------------
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to