mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-20 23:20:36 +01:00
all: merge branch 'th/nm-hash-all'
https://github.com/NetworkManager/NetworkManager/pull/36
This commit is contained in:
commit
27089f4759
50 changed files with 156 additions and 116 deletions
|
|
@ -460,7 +460,6 @@ libnm_core_lib_c_real = \
|
|||
shared/nm-utils/nm-shared-utils.c \
|
||||
shared/nm-utils/nm-random-utils.c \
|
||||
shared/nm-utils/nm-udev-utils.c \
|
||||
shared/nm-utils/siphash24.c \
|
||||
shared/nm-meta-setting.c \
|
||||
libnm-core/crypto.c \
|
||||
libnm-core/nm-connection.c \
|
||||
|
|
@ -3131,7 +3130,7 @@ $(src_tests_test_utils_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
|
|||
|
||||
src_tests_test_systemd_CPPFLAGS = $(src_libsystemd_nm_la_cppflags)
|
||||
src_tests_test_systemd_SOURCES = \
|
||||
shared/nm-utils/siphash24.c \
|
||||
shared/nm-utils/nm-hash-utils.c \
|
||||
src/tests/test-systemd.c
|
||||
src_tests_test_systemd_LDADD = \
|
||||
src/libsystemd-nm.la \
|
||||
|
|
@ -3324,7 +3323,6 @@ clients_common_libnmc_base_la_SOURCES = \
|
|||
shared/nm-utils/nm-random-utils.h \
|
||||
shared/nm-utils/nm-shared-utils.c \
|
||||
shared/nm-utils/nm-shared-utils.h \
|
||||
shared/nm-utils/siphash24.c \
|
||||
shared/nm-utils/siphash24.h \
|
||||
\
|
||||
clients/common/nm-secret-agent-simple.c \
|
||||
|
|
@ -4578,6 +4576,8 @@ EXTRA_DIST += \
|
|||
shared/nm-utils/nm-vpn-plugin-macros.h \
|
||||
shared/nm-utils/nm-vpn-plugin-utils.c \
|
||||
shared/nm-utils/nm-vpn-plugin-utils.h \
|
||||
shared/nm-utils/siphash24.c \
|
||||
shared/nm-utils/siphash24.h \
|
||||
shared/nm-utils/unaligned.h \
|
||||
shared/nm-version-macros.h.in \
|
||||
\
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
#include "nm-vpn-helpers.h"
|
||||
#include "nm-client-utils.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,6 @@
|
|||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
|
||||
#include "nm-client-utils.h"
|
||||
#include "nm-vpn-helpers.h"
|
||||
#include "nm-meta-setting-access.h"
|
||||
|
|
@ -3310,7 +3308,7 @@ _dynamic_options_set (const NMMetaAbstractInfo *abstract_info,
|
|||
PropertyInfFlags v, v2;
|
||||
|
||||
if (G_UNLIKELY (!cache))
|
||||
cache = g_hash_table_new (NULL, NULL);
|
||||
cache = g_hash_table_new (nm_direct_hash, NULL);
|
||||
|
||||
if (g_hash_table_lookup_extended (cache, (gpointer) abstract_info, NULL, &p))
|
||||
v = GPOINTER_TO_UINT (p);
|
||||
|
|
|
|||
|
|
@ -36,8 +36,6 @@
|
|||
|
||||
#include "nm-client-utils.h"
|
||||
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
|
||||
#include "polkit-agent.h"
|
||||
#include "utils.h"
|
||||
#include "common.h"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
#include <arpa/inet.h>
|
||||
|
||||
#include "nm-common-macros.h"
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
#include "nm-utils/nm-enum-utils.h"
|
||||
|
||||
#include "NetworkManager.h"
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
|
||||
#include "NetworkManager.h"
|
||||
#include "nm-vpn-service-plugin.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@
|
|||
|
||||
#include "NetworkManager.h"
|
||||
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
|
||||
#include "nm-meta-setting-access.h"
|
||||
|
||||
#include "nm-utils/nm-test-utils.h"
|
||||
|
|
@ -104,7 +102,7 @@ test_client_meta_check (void)
|
|||
|
||||
if (info->valid_parts) {
|
||||
gsize i, l;
|
||||
gs_unref_hashtable GHashTable *dup = g_hash_table_new (NULL, NULL);
|
||||
gs_unref_hashtable GHashTable *dup = g_hash_table_new (nm_direct_hash, NULL);
|
||||
|
||||
l = NM_PTRARRAY_LEN (info->valid_parts);
|
||||
g_assert (l >= 2);
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#include "NetworkManager.h"
|
||||
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
|
||||
#include "nmtui.h"
|
||||
#include "nmt-connect-connection-list.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -587,7 +587,7 @@ nm_connection_diff (NMConnection *a,
|
|||
if (a == b)
|
||||
return TRUE;
|
||||
|
||||
diffs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
|
||||
diffs = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
|
||||
|
||||
/* Diff A to B, then B to A to capture keys in B that aren't in A */
|
||||
if (diff_one_connection (a, b, flags, FALSE, diffs))
|
||||
|
|
@ -1370,7 +1370,7 @@ nm_connection_verify_secrets (NMConnection *connection, GError **error)
|
|||
* @parameters: (allow-none) (element-type utf8 gpointer): a #GHashTable with
|
||||
* normalization parameters to allow customization of the normalization by providing
|
||||
* specific arguments. Unknown arguments will be ignored and the default will be
|
||||
* used. The keys must be strings, hashed by g_str_hash() and g_str_equal() functions.
|
||||
* used. The keys must be strings compared with g_str_equal() function.
|
||||
* The values are opaque and depend on the parameter name.
|
||||
* @modified: (out) (allow-none): outputs whether any settings were modified.
|
||||
* @error: location to store error, or %NULL. Contains the reason,
|
||||
|
|
@ -2716,7 +2716,7 @@ nm_connection_get_private (NMConnection *connection)
|
|||
priv, (GDestroyNotify) nm_connection_private_free);
|
||||
|
||||
priv->self = connection;
|
||||
priv->settings = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
|
||||
priv->settings = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, g_object_unref);
|
||||
}
|
||||
|
||||
return priv;
|
||||
|
|
|
|||
|
|
@ -763,7 +763,7 @@ read_hash_of_string (GKeyFile *file, NMSetting *setting, const char *key)
|
|||
if (NM_IS_SETTING_USER (setting)) {
|
||||
gs_unref_hashtable GHashTable *data = NULL;
|
||||
|
||||
data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
data = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||
for (iter = (const char *const*) keys; *iter; iter++) {
|
||||
gs_free char *to_free = NULL;
|
||||
char *value = NULL;
|
||||
|
|
|
|||
|
|
@ -892,7 +892,7 @@ nm_setting_bond_init (NMSettingBond *setting)
|
|||
{
|
||||
NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting);
|
||||
|
||||
priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
priv->options = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||
|
||||
/* Default values: */
|
||||
nm_setting_bond_add_option (setting, NM_SETTING_BOND_OPTION_MODE, "balance-rr");
|
||||
|
|
|
|||
|
|
@ -593,7 +593,7 @@ nm_ip_address_set_attribute (NMIPAddress *address, const char *name, GVariant *v
|
|||
g_return_if_fail (strcmp (name, "address") != 0 && strcmp (name, "prefix") != 0);
|
||||
|
||||
if (!address->attributes) {
|
||||
address->attributes = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
address->attributes = g_hash_table_new_full (nm_str_hash, g_str_equal,
|
||||
g_free, (GDestroyNotify) g_variant_unref);
|
||||
}
|
||||
|
||||
|
|
@ -1227,7 +1227,7 @@ nm_ip_route_set_attribute (NMIPRoute *route, const char *name, GVariant *value)
|
|||
&& strcmp (name, "next-hop") != 0 && strcmp (name, "metric") != 0);
|
||||
|
||||
if (!route->attributes) {
|
||||
route->attributes = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
route->attributes = g_hash_table_new_full (nm_str_hash, g_str_equal,
|
||||
g_free, (GDestroyNotify) g_variant_unref);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ nm_setting_user_check_val (const char *val, GError **error)
|
|||
static GHashTable *
|
||||
_create_data_hash (void)
|
||||
{
|
||||
return g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
return g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -722,8 +722,8 @@ nm_setting_vpn_init (NMSettingVpn *setting)
|
|||
{
|
||||
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
|
||||
|
||||
priv->data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
priv->secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, destroy_one_secret);
|
||||
priv->data = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||
priv->secrets = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, destroy_one_secret);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -829,7 +829,7 @@ nm_setting_wired_init (NMSettingWired *setting)
|
|||
{
|
||||
NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
|
||||
|
||||
priv->s390_options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
priv->s390_options = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||
|
||||
/* We use GArray rather than GPtrArray so it will automatically be NULL-terminated */
|
||||
priv->mac_address_blacklist = g_array_new (TRUE, FALSE, sizeof (char *));
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ _ensure_registered (void)
|
|||
{
|
||||
if (G_UNLIKELY (registered_settings == NULL)) {
|
||||
nm_g_type_init ();
|
||||
registered_settings = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
registered_settings = g_hash_table_new (nm_str_hash, g_str_equal);
|
||||
registered_settings_by_type = g_hash_table_new (_nm_gtype_hash, _nm_gtype_equal);
|
||||
}
|
||||
}
|
||||
|
|
@ -807,7 +807,7 @@ _nm_setting_new_from_dbus (GType setting_type,
|
|||
GVariant *entry, *entry_key;
|
||||
char *key;
|
||||
|
||||
keys = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
keys = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, NULL);
|
||||
|
||||
g_variant_iter_init (&iter, setting_dict);
|
||||
while ((entry = g_variant_iter_next_value (&iter))) {
|
||||
|
|
@ -1359,7 +1359,7 @@ nm_setting_diff (NMSetting *a,
|
|||
}
|
||||
|
||||
if (*results == NULL) {
|
||||
*results = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
*results = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, NULL);
|
||||
results_created = TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
#include "nm-utils/nm-jansson.h"
|
||||
#include "nm-utils/nm-enum-utils.h"
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
#include "nm-common-macros.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-setting-private.h"
|
||||
|
|
@ -145,7 +144,7 @@ init_lang_to_encodings_hash (void)
|
|||
if (G_UNLIKELY (langToEncodings5 == NULL)) {
|
||||
/* Five-letter codes */
|
||||
enc = (struct IsoLangToEncodings *) &isoLangEntries5[0];
|
||||
langToEncodings5 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
langToEncodings5 = g_hash_table_new (nm_str_hash, g_str_equal);
|
||||
while (enc->lang) {
|
||||
g_hash_table_insert (langToEncodings5, (gpointer) enc->lang,
|
||||
(gpointer) enc->encodings);
|
||||
|
|
@ -156,7 +155,7 @@ init_lang_to_encodings_hash (void)
|
|||
if (G_UNLIKELY (langToEncodings2 == NULL)) {
|
||||
/* Two-letter codes */
|
||||
enc = (struct IsoLangToEncodings *) &isoLangEntries2[0];
|
||||
langToEncodings2 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
langToEncodings2 = g_hash_table_new (nm_str_hash, g_str_equal);
|
||||
while (enc->lang) {
|
||||
g_hash_table_insert (langToEncodings2, (gpointer) enc->lang,
|
||||
(gpointer) enc->encodings);
|
||||
|
|
@ -513,7 +512,7 @@ _nm_utils_strdict_from_dbus (GVariant *dbus_value,
|
|||
const char *key, *value;
|
||||
GHashTable *hash;
|
||||
|
||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
hash = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||
g_variant_iter_init (&iter, dbus_value);
|
||||
while (g_variant_iter_next (&iter, "{&s&s}", &key, &value))
|
||||
g_hash_table_insert (hash, g_strdup (key), g_strdup (value));
|
||||
|
|
@ -528,7 +527,7 @@ _nm_utils_copy_strdict (GHashTable *strdict)
|
|||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
|
||||
copy = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
copy = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||
if (strdict) {
|
||||
g_hash_table_iter_init (&iter, strdict);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
|
|
@ -4862,7 +4861,7 @@ nm_utils_parse_variant_attributes (const char *string,
|
|||
g_return_val_if_fail (key_value_separator, NULL);
|
||||
g_return_val_if_fail (!error || !*error, NULL);
|
||||
|
||||
ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
|
||||
ht = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
|
||||
|
||||
while (TRUE) {
|
||||
gs_free char *name = NULL, *value = NULL;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "nm-utils/c-list-util.h"
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
|
||||
#include "nm-utils.h"
|
||||
#include "nm-setting-private.h"
|
||||
|
|
@ -168,6 +167,17 @@ _test_hash_str (const char *str)
|
|||
static void
|
||||
test_nm_hash (void)
|
||||
{
|
||||
g_assert (nm_hash_static (0));
|
||||
g_assert (nm_hash_static (777));
|
||||
|
||||
g_assert (nm_hash_str (NULL));
|
||||
g_assert (nm_hash_str (""));
|
||||
g_assert (nm_hash_str ("a"));
|
||||
|
||||
g_assert (nm_hash_ptr (NULL));
|
||||
g_assert (nm_hash_ptr (""));
|
||||
g_assert (nm_hash_ptr ("a"));
|
||||
|
||||
_test_hash_str ("");
|
||||
_test_hash_str ("a");
|
||||
_test_hash_str ("aa");
|
||||
|
|
@ -6088,7 +6098,7 @@ test_g_ptr_array_insert (void)
|
|||
static void
|
||||
test_g_hash_table_get_keys_as_array (void)
|
||||
{
|
||||
GHashTable *table = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
GHashTable *table = g_hash_table_new (nm_str_hash, g_str_equal);
|
||||
guint length = 0;
|
||||
char **keys;
|
||||
|
||||
|
|
@ -6742,7 +6752,7 @@ test_route_attributes_format (void)
|
|||
gs_unref_hashtable GHashTable *ht = NULL;
|
||||
char *str;
|
||||
|
||||
ht = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
ht = g_hash_table_new_full (nm_str_hash, g_str_equal,
|
||||
NULL, (GDestroyNotify) g_variant_unref);
|
||||
|
||||
str = nm_utils_format_variant_attributes (NULL, ' ', '=');
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ nm_client_init (NMClient *client)
|
|||
|
||||
priv->state = NM_STATE_UNKNOWN;
|
||||
|
||||
priv->permissions = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
priv->permissions = g_hash_table_new (NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -2570,7 +2570,7 @@ nm_lldp_neighbor_new (void)
|
|||
|
||||
neigh = g_new0 (NMLldpNeighbor, 1);
|
||||
neigh->refcount = 1;
|
||||
neigh->attrs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
|
||||
neigh->attrs = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free,
|
||||
(GDestroyNotify) g_variant_unref);
|
||||
|
||||
return neigh;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ nm_dhcp_config_init (NMDhcpConfig *config)
|
|||
{
|
||||
NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
priv->options = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ nm_manager_init (NMManager *manager)
|
|||
priv->state = NM_STATE_UNKNOWN;
|
||||
priv->connectivity = NM_CONNECTIVITY_UNKNOWN;
|
||||
|
||||
priv->permissions = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
priv->permissions = g_hash_table_new (nm_direct_hash, NULL);
|
||||
priv->devices = g_ptr_array_new ();
|
||||
priv->all_devices = g_ptr_array_new ();
|
||||
priv->active_connections = g_ptr_array_new ();
|
||||
|
|
@ -1458,7 +1458,7 @@ checkpoint_rollback_cb (GObject *object,
|
|||
&variant,
|
||||
result,
|
||||
&error)) {
|
||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
hash = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, NULL);
|
||||
g_variant_iter_init (&iter, variant);
|
||||
while (g_variant_iter_next (&iter, "{&su}", &path, &r))
|
||||
g_hash_table_insert (hash, g_strdup (path), GUINT_TO_POINTER (r));
|
||||
|
|
|
|||
|
|
@ -955,7 +955,7 @@ _nm_object_register_properties (NMObject *object,
|
|||
G_CALLBACK (properties_changed), object);
|
||||
g_ptr_array_add (priv->proxies, proxy);
|
||||
|
||||
instance = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
instance = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||
priv->property_tables = g_slist_prepend (priv->property_tables, instance);
|
||||
|
||||
for (tmp = (NMPropertiesInfo *) info; tmp->name; tmp++) {
|
||||
|
|
|
|||
|
|
@ -728,8 +728,8 @@ nm_vpn_plugin_old_read_vpn_details (int fd,
|
|||
if (out_secrets)
|
||||
g_return_val_if_fail (*out_secrets == NULL, FALSE);
|
||||
|
||||
data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_secret);
|
||||
data = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||
secrets = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, free_secret);
|
||||
|
||||
line = g_string_new (NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -750,8 +750,8 @@ nm_vpn_service_plugin_read_vpn_details (int fd,
|
|||
if (out_secrets)
|
||||
g_return_val_if_fail (*out_secrets == NULL, FALSE);
|
||||
|
||||
data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_secret);
|
||||
data = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||
secrets = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, free_secret);
|
||||
|
||||
line = g_string_new (NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -178,6 +178,10 @@ _nm_g_return_if_fail_warning (const char *log_domain,
|
|||
#include "nm-utils/nm-macros-internal.h"
|
||||
#include "nm-utils/nm-shared-utils.h"
|
||||
|
||||
#if ((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY) == 0
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
#endif
|
||||
|
||||
#include "nm-version.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
#include "nm-shared-utils.h"
|
||||
#include "nm-random-utils.h"
|
||||
|
||||
#include "siphash24.c"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define HASH_KEY_SIZE 16u
|
||||
|
|
@ -35,33 +37,77 @@
|
|||
|
||||
G_STATIC_ASSERT (sizeof (guint) * HASH_KEY_SIZE_GUINT >= HASH_KEY_SIZE);
|
||||
|
||||
static const guint8 *volatile global_seed = NULL;
|
||||
|
||||
static const guint8 *
|
||||
_get_hash_key (void)
|
||||
_get_hash_key_init (void)
|
||||
{
|
||||
static const guint8 *volatile global_seed = NULL;
|
||||
/* the returned hash is aligned to guin64, hence, it is safe
|
||||
* to use it as guint* or guint64* pointer. */
|
||||
static union {
|
||||
guint8 v8[HASH_KEY_SIZE];
|
||||
} g_arr _nm_alignas (guint64);
|
||||
static gsize g_lock;
|
||||
const guint8 *g;
|
||||
struct siphash siph_state;
|
||||
uint64_t h;
|
||||
guint *p;
|
||||
|
||||
g = global_seed;
|
||||
if (G_UNLIKELY (g == NULL)) {
|
||||
/* the returned hash is aligned to guin64, hence, it is save
|
||||
* to use it as guint* or guint64* pointer. */
|
||||
static union {
|
||||
guint8 v8[HASH_KEY_SIZE];
|
||||
} g_arr _nm_alignas (guint64);
|
||||
static gsize g_lock;
|
||||
|
||||
if (g_once_init_enter (&g_lock)) {
|
||||
nm_utils_random_bytes (g_arr.v8, sizeof (g_arr.v8));
|
||||
g_atomic_pointer_compare_and_exchange (&global_seed, NULL, g_arr.v8);
|
||||
g = g_arr.v8;
|
||||
g_once_init_leave (&g_lock, 1);
|
||||
} else {
|
||||
g = global_seed;
|
||||
nm_assert (g);
|
||||
}
|
||||
if (G_LIKELY (g != NULL)) {
|
||||
nm_assert (g == g_arr.v8);
|
||||
return g;
|
||||
}
|
||||
|
||||
return g;
|
||||
if (g_once_init_enter (&g_lock)) {
|
||||
|
||||
nm_utils_random_bytes (g_arr.v8, sizeof (g_arr.v8));
|
||||
|
||||
/* use siphash() of the key-size, to mangle the first guint. Otherwise,
|
||||
* the first guint has only the entropy that nm_utils_random_bytes()
|
||||
* generated for the first 4 bytes and relies on a good random generator. */
|
||||
siphash24_init (&siph_state, g_arr.v8);
|
||||
siphash24_compress (g_arr.v8, sizeof (g_arr.v8), &siph_state);
|
||||
h = siphash24_finalize (&siph_state);
|
||||
p = (guint *) g_arr.v8;
|
||||
if (sizeof (guint) < sizeof (h))
|
||||
*p = *p ^ ((guint) (h & 0xFFFFFFFFu)) ^ ((guint) (h >> 32));
|
||||
else
|
||||
*p = *p ^ ((guint) (h & 0xFFFFFFFFu));
|
||||
|
||||
g_atomic_pointer_compare_and_exchange (&global_seed, NULL, g_arr.v8);
|
||||
g_once_init_leave (&g_lock, 1);
|
||||
}
|
||||
|
||||
nm_assert (global_seed == g_arr.v8);
|
||||
return g_arr.v8;
|
||||
}
|
||||
|
||||
#define _get_hash_key() \
|
||||
({ \
|
||||
const guint8 *_g; \
|
||||
\
|
||||
_g = global_seed; \
|
||||
if (G_UNLIKELY (_g == NULL)) \
|
||||
_g = _get_hash_key_init (); \
|
||||
_g; \
|
||||
})
|
||||
|
||||
guint
|
||||
nm_hash_static (guint static_seed)
|
||||
{
|
||||
/* note that we only xor the static_seed with the key.
|
||||
* We don't use siphash24(), which would mix the bits better.
|
||||
* Note that this doesn't matter, because static_seed is not
|
||||
* supposed to be a value that you are hashing (for that, use
|
||||
* full siphash24()).
|
||||
* Instead, different callers may set a different static_seed
|
||||
* so that nm_hash_str(NULL) != nm_hash_ptr(NULL).
|
||||
*
|
||||
* Also, ensure that we don't return zero.
|
||||
*/
|
||||
return ((*((const guint *) _get_hash_key ())) ^ static_seed)
|
||||
?: static_seed ?: 3679500967u;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -83,11 +129,10 @@ nm_hash_str (const char *str)
|
|||
{
|
||||
NMHashState h;
|
||||
|
||||
if (str) {
|
||||
nm_hash_init (&h, 1867854211u);
|
||||
nm_hash_update_str (&h, str);
|
||||
} else
|
||||
nm_hash_init (&h, 842995561u);
|
||||
if (!str)
|
||||
return nm_hash_static (1867854211u);
|
||||
nm_hash_init (&h, 1867854211u);
|
||||
nm_hash_update_str (&h, str);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
|
|
@ -100,16 +145,13 @@ nm_str_hash (gconstpointer str)
|
|||
guint
|
||||
nm_hash_ptr (gconstpointer ptr)
|
||||
{
|
||||
guint h;
|
||||
NMHashState h;
|
||||
|
||||
h = ((const guint *) _get_hash_key ())[0];
|
||||
|
||||
if (sizeof (ptr) <= sizeof (guint))
|
||||
h = h ^ ((guint) ((uintptr_t) ptr));
|
||||
else
|
||||
h = h ^ ((guint) (((guint64) (uintptr_t) ptr) >> 32)) ^ ((guint) ((uintptr_t) ptr));
|
||||
|
||||
return h ?: 2907677551u;
|
||||
if (!ptr)
|
||||
return nm_hash_static (2907677551u);
|
||||
nm_hash_init (&h, 2907677551u);
|
||||
nm_hash_update (&h, &ptr, sizeof (ptr));
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
guint
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ struct _NMHashState {
|
|||
|
||||
typedef struct _NMHashState NMHashState;
|
||||
|
||||
guint nm_hash_static (guint static_seed);
|
||||
|
||||
void nm_hash_init (NMHashState *state, guint static_seed);
|
||||
|
||||
static inline guint
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
#include "nm-bluez-device.h"
|
||||
#include "nm-bluez-common.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
|
|
|||
|
|
@ -428,7 +428,7 @@ nm_arping_manager_init (NMArpingManager *self)
|
|||
{
|
||||
NMArpingManagerPrivate *priv = NM_ARPING_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
priv->addresses = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
priv->addresses = g_hash_table_new_full (nm_direct_hash, NULL,
|
||||
NULL, destroy_address_info);
|
||||
priv->state = STATE_INIT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ nm_device_factory_manager_load_factories (NMDeviceFactoryManagerFactoryFunc call
|
|||
g_return_if_fail (factories_by_link == NULL);
|
||||
g_return_if_fail (factories_by_setting == NULL);
|
||||
|
||||
factories_by_link = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref);
|
||||
factories_by_link = g_hash_table_new_full (nm_direct_hash, NULL, NULL, g_object_unref);
|
||||
factories_by_setting = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, (GDestroyNotify) factories_list_unref);
|
||||
|
||||
#define _ADD_INTERNAL(get_type_fcn) \
|
||||
|
|
|
|||
|
|
@ -6217,7 +6217,7 @@ shared4_new_config (NMDevice *self, NMConnection *connection)
|
|||
guint32 count = 0;
|
||||
|
||||
if (G_UNLIKELY (!shared_ips))
|
||||
shared_ips = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
shared_ips = g_hash_table_new (nm_direct_hash, NULL);
|
||||
else {
|
||||
while (g_hash_table_lookup (shared_ips, GUINT_TO_POINTER (start + count))) {
|
||||
count += ntohl (0x100);
|
||||
|
|
@ -12072,7 +12072,7 @@ nm_device_recheck_available_connections (NMDevice *self)
|
|||
priv = NM_DEVICE_GET_PRIVATE(self);
|
||||
|
||||
if (g_hash_table_size (priv->available_connections) > 0) {
|
||||
prune_list = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
prune_list = g_hash_table_new (nm_direct_hash, NULL);
|
||||
g_hash_table_iter_init (&h_iter, priv->available_connections);
|
||||
while (g_hash_table_iter_next (&h_iter, (gpointer *) &connection, NULL))
|
||||
g_hash_table_add (prune_list, connection);
|
||||
|
|
@ -14131,7 +14131,7 @@ nm_device_init (NMDevice *self)
|
|||
priv->rfkill_type = RFKILL_TYPE_UNKNOWN;
|
||||
priv->unmanaged_flags = NM_UNMANAGED_PLATFORM_INIT;
|
||||
priv->unmanaged_mask = priv->unmanaged_flags;
|
||||
priv->available_connections = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
|
||||
priv->available_connections = g_hash_table_new_full (nm_direct_hash, NULL, g_object_unref, NULL);
|
||||
priv->ip6_saved_properties = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, g_free);
|
||||
priv->sys_iface_state = NM_DEVICE_SYS_IFACE_STATE_EXTERNAL;
|
||||
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ nm_dhcp_listener_init (NMDhcpListener *self)
|
|||
NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self);
|
||||
|
||||
/* Maps GDBusConnection :: signal-id */
|
||||
priv->connections = g_hash_table_new (NULL, NULL);
|
||||
priv->connections = g_hash_table_new (nm_direct_hash, NULL);
|
||||
|
||||
priv->dbus_mgr = nm_bus_manager_get ();
|
||||
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ nm_dhcp_manager_init (NMDhcpManager *self)
|
|||
nm_log_info (LOGD_DHCP, "dhcp-init: Using DHCP client '%s'", client_factory->name);
|
||||
|
||||
priv->client_factory = client_factory;
|
||||
priv->clients = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
priv->clients = g_hash_table_new_full (nm_direct_hash, NULL,
|
||||
NULL,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
#include "nm-setting-connection.h"
|
||||
#include "nm-auth-subject.h"
|
||||
#include "nm-auth-manager.h"
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ private_server_new (const char *path,
|
|||
g_signal_connect (server, "new-connection",
|
||||
G_CALLBACK (private_server_new_connection), s);
|
||||
|
||||
s->obj_managers = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
s->obj_managers = g_hash_table_new_full (nm_direct_hash, NULL,
|
||||
(GDestroyNotify) private_server_manager_destroy,
|
||||
g_free);
|
||||
s->manager = manager;
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ nm_checkpoint_init (NMCheckpoint *self)
|
|||
{
|
||||
NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE (self);
|
||||
|
||||
priv->devices = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
priv->devices = g_hash_table_new_full (nm_direct_hash, NULL,
|
||||
NULL, device_checkpoint_destroy);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@
|
|||
#include <stdio.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
|
||||
#include "nm-connection.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -345,8 +345,8 @@ static void
|
|||
_ensure_requests (void)
|
||||
{
|
||||
if (G_UNLIKELY (requests == NULL)) {
|
||||
requests = g_hash_table_new_full (g_direct_hash,
|
||||
g_direct_equal,
|
||||
requests = g_hash_table_new_full (nm_direct_hash,
|
||||
NULL,
|
||||
NULL,
|
||||
(GDestroyNotify) dispatcher_info_free);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -501,8 +501,8 @@ nm_exported_object_create_skeletons (NMExportedObject *self,
|
|||
|
||||
ifdata->property_changed_signal_id = g_signal_lookup ("properties-changed", G_OBJECT_TYPE (ifdata->interface));
|
||||
|
||||
ifdata->pending_notifies = g_hash_table_new_full (g_direct_hash,
|
||||
g_direct_equal,
|
||||
ifdata->pending_notifies = g_hash_table_new_full (nm_direct_hash,
|
||||
NULL,
|
||||
NULL,
|
||||
(GDestroyNotify) g_variant_unref);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3016,7 +3016,7 @@ find_slaves (NMManager *manager,
|
|||
s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
|
||||
g_return_val_if_fail (s_con, NULL);
|
||||
|
||||
devices = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
devices = g_hash_table_new (nm_direct_hash, NULL);
|
||||
|
||||
/* Search through all connections, not only inactive ones, because
|
||||
* even if a slave was already active, it might be deactivated during
|
||||
|
|
@ -5105,7 +5105,7 @@ nm_manager_write_device_state (NMManager *self)
|
|||
gs_unref_hashtable GHashTable *seen_ifindexes = NULL;
|
||||
gint nm_owned;
|
||||
|
||||
seen_ifindexes = g_hash_table_new (NULL, NULL);
|
||||
seen_ifindexes = g_hash_table_new (nm_direct_hash, NULL);
|
||||
|
||||
for (devices = priv->devices; devices; devices = devices->next) {
|
||||
NMDevice *device = NM_DEVICE (devices->data);
|
||||
|
|
@ -6233,7 +6233,7 @@ nm_manager_init (NMManager *self)
|
|||
priv->timestamp_update_id = g_timeout_add_seconds (300, (GSourceFunc) periodic_update_active_connection_timestamps, self);
|
||||
|
||||
priv->metered = NM_METERED_UNKNOWN;
|
||||
priv->sleep_devices = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
priv->sleep_devices = g_hash_table_new (nm_direct_hash, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ device_ip6_prefix_delegated (NMDevice *device,
|
|||
/* Allocate a delegation delegation for new prefix. */
|
||||
g_array_set_size (priv->ip6_prefix_delegations, i + 1);
|
||||
delegation = &g_array_index (priv->ip6_prefix_delegations, IP6PrefixDelegation, i);
|
||||
delegation->subnets = g_hash_table_new (NULL, NULL);
|
||||
delegation->subnets = g_hash_table_new (nm_direct_hash, NULL);
|
||||
delegation->next_subnet = 0;
|
||||
}
|
||||
|
||||
|
|
@ -2484,8 +2484,8 @@ nm_policy_init (NMPolicy *self)
|
|||
else /* default - full mode */
|
||||
priv->hostname_mode = NM_POLICY_HOSTNAME_MODE_FULL;
|
||||
|
||||
priv->devices = g_hash_table_new (NULL, NULL);
|
||||
priv->pending_active_connections = g_hash_table_new (NULL, NULL);
|
||||
priv->devices = g_hash_table_new (nm_direct_hash, NULL);
|
||||
priv->pending_active_connections = g_hash_table_new (nm_direct_hash, NULL);
|
||||
priv->ip6_prefix_delegations = g_array_new (FALSE, FALSE, sizeof (IP6PrefixDelegation));
|
||||
g_array_set_clear_func (priv->ip6_prefix_delegations, clear_ip6_prefix_delegation);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ ck_init (NMSessionMonitor *monitor)
|
|||
|
||||
if (g_file_query_exists (file, NULL)) {
|
||||
if ((monitor->ck.monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &error))) {
|
||||
monitor->ck.cache = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
|
||||
monitor->ck.cache = g_hash_table_new_full (nm_direct_hash, NULL, NULL, g_free);
|
||||
g_signal_connect (monitor->ck.monitor,
|
||||
"changed",
|
||||
G_CALLBACK (ck_changed),
|
||||
|
|
|
|||
|
|
@ -6696,7 +6696,7 @@ nm_linux_platform_init (NMLinuxPlatform *self)
|
|||
priv->delayed_action.list_master_connected = g_ptr_array_new ();
|
||||
priv->delayed_action.list_refresh_link = g_ptr_array_new ();
|
||||
priv->delayed_action.list_wait_for_nl_response = g_array_new (FALSE, TRUE, sizeof (DelayedActionWaitForNlResponseData));
|
||||
priv->wifi_data = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) wifi_utils_deinit);
|
||||
priv->wifi_data = g_hash_table_new_full (nm_direct_hash, NULL, NULL, (GDestroyNotify) wifi_utils_deinit);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -594,7 +594,7 @@ nm_platform_link_get_all (NMPlatform *self, gboolean sort_by_name)
|
|||
* further by moving children/slaves to the end. */
|
||||
g_ptr_array_sort_with_data (links, _link_get_all_presort, GINT_TO_POINTER (sort_by_name));
|
||||
|
||||
unseen = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
unseen = g_hash_table_new (nm_direct_hash, NULL);
|
||||
for (i = 0; i < links->len; i++) {
|
||||
item = NMP_OBJECT_CAST_LINK (links->pdata[i]);
|
||||
nm_assert (item->ifindex > 0);
|
||||
|
|
@ -3175,7 +3175,7 @@ ip4_addr_subnets_build_index (const GPtrArray *addresses,
|
|||
|
||||
nm_assert (addresses && addresses->len);
|
||||
|
||||
subnets = g_hash_table_new (NULL, NULL);
|
||||
subnets = g_hash_table_new (nm_direct_hash, NULL);
|
||||
|
||||
/* Build a hash table of all addresses per subnet */
|
||||
for (i = 0; i < addresses->len; i++) {
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ nm_inotify_helper_init (NMInotifyHelper *self)
|
|||
{
|
||||
NMInotifyHelperPrivate *priv = NM_INOTIFY_HELPER_GET_PRIVATE (self);
|
||||
|
||||
priv->wd_refs = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
priv->wd_refs = g_hash_table_new (nm_direct_hash, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -515,7 +515,7 @@ read_connections (SettingsPluginIfcfg *plugin)
|
|||
return;
|
||||
}
|
||||
|
||||
alive_connections = g_hash_table_new (NULL, NULL);
|
||||
alive_connections = g_hash_table_new (nm_direct_hash, NULL);
|
||||
|
||||
filenames = g_ptr_array_new_with_free_func (g_free);
|
||||
while ((item = g_dir_read_name (dir))) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "nm-utils/nm-hash-utils.h"
|
||||
#include "settings/nm-settings-plugin.h"
|
||||
|
||||
#include "nms-ifnet-net-parser.h"
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@ read_connections (NMSettingsPlugin *config)
|
|||
return;
|
||||
}
|
||||
|
||||
alive_connections = g_hash_table_new (NULL, NULL);
|
||||
alive_connections = g_hash_table_new (nm_direct_hash, NULL);
|
||||
|
||||
filenames = g_ptr_array_new_with_free_func (g_free);
|
||||
while ((item = g_dir_read_name (dir))) {
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ test_nm_utils_array_remove_at_indexes (void)
|
|||
|
||||
idx = g_array_new (FALSE, FALSE, sizeof (guint));
|
||||
array = g_array_new (FALSE, FALSE, sizeof (gssize));
|
||||
unique = g_hash_table_new (NULL, NULL);
|
||||
unique = g_hash_table_new (nm_direct_hash, NULL);
|
||||
for (i_len = 1; i_len < 20; i_len++) {
|
||||
for (i_idx_len = 1; i_idx_len <= i_len; i_idx_len++) {
|
||||
for (i_rnd = 0; i_rnd < 20; i_rnd++) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue