VLANTermination: Remove unnecessary option

This commit is contained in:
Amin Ben Romdhane 2023-04-28 12:09:38 +02:00
parent 6df50f9956
commit 2e13ddbd0e
2 changed files with 9 additions and 16 deletions

View file

@ -209,7 +209,7 @@ static int browseEthernetLinkInst(struct dmctx *dmctx, DMNODE *parent_node, void
/*#Device.Ethernet.VLANTermination.{i}.!UCI:network/device/dmmap_network*/
static int browseEthernetVLANTerminationInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *type, *name, *is_vlan, *inst = NULL;
char *type, *name, *inst = NULL;
struct dmmap_dup *p = NULL;
LIST_HEAD(dup_list);
@ -218,11 +218,10 @@ static int browseEthernetVLANTerminationInst(struct dmctx *dmctx, DMNODE *parent
dmuci_get_value_by_section_string(p->config_section, "type", &type);
dmuci_get_value_by_section_string(p->config_section, "name", &name);
dmuci_get_value_by_section_string(p->dmmap_section, "is_vlan_ter", &is_vlan);
if (DM_LSTRCMP(type, "bridge") == 0 ||
DM_LSTRCMP(type, "macvlan") == 0 ||
(*name == 0 && DM_LSTRCMP(is_vlan, "1") != 0) ||
(*name != 0 && !ethernet___check_vlan_termination_section(name)))
(*name != 0 && !ethernet___check_vlan_termination_section(name)) ||
(*name == 0 && strncmp(section_name(p->config_section), "br_", 3) == 0))
continue;
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "vlan_term_instance", "vlan_term_alias");
@ -366,7 +365,6 @@ static int addObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void
// Add device section in dmmap_network file
dmuci_add_section_bbfdm("dmmap_network", "device", &dmmap_network);
dmuci_set_value_by_section(dmmap_network, "section_name", device_name);
dmuci_set_value_by_section(dmmap_network, "is_vlan_ter", "1");
dmuci_set_value_by_section(dmmap_network, "vlan_term_instance", *instance);
return 0;
}
@ -374,7 +372,7 @@ static int addObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void
static int delObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s_dev = NULL, *sdevtmp = NULL;
char *name, *type, *is_vlan;
char *name, *type;
switch (del_action) {
case DEL_INST:
@ -389,13 +387,12 @@ static int delObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_network", "device", section_name(s_dev), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "is_vlan_ter", &is_vlan);
dmuci_get_value_by_section_string(s_dev, "type", &type);
dmuci_get_value_by_section_string(s_dev, "name", &name);
if (DM_LSTRCMP(type, "bridge") == 0 ||
(*name == 0 && DM_LSTRCMP(is_vlan, "1") != 0) ||
(*name != 0 && !ethernet___check_vlan_termination_section(name)))
(*name != 0 && !ethernet___check_vlan_termination_section(name)) ||
(*name == 0 && strncmp(section_name(s_dev), "br_", 3) == 0))
continue;
// Remove device section in dmmap_network file

View file

@ -298,19 +298,15 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
/* Higher layers are Device.Ethernet.VLANTermination.{i}. */
uci_foreach_sections("network", "device", s) {
struct uci_section *dmmap_section = NULL;
char *type = NULL, *name = NULL, *ifname = NULL, *is_vlan = NULL, *value = NULL;
get_dmmap_section_of_config_section("dmmap_network", "device", section_name(s), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "is_vlan_ter", &is_vlan);
char *type = NULL, *name = NULL, *ifname = NULL, *value = NULL;
dmuci_get_value_by_section_string(s, "type", &type);
dmuci_get_value_by_section_string(s, "name", &name);
dmuci_get_value_by_section_string(s, "ifname", &ifname);
if (DM_LSTRCMP(type, "bridge") == 0 ||
DM_LSTRCMP(type, "macvlan") == 0 ||
(*name == 0 && DM_LSTRCMP(is_vlan, "1") != 0) ||
(*name != 0 && !ethernet___check_vlan_termination_section(name)))
(*name != 0 && !ethernet___check_vlan_termination_section(name)) ||
(*name == 0 && strncmp(section_name(s), "br_", 3) == 0))
continue;
// The higher layer is Device.Ethernet.VLANTermination.{i}.