Skip to content

Commit e5f4675

Browse files
committed
zebra: Prevent active setting if interface is not operative
Currently Installing nhg's has two paths for installation: a) A route comes in with a new nhg that will be selected. Zebra will check that the nexthops are good and signal that the route is ready for installation. This in turn causes the nexthop to be installed first before the route installation. This nexthop group installation then looks at each singleton and attempts to install those as well. This is a way to get routes installed quickly into the system if needed. b) A interface has an event that causes a nexthop group to change. This will cause singletons to be handled appropriately and then once those are handled and installed the handler for the nexthop install success will walk the nexthop groups that use that nexthop and reinstalls them as well. Unfortunately both A and B are currently funneled through the same function. Now for the problem that is being seen: If you have a NHG A that uses NHG B/C/D nexthops. Imagine that the B and C interfaces are down. The NHG A will have B( inactive/!installed), C(inactive/!installed), D(active/installed) Now if interface B comes up, this will cause nexthop B to be reinstalled. After B comes back up we will call a nexthop group reinstallation for A. Since it is using the same functionality to reinstall, it looks at all it's singletons and sees that C is not installed and it was marking C as active, even though the interface is down) and attempting to reinstall it. Unfortunately if interface C happens to be up in the kernel, but not yet in zebra, you end up with nh C being installed and we mark the nh C as valid and installed. Then when interface C actually comes up, it sees that the nhg C is up and does nothing. Leaving the nhg's in a broken state. Modify the active setting to not set a singleton NH as active if the interface is not operational. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
1 parent 46044a4 commit e5f4675

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

zebra/zebra_nhg.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,8 +2814,14 @@ static bool zebra_nhg_set_valid_if_active(struct nhg_hash_entry *nhe)
28142814
}
28152815

28162816
/* should be fully resolved singleton at this point */
2817-
if (CHECK_FLAG(nhe->nhg.nexthop->flags, NEXTHOP_FLAG_ACTIVE))
2818-
valid = true;
2817+
if (CHECK_FLAG(nhe->nhg.nexthop->flags, NEXTHOP_FLAG_ACTIVE)) {
2818+
struct interface *ifp = if_lookup_by_index(nhe->nhg.nexthop->ifindex, nhe->vrf_id);
2819+
2820+
if (!ifp || !if_is_operative(ifp))
2821+
valid = false;
2822+
else
2823+
valid = true;
2824+
}
28192825

28202826
done:
28212827
if (valid)

0 commit comments

Comments
 (0)