mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-01-28 01:47:18 +01:00
Update the logic to identify 'macvlan' device
This commit is contained in:
parent
63302790e1
commit
7f6b13b082
2 changed files with 24 additions and 4 deletions
|
|
@ -59,6 +59,7 @@ do { \
|
|||
#define DM_STRLEN(SRC) ((SRC != NULL) ? strlen(SRC) : 0)
|
||||
#define DM_STRSTR(STR, MATCH) ((STR != NULL && MATCH != NULL) ? strstr(STR, MATCH) : NULL)
|
||||
#define DM_STRCHR(STR, CHR) ((STR != NULL) ? strchr(STR, CHR) : NULL)
|
||||
#define DM_STRRCHR(STR, CHR) ((STR != NULL) ? strrchr(STR, CHR) : NULL)
|
||||
#define DM_STRTOL(SRC) ((SRC != NULL) ? strtol(SRC, NULL, 10) : 0)
|
||||
#define DM_STRTOUL(SRC) ((SRC != NULL) ? strtoul(SRC, NULL, 10) : 0)
|
||||
#define DM_STRCMP(S1, S2) ((S1 != NULL && S2 != NULL) ? strcmp(S1, S2) : -1)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -144,13 +161,15 @@ static void dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_no
|
|||
|
||||
DM_STRNCPY(dev_name, device, sizeof(dev_name));
|
||||
|
||||
char *has_vid = DM_STRCHR(dev_name, '.');
|
||||
char *has_vid = DM_STRRCHR(dev_name, '.');
|
||||
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_STRRCHR(dev_name, '_');
|
||||
if (p)
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
if (is_ethernet_link_exist(dev_name))
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue