mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
TR181 : issues related to Lowerlayers management and order dependency
This commit is contained in:
parent
452858fe1e
commit
6a0545cf50
2 changed files with 94 additions and 2 deletions
|
|
@ -166,12 +166,21 @@ static void create_link(char *sec_name, char *mac_addr)
|
|||
static int dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
char *ifname, *macaddr;
|
||||
char *ifname, *macaddr, *type, *proto;
|
||||
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
|
||||
// Skip this interface section if its name=loopback
|
||||
if (strcmp(section_name(s), "loopback") == 0)
|
||||
continue;
|
||||
|
||||
// Skip this interface section if type=bridge and proto is empty
|
||||
dmuci_get_value_by_section_string(s, "type", &type);
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if ((strcmp(type, "bridge") == 0) && *proto == '\0')
|
||||
continue;
|
||||
|
||||
// Skip this interface section if ifname is empty
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
if (*ifname == '\0')
|
||||
continue;
|
||||
|
|
@ -963,7 +972,7 @@ static int get_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
static int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char lower_layer[250] = {0};
|
||||
char lower_layer[256] = {0};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
|
|
@ -992,6 +1001,50 @@ static int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (strncmp(lower_layer, "Device.Bridging.Bridge.", 23) == 0) {
|
||||
char *linker;
|
||||
adm_entry_get_linker_value(ctx, lower_layer, &linker);
|
||||
|
||||
if (linker == NULL || *linker == '\0')
|
||||
return -1;
|
||||
|
||||
char br_linker[250] = {0};
|
||||
strncpy(br_linker, linker, sizeof(br_linker) - 1);
|
||||
|
||||
char *bridge = strchr(br_linker, ':');
|
||||
if (bridge) {
|
||||
*bridge = '\0';
|
||||
char br_inst[8] = {0};
|
||||
strncpy(br_inst, br_linker+3, sizeof(br_inst) - 1);
|
||||
|
||||
struct uci_section *port;
|
||||
char *interface, *curr_interface;
|
||||
|
||||
// Remove the network section corresponding to this dmmap interface if exists
|
||||
dmuci_get_value_by_section_string(((struct dm_args *)data)->section, "section_name", &curr_interface);
|
||||
struct uci_section *s, *tmp;
|
||||
uci_foreach_sections_safe("network", "interface", tmp, s) {
|
||||
if (strcmp(section_name(s), curr_interface) == 0) {
|
||||
char *proto;
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (*proto == '\0') dmuci_delete_by_section(s, NULL, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the interface bridge name
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_inst, port) {
|
||||
dmuci_get_value_by_section_string(port, "interface", &interface);
|
||||
break;
|
||||
}
|
||||
|
||||
// Get the device name
|
||||
char *device = get_device(interface);
|
||||
|
||||
// Get dmmap section
|
||||
dmuci_set_value_by_section(((struct dm_args *)data)->section, "device", device);
|
||||
dmuci_set_value_by_section(((struct dm_args *)data)->section, "section_name", interface);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -773,6 +773,45 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
|
|||
|
||||
// Update ifname list
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ifname", linker);
|
||||
|
||||
} else if (strncmp(lower_layer, "Device.Ethernet.Link.", 21) == 0) {
|
||||
adm_entry_get_linker_value(ctx, lower_layer, &linker);
|
||||
|
||||
if (linker == NULL || *linker == '\0')
|
||||
return -1;
|
||||
|
||||
// Get interface name from Ethernet.Link. object
|
||||
struct uci_section *s = NULL;
|
||||
char *interface;
|
||||
get_dmmap_section_of_config_section_eq("dmmap", "link", "device", linker, &s);
|
||||
dmuci_get_value_by_section_string(s, "section_name", &interface);
|
||||
|
||||
// Update the new interface section with proto=dhcp
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
if (strcmp(section_name(s), interface) == 0) {
|
||||
dmuci_set_value_by_section(s, "proto", "dhcp");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get dmmap section related to this interface section and remove it
|
||||
struct uci_section *dmmap_section = NULL;
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
|
||||
|
||||
// Get the current ip instance
|
||||
char *ip_int_instance;
|
||||
dmuci_get_value_by_section_string(dmmap_section, "ip_int_instance", &ip_int_instance);
|
||||
|
||||
// Get the new dmmap section related to the new interface section and update ip instance option
|
||||
struct uci_section *new_dmmap_section = NULL;
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", interface, &new_dmmap_section);
|
||||
dmuci_set_value_by_section(new_dmmap_section, "ip_int_instance", ip_int_instance);
|
||||
|
||||
// remove dmmap section
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
|
||||
// remove the current interface section
|
||||
dmuci_delete_by_section(((struct ip_args *)data)->ip_sec, NULL, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue