summaryrefslogtreecommitdiff
path: root/lib/yang.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-04-18 11:55:52 -0300
committerRenato Westphal <renato@opensourcerouting.org>2019-04-18 11:56:45 -0300
commitccd43ada1791793602cbdff3973fae3ca692e6bf (patch)
tree16b3e19d28fb4d04178229cf861e1e7fccf618f9 /lib/yang.c
parent3c7940063b40250354cccc6b582a81d10a5a4261 (diff)
lib: rework management of user pointers in the northbound layer
Introduce a hash table to keep track of user pointers associated to configuration entries. The previous strategy was to embed the user pointers inside libyang data nodes, but this solution incurred a substantial performance overhead. The user pointers embedded in candidate configurations could be lost while the configuration was being edited, so they needed to be regenerated before the candidate could be committed. This was done by the nb_candidate_restore_priv_pointers() function, which was extremely expensive for large configurations. The new hash table solves this performance problem. The yang_dnode_[gs]et_entry() functions were renamed and moved from yang.[ch] to northbound.[ch], which is a more appropriate place for them. This patch also introduces the nb_running_unset_entry() function, the counterpart of nb_running_set_entry() (unsetting user pointers was done automatically before, now it needs to be done manually). As a consequence of these changes, we shouldn't need support for libyang private pointers anymore (-DENABLE_LYD_PRIV=ON). But it's probably a good idea to keep requiring this feature as we might need it in the future for other things (e.g. disable configuration settings without removing them). Fixes #4136. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/yang.c')
-rw-r--r--lib/yang.c43
1 files changed, 0 insertions, 43 deletions
diff --git a/lib/yang.c b/lib/yang.c
index 7982d14fdd..b7b001b7c3 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -513,42 +513,6 @@ void yang_dnode_change_leaf(struct lyd_node *dnode, const char *value)
lyd_change_leaf((struct lyd_node_leaf_list *)dnode, value);
}
-void yang_dnode_set_entry(const struct lyd_node *dnode, void *entry)
-{
- assert(CHECK_FLAG(dnode->schema->nodetype, LYS_LIST | LYS_CONTAINER));
- lyd_set_private(dnode, entry);
-}
-
-void *yang_dnode_get_entry(const struct lyd_node *dnode,
- bool abort_if_not_found)
-{
- const struct lyd_node *orig_dnode = dnode;
- char xpath[XPATH_MAXLEN];
-
- while (dnode) {
- switch (dnode->schema->nodetype) {
- case LYS_CONTAINER:
- case LYS_LIST:
- if (dnode->priv)
- return dnode->priv;
- break;
- default:
- break;
- }
-
- dnode = dnode->parent;
- }
-
- if (!abort_if_not_found)
- return NULL;
-
- yang_dnode_get_path(orig_dnode, xpath, sizeof(xpath));
- flog_err(EC_LIB_YANG_DNODE_NOT_FOUND,
- "%s: failed to find entry [xpath %s]", __func__, xpath);
- zlog_backtrace(LOG_ERR);
- abort();
-}
-
struct lyd_node *yang_dnode_new(struct ly_ctx *ly_ctx, bool config_only)
{
struct lyd_node *dnode;
@@ -629,12 +593,6 @@ struct yang_data *yang_data_list_find(const struct list *list,
return NULL;
}
-static void *ly_dup_cb(const void *priv)
-{
- /* Make a shallow copy of the priv pointer. */
- return (void *)priv;
-}
-
/* Make libyang log its errors using FRR logging infrastructure. */
static void ly_log_cb(LY_LOG_LEVEL level, const char *msg, const char *path)
{
@@ -724,7 +682,6 @@ CPP_NOTICE("lib/yang: deprecated libyang <0.16.74 extension loading in use!")
flog_err(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__);
exit(1);
}
- ly_ctx_set_priv_dup_clb(ly_native_ctx, ly_dup_cb);
#ifndef LIBYANG_EXT_BUILTIN
/* Detect if the required libyang plugin(s) were loaded successfully. */