mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Ticket refs#2494: bbf: multiple bridging object handling
This commit is contained in:
parent
87dd13f4d5
commit
09048693c7
6 changed files with 1362 additions and 2117 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -223,15 +223,9 @@ static int browseEthernetVLANTerminationInst(struct dmctx *dmctx, DMNODE *parent
|
|||
**************************************************************/
|
||||
static int get_linker_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
|
||||
{
|
||||
if (data && ((struct eth_port_args *)data)->ifname) {
|
||||
char *wan_ifname = NULL;
|
||||
dmuci_get_option_value_string("ports", "WAN", "ifname", &wan_ifname);
|
||||
if (strcmp(((struct eth_port_args *)data)->ifname, wan_ifname) == 0) {
|
||||
if(strchr(((struct eth_port_args *)data)->ifname, '.') == NULL)
|
||||
dmasprintf(linker, "%s.1", wan_ifname);
|
||||
} else
|
||||
*linker = ((struct eth_port_args *)data)->ifname;
|
||||
} else
|
||||
if (data && ((struct eth_port_args *)data)->ifname)
|
||||
*linker = ((struct eth_port_args *)data)->ifname;
|
||||
else
|
||||
*linker = "";
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -872,7 +866,7 @@ static int get_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "bridge_key", br_inst, port) {
|
||||
dmuci_get_value_by_section_string(port, "mg_port", &mg);
|
||||
if (strcmp(mg, "true") == 0)
|
||||
snprintf(linker, sizeof(linker), "%s+", section_name(port));
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+", br_inst, section_name(port));
|
||||
adm_entry_get_linker_param(ctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
|
||||
if (*value == NULL)
|
||||
*value = "";
|
||||
|
|
@ -886,7 +880,6 @@ static int get_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
get_upstream_interface(intf_tag, sizeof(intf_tag));
|
||||
|
||||
if (intf_tag[0] != '\0') {
|
||||
strcat(intf_tag, ".1");
|
||||
adm_entry_get_linker_param(ctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), intf_tag, value);
|
||||
if (*value == NULL)
|
||||
*value = "";
|
||||
|
|
|
|||
|
|
@ -64,11 +64,10 @@ static struct uci_section *create_dmmap_interface_stack_section(char *curr_inst)
|
|||
int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct interfacestack_data ifdata = {0};
|
||||
struct uci_section *s = NULL, *sd = NULL, *port, *port_s, *ss, *dmmap_s = NULL;
|
||||
struct uci_section *s = NULL, *port = NULL, *port_s = NULL, *ss = NULL, *dmmap_s = NULL;
|
||||
char *proto, *type, *pch, *layer_inst, *vb, *higheralias, *ifname, *br_inst, *mg, *value, *device, *name, *bridge_port_inst;
|
||||
char *v = "";
|
||||
char *loweralias = "";
|
||||
char *interface_stack_int = NULL, *interface_stack_int_last = NULL, *wanifname, *wanlinker, *mac, *sectionname, *package, *section;
|
||||
char *loweralias = "", *v = "";
|
||||
char *interface_stack_int = NULL, *interface_stack_int_last = NULL, *wanifname, *mac;
|
||||
char buf_lowerlayer[128] = {0};
|
||||
char buf_higherlayer[128] = {0};
|
||||
char buf_higheralias[64] = {0};
|
||||
|
|
@ -258,7 +257,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "bridge_key", br_inst, port) {
|
||||
dmuci_get_value_by_section_string(port, "mg_port", &mg);
|
||||
if (strcmp(mg, "true") == 0) {
|
||||
snprintf(linker, sizeof(linker), "%s+", section_name(port));
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+", br_inst, section_name(port));
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &v);
|
||||
dmuci_get_value_by_section_string(port, "bridge_port_alias", &loweralias);
|
||||
dmuci_get_value_by_section_string(port, "bridge_port_instance", &layer_inst);
|
||||
|
|
@ -269,9 +268,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
uci_foreach_option_eq("ports", "ethport", "name", "WAN", port_s) {
|
||||
dmuci_get_value_by_section_string(port_s, "ifname", &wanifname);
|
||||
if(strstr(ifname, wanifname)) {
|
||||
dmasprintf(&wanlinker, "%s.1", wanifname);
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), wanlinker, &v);
|
||||
dmfree(wanlinker);
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), wanifname, &v);
|
||||
loweralias = get_alias_by_section("dmmap_ports", "ethport", port_s, "eth_port_alias");
|
||||
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_ports", "ethport", port_s, "eth_port_instance", "eth_port_alias");
|
||||
break;
|
||||
|
|
@ -306,7 +303,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "bridge_key", br_inst, port) {
|
||||
dmuci_get_value_by_section_string(port, "mg_port", &mg);
|
||||
if (strcmp(mg, "true") == 0) {
|
||||
snprintf(linker, sizeof(linker), "%s+", section_name(port));
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+", br_inst, section_name(port));
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &pch);
|
||||
dmuci_get_value_by_section_string(port, "bridge_port_alias", &higheralias);
|
||||
dmuci_get_value_by_section_string(port, "bridge_port_instance", &bridge_port_inst);
|
||||
|
|
@ -320,11 +317,13 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
}
|
||||
}
|
||||
|
||||
struct uci_section *sd = NULL;
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "bridge_key", br_inst, sd) {
|
||||
dmuci_get_value_by_section_string(sd, "mg_port", &mg);
|
||||
if (strcmp(mg, "true") == 0)
|
||||
continue;
|
||||
|
||||
char *sectionname, *package, *section;
|
||||
dmuci_get_value_by_section_string(sd, "section_name", §ionname);
|
||||
dmuci_get_value_by_section_string(sd, "package", &package);
|
||||
dmuci_get_value_by_section_string(sd, "section", §ion);
|
||||
|
|
@ -336,10 +335,11 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(strcmp(package, "network") == 0 && strcmp(section, "device") == 0)
|
||||
snprintf(linker, sizeof(linker), "%s+%s", sectionname, name);
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, sectionname, name);
|
||||
else
|
||||
snprintf(linker, sizeof(linker), "%s+%s", sectionname, ifname);
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, sectionname, ifname);
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &vb);
|
||||
if (vb == NULL)
|
||||
vb = "";
|
||||
|
|
@ -392,7 +392,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
}
|
||||
}
|
||||
} else {
|
||||
snprintf(linker, sizeof(linker), "%s.1", ifname);
|
||||
snprintf(linker, sizeof(linker), "%s", ifname);
|
||||
adm_entry_get_linker_param(dmctx,dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &v);
|
||||
loweralias = get_alias_by_section("dmmap_ports", "ethport", port_s, "eth_port_alias");
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_ports", "ethport", port_s, "eth_port_instance", "eth_port_alias");
|
||||
|
|
|
|||
|
|
@ -656,7 +656,7 @@ def cprintGetSetValue(getvalue, setvalue, mappingparam, instance, typeparam, par
|
|||
print >> fp, "}"
|
||||
print >> fp, ""
|
||||
if setvalue != "NULL":
|
||||
print >> fp, "int %s(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)" % setvalue
|
||||
print >> fp, "static int %s(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)" % setvalue
|
||||
print >> fp, "{"
|
||||
print >> fp, " switch (action) {"
|
||||
print >> fp, " case VALUECHECK:"
|
||||
|
|
|
|||
|
|
@ -540,14 +540,13 @@ void update_section_list_bbfdm(char *config, char *section, char *option, int nu
|
|||
}
|
||||
}
|
||||
|
||||
void update_section_list(char *config, char *section, char *option, int number, char *filter, char *option1, char *val1, char *option2, char *val2)
|
||||
void update_section_list(char *config, char *section, char *option, int number, char *filter, char *option1, char *val1, char *option2, char *val2)
|
||||
{
|
||||
char *add_value;
|
||||
struct uci_section *s = NULL;
|
||||
int i = 0;
|
||||
|
||||
if (strcmp(config, DMMAP) == 0)
|
||||
{
|
||||
if (strncmp(config, DMMAP, 5) == 0) {
|
||||
if (option) {
|
||||
uci_path_foreach_option_eq(bbfdm, config, section, option, filter, s) {
|
||||
return;
|
||||
|
|
@ -564,9 +563,7 @@ void update_section_list(char *config, char *section, char *option, int number,
|
|||
if (option2)DMUCI_SET_VALUE_BY_SECTION(bbfdm, s, option2, val2);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (option) {
|
||||
uci_foreach_option_eq(config, section, option, filter, s) {
|
||||
return;
|
||||
|
|
@ -781,68 +778,6 @@ struct uci_section *get_dup_section_in_dmmap_eq(char *dmmap_package, char* secti
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void synchronize_specific_config_sections_with_dmmap_vlan(char *package, char *section_type, char *dmmap_package, char *ifname, struct list_head *dup_list, int *count, char *id)
|
||||
{
|
||||
struct uci_section *s, *stmp, *dmmap_sect;
|
||||
char *v;
|
||||
|
||||
dmmap_file_path_get(dmmap_package);
|
||||
|
||||
uci_foreach_sections(package, section_type, s) {
|
||||
/*
|
||||
* create/update corresponding dmmap section that have same config_section link and using param_value_array
|
||||
*/
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap(dmmap_package, section_type, section_name(s))) == NULL) {
|
||||
dmuci_add_section_bbfdm(dmmap_package, section_type, &dmmap_sect, &v);
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_sect, "section_name", section_name(s));
|
||||
}
|
||||
|
||||
/* Entry for only VLANS. */
|
||||
if (strcmp(package, "network") == 0 && strcmp(section_type, "interface") == 0 && strcmp(dmmap_package, "dmmap_network") == 0) {
|
||||
char *type, *intf;
|
||||
dmuci_get_value_by_section_string(s, "type", &type);
|
||||
dmuci_get_value_by_section_string(s, "ifname", &intf);
|
||||
if (strcmp(type, "bridge") != 0 || strcmp(intf, ifname) != 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Vlan object should not be created for transparent bridges. */
|
||||
int tag = 0;
|
||||
char name[250] = {0};
|
||||
strncpy(name, ifname, sizeof(name) - 1);
|
||||
char *p = strtok(name, " ");
|
||||
while (p != NULL) {
|
||||
char intf[250] = {0};
|
||||
strncpy(intf, p, sizeof(intf) - 1);
|
||||
char *find = strstr(intf, ".");
|
||||
if (find) {
|
||||
tag = 1;
|
||||
*id = find[strlen(find) - 1];
|
||||
break;
|
||||
}
|
||||
p = strtok(NULL, " ");
|
||||
}
|
||||
|
||||
if (tag == 0)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Add system and dmmap sections to the list
|
||||
*/
|
||||
add_sectons_list_paramameter(dup_list, s, dmmap_sect, NULL);
|
||||
*count = *count + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete unused dmmap sections
|
||||
*/
|
||||
uci_path_foreach_sections_safe(bbfdm, dmmap_package, section_type, stmp, s) {
|
||||
dmuci_get_value_by_section_string(s, "section_name", &v);
|
||||
if (get_origin_section_from_config(package, section_type, v) == NULL)
|
||||
dmuci_delete_by_section_unnamed_bbfdm(s, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void synchronize_specific_config_sections_with_dmmap(char *package, char *section_type, char *dmmap_package, struct list_head *dup_list)
|
||||
{
|
||||
struct uci_section *s, *stmp, *dmmap_sect;
|
||||
|
|
|
|||
|
|
@ -271,7 +271,6 @@ void hex_to_ip(char *address, char *ret);
|
|||
void ip_to_hex(char *address, char *ret);
|
||||
void free_dmmap_config_dup_list(struct list_head *dup_list);
|
||||
void synchronize_specific_config_sections_with_dmmap(char *package, char *section_type, char *dmmap_package, struct list_head *dup_list);
|
||||
void synchronize_specific_config_sections_with_dmmap_vlan(char *package, char *section_type, char *dmmap_package, char *ifname, struct list_head *dup_list, int *count, char *id);
|
||||
void synchronize_multi_config_sections_with_dmmap_set(char *package, char *section_type, char *dmmap_package, char* dmmap_section, char* option_name, char* option_value, char *instance, char *br_key);
|
||||
void synchronize_specific_config_sections_with_dmmap_eq(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list);
|
||||
void synchronize_specific_config_sections_with_dmmap_eq_no_delete(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue