Skip to content

Commit

Permalink
zebra: When reinstalling a NHG, set REINSTALL flag
Browse files Browse the repository at this point in the history
The current code is unsetting the fact that the
NHG is installed.  It is installed but we are
reinstalling it.  Let's note this in the code
appropriately as REINSTALL and not remove the
INSTALLED FLAG.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Feb 8, 2024
1 parent e28162b commit b2ade8e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
19 changes: 10 additions & 9 deletions zebra/zebra_nhg.c
Original file line number Diff line number Diff line change
Expand Up @@ -3090,9 +3090,10 @@ void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe)
zebra_nhg_install_kernel(rb_node_dep->nhe);
}

if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_VALID)
&& !CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED)
&& !CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_QUEUED)) {
if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_VALID) &&
(!CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED) ||
CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_REINSTALL)) &&
!CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_QUEUED)) {
/* Change its type to us since we are installing it */
if (!ZEBRA_NHG_CREATED(nhe))
nhe->type = ZEBRA_ROUTE_NHG;
Expand Down Expand Up @@ -3179,6 +3180,7 @@ void zebra_nhg_dplane_result(struct zebra_dplane_ctx *ctx)
}

UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_QUEUED);
UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_REINSTALL);
switch (status) {
case ZEBRA_DPLANE_REQUEST_SUCCESS:
SET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
Expand Down Expand Up @@ -3686,12 +3688,11 @@ void zebra_interface_nhg_reinstall(struct interface *ifp)
&rb_node_dep->nhe->nhg_dependents,
rb_node_dependent) {
if (IS_ZEBRA_DEBUG_NHG)
zlog_debug(
"%s dependent nhe %pNG unset installed flag",
__func__,
rb_node_dependent->nhe);
UNSET_FLAG(rb_node_dependent->nhe->flags,
NEXTHOP_GROUP_INSTALLED);
zlog_debug("%s dependent nhe %pNG Setting Reinstall flag",
__func__,
rb_node_dependent->nhe);
SET_FLAG(rb_node_dependent->nhe->flags,
NEXTHOP_GROUP_REINSTALL);
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions zebra/zebra_nhg.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ struct nhg_hash_entry {
* Track FPM installation status..
*/
#define NEXTHOP_GROUP_FPM (1 << 7)

/*
* When an interface comes up install the
* singleton's and schedule the NHG's that
* are using this nhg to be reinstalled
* when installation is successful.
*/
#define NEXTHOP_GROUP_REINSTALL (1 << 8)
};

/* Upper 4 bits of the NHG are reserved for indicating the NHG type */
Expand Down
7 changes: 6 additions & 1 deletion zebra/zebra_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,12 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe,
json_object_boolean_true_add(json, "valid");
else
vty_out(vty, " Valid");

if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_REINSTALL)) {
if (json)
json_object_boolean_true_add(json, "reInstall");
else
vty_out(vty, ", Reinstall");
}
if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED)) {
if (json)
json_object_boolean_true_add(json, "installed");
Expand Down

0 comments on commit b2ade8e

Please sign in to comment.