summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-09-10 13:46:10 +0200
committerThomas Haller <thaller@redhat.com>2020-09-11 10:58:16 +0200
commit96bd3baad4ea6fb1a28048f7f292f5edfca1d706 (patch)
treebde7b7eca75fc246bb9f93ed785441f7740e77a6
parent63c228271d8726d0ec65bf25534ff4977ce43550 (diff)
downloadNetworkManager-th/l3cfg-8.tar.gz
dhcp: drop "event_id" parameter from NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED signalth/l3cfg-8
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.
-rw-r--r--src/devices/nm-device.c6
-rw-r--r--src/dhcp/nm-dhcp-client.c20
-rw-r--r--src/dhcp/nm-dhcp-manager.c16
-rw-r--r--src/dhcp/nm-dhcp-utils.c20
-rw-r--r--src/dhcp/nm-dhcp-utils.h2
-rw-r--r--src/nm-iface-helper.c1
6 files changed, 42 insertions, 23 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 5937393fcf..816c002d8a 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -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
diff --git a/src/dhcp/nm-dhcp-client.c b/src/dhcp/nm-dhcp-client.c
index b02ff93426..9f937ac13e 100644
--- a/src/dhcp/nm-dhcp-client.c
+++ b/src/dhcp/nm-dhcp-client.c
@@ -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,
diff --git a/src/dhcp/nm-dhcp-manager.c b/src/dhcp/nm-dhcp-manager.c
index 5148d641f1..78677d8eec 100644
--- a/src/dhcp/nm-dhcp-manager.c
+++ b/src/dhcp/nm-dhcp-manager.c
@@ -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)
diff --git a/src/dhcp/nm-dhcp-utils.c b/src/dhcp/nm-dhcp-utils.c
index 88ced0548e..c4bb7872ce 100644
--- a/src/dhcp/nm-dhcp-utils.c
+++ b/src/dhcp/nm-dhcp-utils.c
@@ -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);
+}
diff --git a/src/dhcp/nm-dhcp-utils.h b/src/dhcp/nm-dhcp-utils.h
index ecb91809be..c773262d80 100644
--- a/src/dhcp/nm-dhcp-utils.h
+++ b/src/dhcp/nm-dhcp-utils.h
@@ -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__ */
diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c
index 5904e8fc0b..0335b7617a 100644
--- a/src/nm-iface-helper.c
+++ b/src/nm-iface-helper.c
@@ -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;