mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 12:28:11 +02:00
dhcp: use cleanup attribute in nm_dhcp_client_handle_event()
and use NMIPConfig type.
This commit is contained in:
parent
97dc1ec1e4
commit
ef8782127f
1 changed files with 19 additions and 22 deletions
|
|
@ -770,8 +770,8 @@ nm_dhcp_client_handle_event (gpointer unused,
|
||||||
NMDhcpClientPrivate *priv;
|
NMDhcpClientPrivate *priv;
|
||||||
guint32 old_state;
|
guint32 old_state;
|
||||||
guint32 new_state;
|
guint32 new_state;
|
||||||
GHashTable *str_options = NULL;
|
gs_unref_hashtable GHashTable *str_options = NULL;
|
||||||
GObject *ip_config = NULL;
|
gs_unref_object NMIPConfig *ip_config = NULL;
|
||||||
NMPlatformIP6Address prefix = { 0, };
|
NMPlatformIP6Address prefix = { 0, };
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE);
|
g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE);
|
||||||
|
|
@ -815,24 +815,24 @@ nm_dhcp_client_handle_event (gpointer unused,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the IP config */
|
/* Create the IP config */
|
||||||
g_warn_if_fail (g_hash_table_size (str_options));
|
if (g_hash_table_size (str_options) > 0) {
|
||||||
if (g_hash_table_size (str_options)) {
|
|
||||||
if (priv->addr_family == AF_INET) {
|
if (priv->addr_family == AF_INET) {
|
||||||
ip_config = (GObject *) nm_dhcp_utils_ip4_config_from_options (nm_dhcp_client_get_multi_idx (self),
|
ip_config = NM_IP_CONFIG_CAST (nm_dhcp_utils_ip4_config_from_options (nm_dhcp_client_get_multi_idx (self),
|
||||||
priv->ifindex,
|
priv->ifindex,
|
||||||
priv->iface,
|
priv->iface,
|
||||||
str_options,
|
str_options,
|
||||||
priv->route_table,
|
priv->route_table,
|
||||||
priv->route_metric);
|
priv->route_metric));
|
||||||
} else {
|
} else {
|
||||||
prefix = nm_dhcp_utils_ip6_prefix_from_options (str_options);
|
prefix = nm_dhcp_utils_ip6_prefix_from_options (str_options);
|
||||||
ip_config = (GObject *) nm_dhcp_utils_ip6_config_from_options (nm_dhcp_client_get_multi_idx (self),
|
ip_config = NM_IP_CONFIG_CAST (nm_dhcp_utils_ip6_config_from_options (nm_dhcp_client_get_multi_idx (self),
|
||||||
priv->ifindex,
|
priv->ifindex,
|
||||||
priv->iface,
|
priv->iface,
|
||||||
str_options,
|
str_options,
|
||||||
priv->info_only);
|
priv->info_only));
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
g_warn_if_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IN6_IS_ADDR_UNSPECIFIED (&prefix.address)) {
|
if (!IN6_IS_ADDR_UNSPECIFIED (&prefix.address)) {
|
||||||
|
|
@ -844,19 +844,16 @@ nm_dhcp_client_handle_event (gpointer unused,
|
||||||
&prefix);
|
&prefix);
|
||||||
} else {
|
} else {
|
||||||
/* Fail if no valid IP config was received */
|
/* Fail if no valid IP config was received */
|
||||||
if (new_state == NM_DHCP_STATE_BOUND && ip_config == NULL) {
|
if ( new_state == NM_DHCP_STATE_BOUND
|
||||||
|
&& !ip_config) {
|
||||||
_LOGW ("client bound but IP config not received");
|
_LOGW ("client bound but IP config not received");
|
||||||
new_state = NM_DHCP_STATE_FAIL;
|
new_state = NM_DHCP_STATE_FAIL;
|
||||||
g_clear_pointer (&str_options, g_hash_table_unref);
|
g_clear_pointer (&str_options, g_hash_table_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
nm_dhcp_client_set_state (self, new_state, ip_config, str_options);
|
nm_dhcp_client_set_state (self, new_state, G_OBJECT (ip_config), str_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str_options)
|
|
||||||
g_hash_table_destroy (str_options);
|
|
||||||
g_clear_object (&ip_config);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue