From 4ef5f49dda239b493e227e3ab6ba43276513403d Mon Sep 17 00:00:00 2001 From: Amin Ben Ramdhane Date: Mon, 10 Oct 2022 20:01:44 +0000 Subject: [PATCH] T#8940: Device.Ethernet.Link. doesn't show correct MAC Address and Status when... --- dmtree/tr181/ethernet.c | 7 +++++-- dmtree/tr181/ip.c | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dmtree/tr181/ethernet.c b/dmtree/tr181/ethernet.c index c723d9dc..7974a7b3 100644 --- a/dmtree/tr181/ethernet.c +++ b/dmtree/tr181/ethernet.c @@ -1081,6 +1081,7 @@ static int get_EthernetLink_Status(char *refparam, struct dmctx *ctx, void *data dmuci_get_value_by_section_string((struct uci_section *)data, "section_name", &interface_name); s = get_origin_section_from_config("network", "interface", interface_name); dmuci_get_value_by_section_string(s, "device", &dev_name); + get_net_iface_sysfs(interface_name, "address", value); return get_net_device_status(dev_name, value); } @@ -1313,8 +1314,10 @@ static int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void static int get_EthernetLink_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "mac", value); - return 0; + char *interface_name = NULL; + + dmuci_get_value_by_section_string((struct uci_section *)data, "section_name", &interface_name); + return get_net_iface_sysfs(interface_name, "address", value); } static int get_EthernetLinkStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) diff --git a/dmtree/tr181/ip.c b/dmtree/tr181/ip.c index d9c6f59b..2f16d5a0 100644 --- a/dmtree/tr181/ip.c +++ b/dmtree/tr181/ip.c @@ -1441,6 +1441,10 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void * uci_foreach_option_eq_safe("network", "interface", "device", dev_buf, stmp, s) { dmuci_delete_by_section(s, NULL, NULL); } + + // Check if there is an dmmap link section that has the same device ==> if yes, update section name + get_dmmap_section_of_config_section_eq("dmmap", "link", "device", dev_buf, &s); + dmuci_set_value_by_section_bbfdm(s, "section_name", section_name((struct uci_section *)data)); } }