mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 20:20:17 +01:00
cloud-setup: make _device_get_hwaddr() work with all kinds of devices
We'll have Vlans and MacVlans soon, and those don't have permanent addresses.
This commit is contained in:
parent
04e426a7bf
commit
04f0491a58
1 changed files with 10 additions and 5 deletions
|
|
@ -198,13 +198,14 @@ _map_interfaces_parse(void)
|
|||
}
|
||||
|
||||
static const char *
|
||||
_device_get_hwaddr(NMDeviceEthernet *device)
|
||||
_device_get_hwaddr(NMDevice *device)
|
||||
{
|
||||
static const NMUtilsNamedValue *gl_map_interfaces_map = NULL;
|
||||
static gsize gl_initialized = 0;
|
||||
const NMUtilsNamedValue *map = NULL;
|
||||
|
||||
nm_assert(NM_IS_DEVICE_ETHERNET(device));
|
||||
nm_assert(NM_IS_DEVICE_ETHERNET(device) || NM_IS_DEVICE_MACVLAN(device)
|
||||
|| NM_IS_DEVICE_VLAN(device));
|
||||
|
||||
/* Network interfaces in cloud environments are identified by their permanent
|
||||
* MAC address.
|
||||
|
|
@ -238,7 +239,11 @@ _device_get_hwaddr(NMDeviceEthernet *device)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return nm_device_ethernet_get_permanent_hw_address(device);
|
||||
if (NM_IS_DEVICE_ETHERNET(device)) {
|
||||
return nm_device_ethernet_get_permanent_hw_address(NM_DEVICE_ETHERNET(device));
|
||||
} else {
|
||||
return nm_device_get_hw_address(device);
|
||||
}
|
||||
}
|
||||
|
||||
static char **
|
||||
|
|
@ -263,7 +268,7 @@ _nmc_get_ethernet_hwaddrs(NMClient *nmc)
|
|||
if (nm_device_get_state(device) < NM_DEVICE_STATE_UNAVAILABLE)
|
||||
continue;
|
||||
|
||||
hwaddr = _device_get_hwaddr(NM_DEVICE_ETHERNET(device));
|
||||
hwaddr = _device_get_hwaddr(device);
|
||||
if (!hwaddr)
|
||||
continue;
|
||||
|
||||
|
|
@ -305,7 +310,7 @@ _nmc_get_device_by_hwaddr(NMClient *nmc, const char *hwaddr)
|
|||
if (!NM_IS_DEVICE_ETHERNET(device))
|
||||
continue;
|
||||
|
||||
hwaddr_dev = _device_get_hwaddr(NM_DEVICE_ETHERNET(device));
|
||||
hwaddr_dev = _device_get_hwaddr(device);
|
||||
if (!hwaddr_dev)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue