summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/link_state.c4
-rw-r--r--lib/northbound.c4
-rw-r--r--lib/vrf.c31
3 files changed, 22 insertions, 17 deletions
diff --git a/lib/link_state.c b/lib/link_state.c
index afeb89c592..e8a6b89f89 100644
--- a/lib/link_state.c
+++ b/lib/link_state.c
@@ -79,7 +79,6 @@ void ls_node_del(struct ls_node *node)
return;
XFREE(MTYPE_LS_DB, node);
- node = NULL;
}
int ls_node_same(struct ls_node *n1, struct ls_node *n2)
@@ -168,7 +167,6 @@ void ls_attributes_del(struct ls_attributes *attr)
ls_attributes_srlg_del(attr);
XFREE(MTYPE_LS_DB, attr);
- attr = NULL;
}
int ls_attributes_same(struct ls_attributes *l1, struct ls_attributes *l2)
@@ -221,7 +219,6 @@ void ls_prefix_del(struct ls_prefix *pref)
return;
XFREE(MTYPE_LS_DB, pref);
- pref = NULL;
}
int ls_prefix_same(struct ls_prefix *p1, struct ls_prefix *p2)
@@ -839,7 +836,6 @@ void ls_ted_del(struct ls_ted *ted)
subnets_fini(&ted->subnets);
XFREE(MTYPE_LS_DB, ted);
- ted = NULL;
}
void ls_ted_del_all(struct ls_ted *ted)
diff --git a/lib/northbound.c b/lib/northbound.c
index 47af770189..6edd5184ef 100644
--- a/lib/northbound.c
+++ b/lib/northbound.c
@@ -696,14 +696,14 @@ int nb_candidate_edit(struct nb_config *candidate,
NULL, LYD_NEW_PATH_UPDATE,
&dep_dnode);
/* Create default nodes */
- if (!err)
+ if (!err && dep_dnode)
err = lyd_new_implicit_tree(
dep_dnode,
LYD_IMPLICIT_NO_STATE, NULL);
if (err) {
flog_warn(
EC_LIB_LIBYANG,
- "%s: lyd_new_path(%s) failed: %d",
+ "%s: dependency: lyd_new_path(%s) failed: %d",
__func__, dep_xpath, err);
return NB_ERR;
}
diff --git a/lib/vrf.c b/lib/vrf.c
index de29f45f8f..a04f2ddeb7 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -582,29 +582,38 @@ void vrf_init(int (*create)(struct vrf *), int (*enable)(struct vrf *),
cmd_variable_handler_register(vrf_var_handlers);
}
+static void vrf_terminate_single(struct vrf *vrf)
+{
+ /* Clear configured flag and invoke delete. */
+ UNSET_FLAG(vrf->status, VRF_CONFIGURED);
+ vrf_delete(vrf);
+}
+
/* Terminate VRF module. */
void vrf_terminate(void)
{
- struct vrf *vrf;
+ struct vrf *vrf, *tmp;
if (debug_vrf)
zlog_debug("%s: Shutting down vrf subsystem", __func__);
- while (!RB_EMPTY(vrf_id_head, &vrfs_by_id)) {
- vrf = RB_ROOT(vrf_id_head, &vrfs_by_id);
+ RB_FOREACH_SAFE (vrf, vrf_id_head, &vrfs_by_id, tmp) {
+ if (vrf->vrf_id == VRF_DEFAULT)
+ continue;
- /* Clear configured flag and invoke delete. */
- UNSET_FLAG(vrf->status, VRF_CONFIGURED);
- vrf_delete(vrf);
+ vrf_terminate_single(vrf);
}
- while (!RB_EMPTY(vrf_name_head, &vrfs_by_name)) {
- vrf = RB_ROOT(vrf_name_head, &vrfs_by_name);
+ RB_FOREACH_SAFE (vrf, vrf_name_head, &vrfs_by_name, tmp) {
+ if (vrf->vrf_id == VRF_DEFAULT)
+ continue;
- /* Clear configured flag and invoke delete. */
- UNSET_FLAG(vrf->status, VRF_CONFIGURED);
- vrf_delete(vrf);
+ vrf_terminate_single(vrf);
}
+
+ /* Finally terminate default VRF */
+ vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ vrf_terminate_single(vrf);
}
int vrf_socket(int domain, int type, int protocol, vrf_id_t vrf_id,