summaryrefslogtreecommitdiff
path: root/src/nm-cloud-setup
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-04-29 10:34:48 +0200
committerThomas Haller <thaller@redhat.com>2022-05-05 08:37:29 +0200
commita1d9fce14725011a93eb92a87f862d5dd1e0bcb7 (patch)
tree0bd2733b16076c10169a41fdad4b561cb64643d7 /src/nm-cloud-setup
parent16ba58cfb1f12026f2c8f85658d60bedb9df7987 (diff)
downloadNetworkManager-a1d9fce14725011a93eb92a87f862d5dd1e0bcb7.tar.gz
cloud-setup: only pass config-iface-data as user-data for async functions
From config_iface_data->get_config_data we have access to the other pointer already. No need to allocate a user data. (cherry picked from commit 7d71aff24770ad8ba6c6bc16a83d4d9e2544bd45)
Diffstat (limited to 'src/nm-cloud-setup')
-rw-r--r--src/nm-cloud-setup/nmcs-provider-aliyun.c45
-rw-r--r--src/nm-cloud-setup/nmcs-provider-ec2.c29
2 files changed, 34 insertions, 40 deletions
diff --git a/src/nm-cloud-setup/nmcs-provider-aliyun.c b/src/nm-cloud-setup/nmcs-provider-aliyun.c
index 02fd7a01aa..1a5e5459e4 100644
--- a/src/nm-cloud-setup/nmcs-provider-aliyun.c
+++ b/src/nm-cloud-setup/nmcs-provider-aliyun.c
@@ -129,24 +129,20 @@ typedef enum {
} GetConfigFetchDoneType;
static void
-_get_config_fetch_done_cb(NMHttpClient *http_client,
- GAsyncResult *result,
- gpointer user_data,
- GetConfigFetchDoneType fetch_type)
+_get_config_fetch_done_cb(NMHttpClient *http_client,
+ GAsyncResult *result,
+ NMCSProviderGetConfigIfaceData *config_iface_data,
+ GetConfigFetchDoneType fetch_type)
{
- NMCSProviderGetConfigTaskData *get_config_data;
- gs_unref_bytes GBytes *response = NULL;
- gs_free_error GError *error = NULL;
- NMCSProviderGetConfigIfaceData *config_iface_data;
- in_addr_t tmp_addr;
- int tmp_prefix;
- in_addr_t netmask_bin;
- in_addr_t gateway_bin;
- gs_free const char **s_addrs = NULL;
- gsize i;
- gsize len;
-
- nm_utils_user_data_unpack(user_data, &get_config_data, &config_iface_data);
+ gs_unref_bytes GBytes *response = NULL;
+ gs_free_error GError *error = NULL;
+ in_addr_t tmp_addr;
+ int tmp_prefix;
+ in_addr_t netmask_bin;
+ in_addr_t gateway_bin;
+ gs_free const char **s_addrs = NULL;
+ gsize i;
+ gsize len;
nm_http_client_poll_get_finish(http_client, result, NULL, &response, &error);
@@ -244,8 +240,9 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
}
out:
- get_config_data->n_pending--;
- _nmcs_provider_get_config_task_maybe_return(get_config_data, g_steal_pointer(&error));
+ config_iface_data->get_config_data->n_pending--;
+ _nmcs_provider_get_config_task_maybe_return(config_iface_data->get_config_data,
+ g_steal_pointer(&error));
}
static void
@@ -379,7 +376,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_vpc_cidr_block,
- nm_utils_user_data_pack(get_config_data, config_iface_data));
+ config_iface_data);
get_config_data->n_pending++;
nm_http_client_poll_get(
@@ -396,7 +393,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_private_ipv4s,
- nm_utils_user_data_pack(get_config_data, config_iface_data));
+ config_iface_data);
get_config_data->n_pending++;
nm_http_client_poll_get(
@@ -413,7 +410,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_primary_ip_address,
- nm_utils_user_data_pack(get_config_data, config_iface_data));
+ config_iface_data);
get_config_data->n_pending++;
nm_http_client_poll_get(
@@ -430,7 +427,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_netmask,
- nm_utils_user_data_pack(get_config_data, config_iface_data));
+ config_iface_data);
get_config_data->n_pending++;
nm_http_client_poll_get(
@@ -447,7 +444,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_gateway,
- nm_utils_user_data_pack(get_config_data, config_iface_data));
+ config_iface_data);
}
_nmcs_provider_get_config_task_maybe_return(get_config_data, NULL);
diff --git a/src/nm-cloud-setup/nmcs-provider-ec2.c b/src/nm-cloud-setup/nmcs-provider-ec2.c
index 8362dd7c79..d6fa03118d 100644
--- a/src/nm-cloud-setup/nmcs-provider-ec2.c
+++ b/src/nm-cloud-setup/nmcs-provider-ec2.c
@@ -116,19 +116,15 @@ detect(NMCSProvider *provider, GTask *task)
/*****************************************************************************/
static void
-_get_config_fetch_done_cb(NMHttpClient *http_client,
- GAsyncResult *result,
- gpointer user_data,
- gboolean is_local_ipv4)
+_get_config_fetch_done_cb(NMHttpClient *http_client,
+ GAsyncResult *result,
+ NMCSProviderGetConfigIfaceData *config_iface_data,
+ gboolean is_local_ipv4)
{
- NMCSProviderGetConfigTaskData *get_config_data;
- gs_unref_bytes GBytes *response = NULL;
- gs_free_error GError *error = NULL;
- NMCSProviderGetConfigIfaceData *config_iface_data;
- in_addr_t tmp_addr;
- int tmp_prefix;
-
- nm_utils_user_data_unpack(user_data, &get_config_data, &config_iface_data);
+ gs_unref_bytes GBytes *response = NULL;
+ gs_free_error GError *error = NULL;
+ in_addr_t tmp_addr;
+ int tmp_prefix;
nm_http_client_poll_get_finish(http_client, result, NULL, &response, &error);
@@ -173,8 +169,9 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
}
out:
- get_config_data->n_pending--;
- _nmcs_provider_get_config_task_maybe_return(get_config_data, g_steal_pointer(&error));
+ config_iface_data->get_config_data->n_pending--;
+ _nmcs_provider_get_config_task_maybe_return(config_iface_data->get_config_data,
+ g_steal_pointer(&error));
}
static void
@@ -271,7 +268,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_subnet_ipv4_cidr_block,
- nm_utils_user_data_pack(get_config_data, config_iface_data));
+ config_iface_data);
get_config_data->n_pending++;
nm_http_client_poll_get(
@@ -288,7 +285,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_local_ipv4s,
- nm_utils_user_data_pack(get_config_data, config_iface_data));
+ config_iface_data);
}
_nmcs_provider_get_config_task_maybe_return(get_config_data, NULL);