dhcp: drop "event_id" parameter from NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED signal

It is solely computed from the lease information (the GHashTable).
No need to pass it along as separate argument in NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED,
especially since it only applies to IPv6.
This commit is contained in:
Thomas Haller 2020-09-10 13:46:10 +02:00
parent ee447cbb52
commit 345aeefaf3
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
6 changed files with 42 additions and 23 deletions

View file

@ -8721,7 +8721,6 @@ dhcp4_state_changed (NMDhcpClient *client,
NMDhcpState state,
NMIP4Config *ip4_config,
GHashTable *options,
const char *event_id,
gpointer user_data)
{
NMDevice *self = NM_DEVICE (user_data);
@ -9561,11 +9560,11 @@ dhcp6_state_changed (NMDhcpClient *client,
NMDhcpState state,
NMIP6Config *ip6_config,
GHashTable *options,
const char *event_id,
gpointer user_data)
{
NMDevice *self = NM_DEVICE (user_data);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
gs_free char *event_id = NULL;
g_return_if_fail (nm_dhcp_client_get_addr_family (client) == AF_INET6);
g_return_if_fail (!ip6_config || NM_IS_IP6_CONFIG (ip6_config));
@ -9581,6 +9580,9 @@ dhcp6_state_changed (NMDhcpClient *client,
* changed event for each of them. Use the event ID to merge IPv6
* addresses from the same transaction into a single configuration.
*/
event_id = nm_dhcp_utils_get_dhcp6_event_id (options);
if ( ip6_config
&& event_id
&& priv->dhcp6.event_id

View file

@ -480,15 +480,8 @@ nm_dhcp_client_set_state (NMDhcpClient *self,
}
}
if ( priv->addr_family == AF_INET6
&& NM_IN_SET (new_state, NM_DHCP_STATE_BOUND, NM_DHCP_STATE_EXTENDED)) {
char *start, *iaid;
iaid = g_hash_table_lookup (options, "iaid");
start = g_hash_table_lookup (options, "life_starts");
if (iaid && start)
event_id = g_strdup_printf ("%s|%s", iaid, start);
}
if (priv->addr_family == AF_INET6)
event_id = nm_dhcp_utils_get_dhcp6_event_id (options);
_LOGI ("state changed %s -> %s%s%s%s",
state_to_string (priv->state),
@ -500,8 +493,7 @@ nm_dhcp_client_set_state (NMDhcpClient *self,
signals[SIGNAL_STATE_CHANGED], 0,
new_state,
ip_config,
options,
event_id);
options);
}
static gboolean
@ -1319,7 +1311,11 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class)
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_OBJECT, G_TYPE_HASH_TABLE, G_TYPE_STRING);
G_TYPE_NONE,
3,
G_TYPE_UINT,
G_TYPE_OBJECT,
G_TYPE_HASH_TABLE);
signals[SIGNAL_PREFIX_DELEGATED] =
g_signal_new (NM_DHCP_CLIENT_SIGNAL_PREFIX_DELEGATED,

View file

@ -45,6 +45,14 @@ G_DEFINE_TYPE (NMDhcpManager, nm_dhcp_manager, G_TYPE_OBJECT)
/*****************************************************************************/
static void client_state_changed (NMDhcpClient *client,
NMDhcpState state,
GObject *ip_config,
GVariant *options,
NMDhcpManager *self);
/*****************************************************************************/
/* default to installed helper, but can be modified for testing */
const char *nm_dhcp_helper_path = LIBEXECDIR "/nm-dhcp-helper";
@ -161,13 +169,6 @@ get_client_for_ifindex (NMDhcpManager *manager, int addr_family, int ifindex)
return NULL;
}
static void client_state_changed (NMDhcpClient *client,
NMDhcpState state,
GObject *ip_config,
GVariant *options,
const char *event_id,
NMDhcpManager *self);
static void
remove_client (NMDhcpManager *self, NMDhcpClient *client)
{
@ -192,7 +193,6 @@ client_state_changed (NMDhcpClient *client,
NMDhcpState state,
GObject *ip_config,
GVariant *options,
const char *event_id,
NMDhcpManager *self)
{
if (state >= NM_DHCP_STATE_TIMEOUT)

View file

@ -786,3 +786,23 @@ nm_dhcp_utils_get_leasefile_path (int addr_family,
*out_leasefile_path = g_steal_pointer (&statedir_path);
return FALSE;
}
char *
nm_dhcp_utils_get_dhcp6_event_id (GHashTable *lease)
{
const char *start;
const char *iaid;
if (!lease)
return NULL;
iaid = g_hash_table_lookup (lease, "iaid");
if (!iaid)
return NULL;
start = g_hash_table_lookup (lease, "life_starts");
if (!start)
return NULL;
return g_strdup_printf ("%s|%s", iaid, start);
}

View file

@ -38,5 +38,7 @@ gboolean nm_dhcp_utils_get_leasefile_path (int addr_family,
char **nm_dhcp_parse_search_list (guint8 *data, size_t n_data);
char *nm_dhcp_utils_get_dhcp6_event_id (GHashTable *lease);
#endif /* __NETWORKMANAGER_DHCP_UTILS_H__ */

View file

@ -95,7 +95,6 @@ dhcp4_state_changed (NMDhcpClient *client,
NMDhcpState state,
NMIP4Config *ip4_config,
GHashTable *options,
const char *event_id,
gpointer user_data)
{
static NMIP4Config *last_config = NULL;