zebra: Fix rnh old -vs- new comparison

1) If we are moving the nexthop we are tracking to
a new rn in the rib, then we know that the route
to get to that nexthop has changed.  As such
we should notify the upper level.

This manifested itself because the code had a trigraph `?`
in the wrong order.  Put the comparison in the right order.

2) If we are re-matching to the same rn and we call compare_state
then we need to see if our stored nexthops are the same or different.

If they are the same we should not notify.  If they are different
we should notify.  compare_state was only comparing the flags
on a route and since those are not necessarily the right flags
to look at( and we are well after the fact that the route has
already changed and been processed ) let's just compare
the nexthops to see if they are the same or different.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2019-06-24 09:50:55 -04:00
parent 0c3bbed4e6
commit 60c67010f2

View File

@ -759,7 +759,7 @@ static void zebra_rnh_eval_nexthop_entry(struct zebra_vrf *zvrf, afi_t afi,
* change.
*/
zebra_rnh_remove_from_routing_table(rnh);
if (!prefix_same(&rnh->resolved_route, prn ? NULL : &prn->p)) {
if (!prefix_same(&rnh->resolved_route, prn ? &prn->p : NULL)) {
if (prn)
prefix_copy(&rnh->resolved_route, &prn->p);
else {
@ -965,7 +965,6 @@ static void copy_state(struct rnh *rnh, struct route_entry *re,
static int compare_state(struct route_entry *r1, struct route_entry *r2)
{
if (!r1 && !r2)
return 0;
@ -981,8 +980,7 @@ static int compare_state(struct route_entry *r1, struct route_entry *r2)
if (r1->nexthop_num != r2->nexthop_num)
return 1;
if (CHECK_FLAG(r1->status, ROUTE_ENTRY_NEXTHOPS_CHANGED)
|| CHECK_FLAG(r1->status, ROUTE_ENTRY_LABELS_CHANGED))
if (nexthop_group_hash(&r1->ng) != nexthop_group_hash(&r2->ng))
return 1;
return 0;