From 7ec89f485be6641b2d53d181b5e8685f5e66d916 Mon Sep 17 00:00:00 2001 From: Omar Kallel Date: Tue, 25 Aug 2020 15:27:58 +0100 Subject: [PATCH] Fix InterfaceStack issues: Ethernet.Link, Bridge.x.Port. --- dmtree/tr181/interfacestack.c | 25 +++++++++++++++++++++---- libbbf_api/dmcommon.h | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/dmtree/tr181/interfacestack.c b/dmtree/tr181/interfacestack.c index 4405265f..b99305a3 100644 --- a/dmtree/tr181/interfacestack.c +++ b/dmtree/tr181/interfacestack.c @@ -61,6 +61,16 @@ static char *get_alias_by_section(char *dmmap_config, char *section, struct uci_ return alias; } +static char *get_alias_by_section_option_condition(char *dmmap_config, char *section, char *option, char *value, char *alias_option) +{ + struct uci_section *dmmap_section; + char *alias = ""; + + get_dmmap_section_of_config_section_cont(dmmap_config, section, option, value, &dmmap_section); + dmuci_get_value_by_section_string(dmmap_section, alias_option, &alias); + + return alias; +} static struct uci_section *create_dmmap_interface_stack_section(char *curr_inst) { struct uci_section *s = NULL; @@ -143,13 +153,12 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre char *vid = strchr(linker, '.'); if (vid) *vid = '\0'; adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &value); - loweralias = get_alias_by_section("dmmap", "link", s, "link_alias"); + loweralias = get_alias_by_section_option_condition("dmmap", "link", "section_name", section_name(s), "link_alias"); layer_inst = get_instance_by_section_option_condition(dmctx->instance_mode, "dmmap", "link", s, "section_name", section_name(s), "link_instance", "link_alias"); if (value == NULL) value = ""; } - - snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value); + snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value?value:""); if (*loweralias == '\0') if (*layer_inst == '\0') snprintf(buf_loweralias, sizeof(buf_loweralias), "%s", ""); @@ -375,7 +384,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre break; } if (eth_port_sect != NULL) { - get_dmmap_section_of_config_section_eq("dmmap_ports", eth_port_sect, "section_name", section_name(eth_port_sect), ð_port_dmms); + get_dmmap_section_of_config_section_eq("dmmap_ports", "ethport", "section_name", section_name(eth_port_sect), ð_port_dmms); if (eth_port_dmms) { dmuci_get_value_by_section_string(eth_port_dmms, "eth_port_alias", &loweralias); dmuci_get_value_by_section_string(eth_port_dmms, "eth_port_instance", &layer_inst); @@ -497,6 +506,14 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&intf_stack_data, inst) == DM_STOP) goto end; + if (*loweralias == '\0') + if (*bridge_port_inst == '\0') + snprintf(buf_higheralias, sizeof(buf_higheralias), "%s", ""); + else + snprintf(buf_higheralias, sizeof(buf_higheralias), "cpe-%s", bridge_port_inst); + else + snprintf(buf_higheralias, sizeof(buf_higheralias), "%s", loweralias); + char package[32] = {0}; int found = 0; // The lower layer is Device.Ethernet.Interface.{i}. diff --git a/libbbf_api/dmcommon.h b/libbbf_api/dmcommon.h index a8c57777..22716b55 100644 --- a/libbbf_api/dmcommon.h +++ b/libbbf_api/dmcommon.h @@ -278,6 +278,7 @@ void add_sysfs_sectons_list_paramameter(struct list_head *dup_list, struct uci_s int synchronize_system_folders_with_dmmap_opt(char *sysfsrep, char *dmmap_package, char *dmmap_section, char *opt_name, char* inst_opt, struct list_head *dup_list); void get_dmmap_section_of_config_section(char* dmmap_package, char* section_type, char *section_name, struct uci_section **dmmap_section); void get_dmmap_section_of_config_section_eq(char* dmmap_package, char* section_type, char *opt, char* value, struct uci_section **dmmap_section); +void get_dmmap_section_of_config_section_cont(char* dmmap_package, char* section_type, char *opt, char* value, struct uci_section **dmmap_section); void get_config_section_of_dmmap_section(char* package, char* section_type, char *section_name, struct uci_section **config_section); void check_create_dmmap_package(char *dmmap_package); int is_section_unnamed(char *section_name);