maybe it is a bug in nexthop__same function
Alexander Zubkov
green at qrator.net
Mon Mar 11 11:22:20 CET 2019
Hi,
For me, code looks valid. Loop ends when one of the pointers is null:
> x && y
So this comparison (x == y) verifies that both pointers are null, i.e.
both lists are of the same size.
On Mon, Mar 11, 2019 at 11:03 AM Derek Pan <DPan at advaoptical.com> wrote:
>
> Hi
>
>
>
> I think below function should be used by comparing two netxhop object with different pointer.
>
> If this function is called, the X and Y always have different pointer values, but if their values are same, they also can be treated as the same.
>
> I think the “return x== y;” should be replaced by “return 1;”.
>
> Please have a look. Thank.
>
>
>
> int
>
> nexthop__same(struct nexthop *x, struct nexthop *y)
>
> {
>
> for (; x && y; x = x->next, y = y->next)
>
> {
>
> if (!ipa_equal(x->gw, y->gw) || (x->iface != y->iface) ||
>
> (x->flags != y->flags) || (x->weight != y->weight) ||
>
> (x->labels_orig != y->labels_orig) || (x->labels != y->labels))
>
> return 0;
>
>
>
> for (int i = 0; i < x->labels; i++)
>
> if (x->label[i] != y->label[i])
>
> return 0;
>
> }
>
>
>
> return x == y;
>
> }
More information about the Bird-users
mailing list