Fix LowerLayer value of IP.Interface. and Ethernet.Link.

This commit is contained in:
Amin Ben Romdhane 2023-06-02 15:57:00 +02:00
parent 4a8d286201
commit 52173292db
3 changed files with 22 additions and 9 deletions

View file

@ -132,7 +132,7 @@ static void dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_no
// Skip this interface section if its device starts with prfix 'link_' // Skip this interface section if its device starts with prfix 'link_'
dmuci_get_value_by_section_string(s, "device", &device); dmuci_get_value_by_section_string(s, "device", &device);
if (DM_STRNCMP(device, "link_", 5) == 0) if (DM_STRNCMP(device, "link_", 5) == 0 || DM_STRNCMP(device, "iface", 5) == 0)
continue; continue;
// Skip this interface section if its device is empty // Skip this interface section if its device is empty
@ -140,10 +140,7 @@ static void dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_no
if (DM_STRLEN(device) == 0) if (DM_STRLEN(device) == 0)
continue; continue;
// Skip this interface section if its device name isn't a real device
get_net_device_sysfs(device, "address", &macaddr); get_net_device_sysfs(device, "address", &macaddr);
if (DM_STRLEN(macaddr) == 0)
continue;
DM_STRNCPY(dev_name, device, sizeof(dev_name)); DM_STRNCPY(dev_name, device, sizeof(dev_name));

View file

@ -1298,8 +1298,11 @@ static int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
if ((*value)[0] == '\0') { if ((*value)[0] == '\0') {
char *device = get_device(section_name((struct uci_section *)data)); char *device = get_device(section_name((struct uci_section *)data));
if (DM_STRLEN(device) == 0) if (DM_STRLEN(device) == 0) {
return 0; dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
if (DM_STRLEN(device) == 0)
return 0;
}
adm_entry_get_linker_param(ctx, "Device.PPP.Interface.", device, value); adm_entry_get_linker_param(ctx, "Device.PPP.Interface.", device, value);
if (*value != NULL && (*value)[0] != 0) if (*value != NULL && (*value)[0] != 0)
@ -1428,6 +1431,9 @@ static int set_IPInterface_Router(char *refparam, struct dmctx *ctx, void *data,
if (!rt_table || *rt_table == 0) if (!rt_table || *rt_table == 0)
return FAULT_9007; return FAULT_9007;
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name((struct uci_section *)data), &s);
dmuci_set_value_by_section(s, "Router", value);
dmuci_set_value_by_section((struct uci_section *)data, "ip4table", rt_table); dmuci_set_value_by_section((struct uci_section *)data, "ip4table", rt_table);
dmuci_set_value_by_section((struct uci_section *)data, "ip6table", rt_table); dmuci_set_value_by_section((struct uci_section *)data, "ip6table", rt_table);

View file

@ -996,10 +996,13 @@ static int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
if ((*value)[0] == '\0') { if ((*value)[0] == '\0') {
char *device = NULL; char *device = NULL;
if (ppp->iface_s) if (ppp->iface_s) {
device = get_device(section_name(ppp->iface_s)); device = get_device(section_name(ppp->iface_s));
else if (DM_STRLEN(device) == 0)
dmuci_get_value_by_section_string(ppp->iface_s, "device", &device);
} else {
dmuci_get_value_by_section_string(ppp->dmmap_s, "device", &device); dmuci_get_value_by_section_string(ppp->dmmap_s, "device", &device);
}
if (DM_STRLEN(device) == 0) if (DM_STRLEN(device) == 0)
return 0; return 0;
@ -1165,7 +1168,14 @@ static int set_PPPInterfacePPPoE_ServiceName(char *refparam, struct dmctx *ctx,
***************************************************************************/ ***************************************************************************/
static int get_linker_ppp_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) static int get_linker_ppp_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{ {
dmuci_get_value_by_section_string(((struct ppp_args *)data)->dmmap_s, "device", linker); if (((struct ppp_args *)data)->iface_s) {
*linker = get_device(section_name(((struct ppp_args *)data)->iface_s));
if (DM_STRLEN(*linker) == 0)
dmuci_get_value_by_section_string(((struct ppp_args *)data)->iface_s, "device", linker);
} else {
dmuci_get_value_by_section_string(((struct ppp_args *)data)->dmmap_s, "device", linker);
}
return 0; return 0;
} }