summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-10-09 10:27:22 +0200
committerThomas Haller <thaller@redhat.com>2020-10-09 10:37:14 +0200
commit8cab6f151d9dcddf72ac9db43e0b8538c785e770 (patch)
tree9615e08d389ea65fee5f3a81d3811c20e790f02e
parentbba1ab0f21b4114a6ae3d92c536e0803bcf9e4cd (diff)
downloadNetworkManager-8cab6f151d9dcddf72ac9db43e0b8538c785e770.tar.gz
device: ensure unique counter for udi placeholder variable
- use a guint64 variable to avoid wrapping the counter - cache the used ID in NMDevice. This way, the same NMDevice instance will get the same UDI path when it realizes and unrealizes multiple times.
-rw-r--r--src/devices/nm-device.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 2dab5075a6..57882382ba 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -357,6 +357,8 @@ typedef struct _NMDevicePrivate {
bool assume_state_guess_assume : 1;
char *assume_state_connection_uuid;
+ guint64 udi_id;
+
GHashTable *available_connections;
char * hw_addr;
char * hw_addr_perm;
@@ -5881,7 +5883,6 @@ realize_start_setup(NMDevice * self,
NMDevicePrivate * priv;
NMDeviceClass * klass;
NMPlatform * platform;
- static guint32 id = 0;
NMDeviceCapabilities capabilities = 0;
NMConfig * config;
guint real_rate;
@@ -5967,7 +5968,12 @@ realize_start_setup(NMDevice * self,
if (!priv->udi) {
/* Use a placeholder UDI until we get a real one */
- priv->udi = g_strdup_printf("/virtual/device/placeholder/%d", id++);
+ if (priv->udi_id == 0) {
+ static guint64 udi_id_counter = 0;
+
+ priv->udi_id = ++udi_id_counter;
+ }
+ priv->udi = g_strdup_printf("/virtual/device/placeholder/%" G_GUINT64_FORMAT, priv->udi_id);
_notify(self, PROP_UDI);
}