B#11542: GPN walk at each level fails with micro-services

This commit is contained in:
Amin Ben Romdhane 2023-07-21 11:20:19 +02:00
parent 7f68018d53
commit e7b48af2cb
3 changed files with 27 additions and 0 deletions

View file

@ -1279,6 +1279,7 @@ static int set_ubus_value(struct dmctx *dmctx, struct dmnode *node)
static int get_ubus_name(struct dmctx *dmctx, struct dmnode *node)
{
unsigned int in_path_dot_num = count_occurrences(dmctx->in_param, '.');
json_object *res = NULL, *res_obj = NULL;
char *ubus_name = node->obj->checkdep;
@ -1324,6 +1325,15 @@ static int get_ubus_name(struct dmctx *dmctx, struct dmnode *node)
char *data = dmjson_get_value(res_obj, 1, "data");
char *type = dmjson_get_value(res_obj, 1, "type");
if (dmctx->nextlevel) {
unsigned int path_dot_num = count_occurrences(path, '.');
size_t len = DM_STRLEN(path);
if ((path[len - 1] == '.' && path_dot_num > in_path_dot_num + 1) ||
(path[len - 1] != '.' && path_dot_num > in_path_dot_num))
continue;
}
add_list_parameter(dmctx, dmstrdup(path), dmstrdup(data), dmstrdup(type), NULL);
}

View file

@ -653,6 +653,22 @@ struct uci_section *is_dmmap_section_exist_eq(char* package, char* section, char
return NULL;
}
unsigned int count_occurrences(char *str, char c)
{
int count = 0;
if (!str)
return 0;
char *pch = strchr(str, c);
while (pch) {
count++;
pch = strchr(pch + 1, c);
}
return count;
}
unsigned char isdigit_str(char *str)
{
if (!(*str)) return 0;

View file

@ -227,6 +227,7 @@ int adm_entry_get_linker_param(struct dmctx *ctx, char *param, char *linker, cha
int adm_entry_get_linker_value(struct dmctx *ctx, char *param, char **value);
int dm_entry_validate_allowed_objects(struct dmctx *ctx, char *value, char *objects[]);
char *check_create_dmmap_package(const char *dmmap_package);
unsigned int count_occurrences(char *str, char c);
unsigned char isdigit_str(char *str);
bool special_char(char c);
bool special_char_exits(const char *str);