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:
@@ -198,13 +198,14 @@ _map_interfaces_parse(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
_device_get_hwaddr(NMDeviceEthernet *device)
|
_device_get_hwaddr(NMDevice *device)
|
||||||
{
|
{
|
||||||
static const NMUtilsNamedValue *gl_map_interfaces_map = NULL;
|
static const NMUtilsNamedValue *gl_map_interfaces_map = NULL;
|
||||||
static gsize gl_initialized = 0;
|
static gsize gl_initialized = 0;
|
||||||
const NMUtilsNamedValue *map = NULL;
|
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
|
/* Network interfaces in cloud environments are identified by their permanent
|
||||||
* MAC address.
|
* MAC address.
|
||||||
@@ -238,7 +239,11 @@ _device_get_hwaddr(NMDeviceEthernet *device)
|
|||||||
return NULL;
|
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 **
|
static char **
|
||||||
@@ -263,7 +268,7 @@ _nmc_get_ethernet_hwaddrs(NMClient *nmc)
|
|||||||
if (nm_device_get_state(device) < NM_DEVICE_STATE_UNAVAILABLE)
|
if (nm_device_get_state(device) < NM_DEVICE_STATE_UNAVAILABLE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
hwaddr = _device_get_hwaddr(NM_DEVICE_ETHERNET(device));
|
hwaddr = _device_get_hwaddr(device);
|
||||||
if (!hwaddr)
|
if (!hwaddr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -305,7 +310,7 @@ _nmc_get_device_by_hwaddr(NMClient *nmc, const char *hwaddr)
|
|||||||
if (!NM_IS_DEVICE_ETHERNET(device))
|
if (!NM_IS_DEVICE_ETHERNET(device))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
hwaddr_dev = _device_get_hwaddr(NM_DEVICE_ETHERNET(device));
|
hwaddr_dev = _device_get_hwaddr(device);
|
||||||
if (!hwaddr_dev)
|
if (!hwaddr_dev)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user