From 0af98c8c3660c5159046d67365602193efc64996 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Wed, 5 Feb 2025 14:35:11 +0100 Subject: [PATCH] Reapply "cloud-setup: lookup device by MAC + type instead of just MAC" This will be useful for updating configuration of Vlans and MacVlans, some of having same MAC addresses as devices of other type. This reverts commit cee0515f1399fe05f650adec147435aa0a933d78. --- src/nm-cloud-setup/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nm-cloud-setup/main.c b/src/nm-cloud-setup/main.c index 44500ffa9f..d913ea1ffe 100644 --- a/src/nm-cloud-setup/main.c +++ b/src/nm-cloud-setup/main.c @@ -295,7 +295,7 @@ _nmc_get_ethernet_hwaddrs(NMClient *nmc) } static NMDevice * -_nmc_get_device_by_hwaddr(NMClient *nmc, const char *hwaddr) +_nmc_get_device_by_hwaddr(NMClient *nmc, const GType type_device, const char *hwaddr) { const GPtrArray *devices; guint i; @@ -307,7 +307,7 @@ _nmc_get_device_by_hwaddr(NMClient *nmc, const char *hwaddr) const char *hwaddr_dev; gs_free char *s = NULL; - if (!NM_IS_DEVICE_ETHERNET(device)) + if (!G_TYPE_CHECK_INSTANCE_TYPE(device, type_device)) continue; hwaddr_dev = _device_get_hwaddr(device); @@ -589,7 +589,7 @@ _config_one(SigTermData *sigterm_data, if (g_cancellable_is_cancelled(sigterm_data->cancellable)) return FALSE; - device = nm_g_object_ref(_nmc_get_device_by_hwaddr(nmc, hwaddr)); + device = nm_g_object_ref(_nmc_get_device_by_hwaddr(nmc, NM_DEVICE_TYPE_ETHERNET, hwaddr)); if (!device) { _LOGD("config device %s: skip because device not found", hwaddr); return FALSE;