bbfd: clear nb config entries when removing bfd node

When bfd node is removed, we must clear all NB entries set by its
children - sessions and profiles. Let's store some fake data as an entry
for the bfd node to be able to unset it later.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2021-04-01 15:42:53 +03:00
parent e93c3c003d
commit f13ad7c542

View File

@ -229,7 +229,15 @@ static int bfd_session_destroy(enum nb_event event,
*/
int bfdd_bfd_create(struct nb_cb_create_args *args)
{
/* NOTHING */
if (args->event != NB_EV_APPLY)
return NB_OK;
/*
* Set any non-NULL value to be able to call
* nb_running_unset_entry in bfdd_bfd_destroy.
*/
nb_running_set_entry(args->dnode, (void *)0x1);
return NB_OK;
}
@ -245,6 +253,12 @@ int bfdd_bfd_destroy(struct nb_cb_destroy_args *args)
return NB_OK;
case NB_EV_APPLY:
/*
* We need to call this to unset pointers from
* the child nodes - sessions and profiles.
*/
nb_running_unset_entry(args->dnode);
bfd_sessions_remove_manual();
bfd_profiles_remove();
break;