diff options
| author | Christian Hopps <chopps@labn.net> | 2024-01-01 09:04:19 +0000 | 
|---|---|---|
| committer | Christian Hopps <chopps@labn.net> | 2024-01-02 09:47:15 +0000 | 
| commit | 7e6595698bd66c7a191996a7cb933ae63b5c5883 (patch) | |
| tree | 58f0d9a43e29c8f5dfae04b66327247203a77bfa /lib/northbound_oper.c | |
| parent | 353ee7bb819d5f06a180a1d062b47006456a98c7 (diff) | |
lib: fix specific entry queries
- fix key leaf queries
- fix specific list entry with non-key leaf top element
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'lib/northbound_oper.c')
| -rw-r--r-- | lib/northbound_oper.c | 16 | 
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/northbound_oper.c b/lib/northbound_oper.c index 4a7a0bb559..ab9abdeae2 100644 --- a/lib/northbound_oper.c +++ b/lib/northbound_oper.c @@ -499,7 +499,11 @@ static enum nb_error nb_op_ys_init_node_infos(struct nb_op_yield_state *ys)  			ret = NB_ERR_NOT_FOUND;  		return ret;  	} -	assert(CHECK_FLAG(node->schema->nodetype, LYS_CONTAINER | LYS_LIST)); +	while (node && +	       !CHECK_FLAG(node->schema->nodetype, LYS_CONTAINER | LYS_LIST)) +		node = &node->parent->node; +	if (!node) +		return NB_ERR_NOT_FOUND;  	inner = (struct lyd_node_inner *)node;  	for (len = 1; inner->parent; len++) @@ -1237,9 +1241,18 @@ static enum nb_error __walk(struct nb_op_yield_state *ys, bool is_resume)  			 * `route-entry` element for a query  			 * `.../route-entry/metric` where the list element had  			 * no metric value. +			 * +			 * However, if the user query is for a key of a list +			 * element, then when we reach that list element it will +			 * have no non-key children, check for this condition +			 * and do not reap if true.  			 */  			if (!list_start && ni->inner &&  			    !lyd_child_no_keys(&ni->inner->node) && +			    /* not the top element with a key match */ +			    !((darr_ilen(ys->node_infos) == +			       darr_ilen(ys->schema_path) - 1) && +			      lysc_is_key((*darr_last(ys->schema_path)))) &&  			    /* is this at or below the base? */  			    darr_ilen(ys->node_infos) <= ys->query_base_level)  				lyd_free_tree(&ni->inner->node); @@ -1674,7 +1687,6 @@ static enum nb_error nb_op_walk_start(struct nb_op_yield_state *ys)  	 * Get the node_info path (stack) corresponding to the uniquely  	 * resolvable data nodes from the beginning of the xpath query.  	 */ -	// I think this moves  	ret = nb_op_ys_init_node_infos(ys);  	if (ret != NB_OK)  		return ret;  | 
