Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix order of NB callbacks (and a crash) #15401

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/affinitymap_northbound.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ const struct frr_yang_module_info frr_affinity_map_info = {
.cbs = {
.create = lib_affinity_map_create,
.destroy = lib_affinity_map_destroy,
}
},
.priority = NB_DFLT_PRIORITY - 1,
},
{
.xpath = "/frr-affinity-map:lib/affinity-maps/affinity-map/value",
Expand Down
9 changes: 6 additions & 3 deletions lib/northbound.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,14 @@ void nb_config_replace(struct nb_config *config_dst,
static inline int nb_config_cb_compare(const struct nb_config_cb *a,
const struct nb_config_cb *b)
{
/* Sort by priority first. */
/*
* Sort by priority first. If the operation is "destroy", reverse the
* order, so that the dependencies are destroyed before the dependants.
*/
if (a->nb_node->priority < b->nb_node->priority)
return -1;
return a->operation != NB_CB_DESTROY ? -1 : 1;
if (a->nb_node->priority > b->nb_node->priority)
return 1;
return a->operation != NB_CB_DESTROY ? 1 : -1;

/*
* Preserve the order of the configuration changes as told by libyang.
Expand Down
Loading