From 25a5df6b98e0b5e9782d78170cbf7ed5b1cab79e Mon Sep 17 00:00:00 2001 From: Ratish Date: Wed, 2 Aug 2023 09:16:46 +0000 Subject: [PATCH] Updated the logic to identify macvlan device --- libbbfdm/dmtree/tr181/ethernet.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/libbbfdm/dmtree/tr181/ethernet.c b/libbbfdm/dmtree/tr181/ethernet.c index 56c1ef5a..0b66c8e9 100644 --- a/libbbfdm/dmtree/tr181/ethernet.c +++ b/libbbfdm/dmtree/tr181/ethernet.c @@ -100,6 +100,23 @@ bool ethernet___name_exists_in_devices(char *name) return false; } +static bool is_mac_vlan_interface(char *device_name) +{ + struct uci_section *s = NULL; + char *type = NULL, *name = NULL; + + uci_foreach_sections("network", "device", s) { + + dmuci_get_value_by_section_string(s, "type", &type); + dmuci_get_value_by_section_string(s, "name", &name); + + if (DM_STRCMP(type, "macvlan") == 0 && DM_STRCMP(name, device_name) == 0) + return true; + } + + return false; +} + static void add_ethernet_link_section(char *device, char *macaddr) { struct uci_section *dmmap_s = NULL; @@ -148,9 +165,11 @@ static void dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_no if (has_vid) *has_vid = '\0'; - char *is_mac_vlan = DM_STRCHR(dev_name, '_'); - if (is_mac_vlan) - *is_mac_vlan = '\0'; + if (is_mac_vlan_interface(dev_name)) { + char *p = DM_STRCHR(dev_name, '_'); + if (p) + *p = '\0'; + } if (is_ethernet_link_exist(dev_name)) continue;