Zebra: Ensure we compare prefix and NHs when checking if NH changed

In nexthop tracking, the code currently compares the nexthop state of the
resolved_route for a prefix with the previous nexthop state. However, if
the resolved route itself changes, we can end up comparing the RIBs of
unrelated prefixes and assuming that nothing has changed. To fix this, we
need to store and compare the new resolved route with the previously
resolved route. If this has changed, assume the NH associated with a route
has changed.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Reviewed-by:   Vivek Venkataraman <vivek@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2015-05-19 18:04:16 -07:00
parent ca657c652d
commit c5f7794faa
3 changed files with 23 additions and 1 deletions

View file

@ -278,6 +278,12 @@ prefix_copy (struct prefix *dest, const struct prefix *src)
int
prefix_same (const struct prefix *p1, const struct prefix *p2)
{
if ((p1 && !p2) || (!p1 && p2))
return 0;
if (!p1 && !p2)
return 1;
if (p1->family == p2->family && p1->prefixlen == p2->prefixlen)
{
if (p1->family == AF_INET)

View file

@ -266,6 +266,7 @@ zebra_evaluate_rnh_table (int vrfid, int family, int force)
char bufs[INET6_ADDRSTRLEN];
struct route_node *static_rn;
struct nexthop *nexthop;
ntable = lookup_rnh_table(vrfid, family);
if (!ntable)
{
@ -312,7 +313,21 @@ zebra_evaluate_rnh_table (int vrfid, int family, int force)
state_changed = 0;
if (compare_state(rib, rnh->state))
/* Ensure prefixes we're resolving over have stayed the same */
if (!prefix_same(&rnh->resolved_route, &prn->p))
{
if (rib)
UNSET_FLAG(rib->status, RIB_ENTRY_NEXTHOPS_CHANGED);
if (prn)
prefix_copy(&rnh->resolved_route, &prn->p);
else
memset(&rnh->resolved_route, 0, sizeof(struct prefix));
copy_state(rnh, rib, nrn);
state_changed = 1;
}
else if (compare_state(rib, rnh->state))
{
if (rib)
UNSET_FLAG(rib->status, RIB_ENTRY_NEXTHOPS_CHANGED);

View file

@ -33,6 +33,7 @@ struct rnh
#define ZEBRA_NHT_CONNECTED 0x1
#define ZEBRA_NHT_DELETED 0x2
struct rib *state;
struct prefix resolved_route;
struct list *client_list;
struct list *zebra_static_route_list; /* static routes dependent on this NH */
struct route_node *node;