all: add helper functions for nm_hash_update*()

By using a macro, we don't cast all the types to guint. Instead,
we use their native types directly. Hence, we don't need
nm_hash_update_uint64() nor nm_hash_update_ptr().
Also, for types smaller then guint like char, we save hashing
the all zero bytes.
This commit is contained in:
Thomas Haller
2017-10-16 12:38:16 +02:00
parent ee76b0979f
commit 2f56de7492
10 changed files with 425 additions and 259 deletions

View File

@@ -4006,7 +4006,7 @@ guint
_nm_utils_strstrdictkey_hash (gconstpointer a)
{
const NMUtilsStrStrDictKey *k = a;
const signed char *p;
const char *p;
NMHashState h;
nm_hash_init (&h, 76642997u);
@@ -4014,17 +4014,18 @@ _nm_utils_strstrdictkey_hash (gconstpointer a)
if (((int) k->type) & ~STRSTRDICTKEY_ALL_SET)
g_return_val_if_reached (0);
nm_hash_update_uint (&h, k->type);
nm_hash_update_val (&h, k->type);
if (k->type & STRSTRDICTKEY_ALL_SET) {
p = (void *) k->data;
for (; *p != '\0'; p++)
nm_hash_update_uint (&h, *p);
gsize n;
n = 0;
p = strchr (k->data, '\0');
if (k->type == STRSTRDICTKEY_ALL_SET) {
/* the key contains two strings. Continue... */
nm_hash_update_uint (&h, '\0');
for (p++; *p != '\0'; p++)
nm_hash_update_uint (&h, *p);
p = strchr (p + 1, '\0');
}
if (p != k->data)
nm_hash_update (&h, k->data, p - k->data);
}
}
return nm_hash_complete (&h);

View File

@@ -79,6 +79,41 @@ G_STATIC_ASSERT (sizeof (bool) <= sizeof (int));
/*****************************************************************************/
typedef struct _nm_packed {
int v0;
char v1;
double v2;
guint8 v3;
} TestHashStruct;
static void
_test_hash_struct (int v0, char v1, double v2, guint8 v3)
{
const TestHashStruct s = {
.v0 = v0,
.v1 = v1,
.v2 = v2,
.v3 = v3,
};
NMHashState h;
guint hh;
nm_hash_init (&h, 100);
nm_hash_update (&h, &s, sizeof (s));
hh = nm_hash_complete (&h);
nm_hash_init (&h, 100);
nm_hash_update_val (&h, v0);
nm_hash_update_val (&h, v1);
nm_hash_update_val (&h, v2);
nm_hash_update_val (&h, v3);
g_assert_cmpint (hh, ==, nm_hash_complete (&h));
nm_hash_init (&h, 100);
nm_hash_update_vals (&h, v0, v1, v2, v3);
g_assert_cmpint (hh, ==, nm_hash_complete (&h));
}
static guint
_test_hash_str (const char *str)
{
@@ -102,6 +137,34 @@ _test_hash_str (const char *str)
return v;
}
#define _test_hash_vals(type, ...) \
G_STMT_START { \
NMHashState h0, h1, h2, h3; \
const type v[] = { __VA_ARGS__ }; \
guint h; \
guint i; \
\
nm_hash_init (&h0, 10); \
nm_hash_init (&h1, 10); \
nm_hash_init (&h2, 10); \
nm_hash_init (&h3, 10); \
\
/* assert that it doesn't matter, whether we hash the values individually,
* or all at once, or via the convenience macros nm_hash_update_val()
* and nm_hash_update_vals(). */ \
for (i = 0; i < G_N_ELEMENTS (v); i++) { \
nm_hash_update (&h0, &v[i], sizeof (type)); \
nm_hash_update_val (&h1, v[i]); \
} \
nm_hash_update_vals (&h2, __VA_ARGS__); \
nm_hash_update (&h3, v, sizeof (v)); \
\
h = nm_hash_complete (&h0); \
g_assert_cmpint (h, ==, nm_hash_complete (&h1)); \
g_assert_cmpint (h, ==, nm_hash_complete (&h2)); \
g_assert_cmpint (h, ==, nm_hash_complete (&h3)); \
} G_STMT_END
static void
test_nm_hash (void)
{
@@ -109,6 +172,26 @@ test_nm_hash (void)
_test_hash_str ("a");
_test_hash_str ("aa");
_test_hash_str ("diceros bicornis longipes");
/* assert that nm_hash_update_vals() is the same as calling nm_hash_update_val() multiple times. */
_test_hash_vals (int, 1);
_test_hash_vals (int, 1, 2);
_test_hash_vals (int, 1, 2, 3);
_test_hash_vals (int, 1, 2, 3, 4);
_test_hash_vals (long, 1l);
_test_hash_vals (long, 1l, 2l, 3l, 4l, 5l);
_test_hash_struct (10, 'a', 5.4, 7);
_test_hash_struct (-10, '\0', -5.4e49, 255);
g_assert_cmpint (NM_HASH_COMBINE_BOOLS (guint8, 1, 0), ==, 0x002);
g_assert_cmpint (NM_HASH_COMBINE_BOOLS (guint8, 1, 1), ==, 0x003);
g_assert_cmpint (NM_HASH_COMBINE_BOOLS (guint8, 1, 1, 0, 0, 0, 0), ==, 0x030);
g_assert_cmpint (NM_HASH_COMBINE_BOOLS (guint8, 1, 1, 0, 0, 0, 1), ==, 0x031);
g_assert_cmpint (NM_HASH_COMBINE_BOOLS (guint8, 0, 0, 1, 1, 0, 0, 0, 1), ==, 0x031);
g_assert_cmpint (NM_HASH_COMBINE_BOOLS (guint16, 0, 0, 1, 1, 0, 0, 0, 1), ==, 0x031);
g_assert_cmpint (NM_HASH_COMBINE_BOOLS (guint16, 0, 0, 0, 1, 1, 0, 0, 0, 1), ==, 0x031);
g_assert_cmpint (NM_HASH_COMBINE_BOOLS (guint16, 1, 0, 0, 1, 1, 0, 0, 0, 1), ==, 0x131);
}
/*****************************************************************************/

View File

@@ -183,13 +183,13 @@ _dict_idx_entries_hash (const NMDedupMultiEntry *entry)
nm_hash_init (&h, 1914869417u);
if (idx_type->klass->idx_obj_partition_hash) {
nm_assert (obj);
nm_hash_update_uint (&h, idx_type->klass->idx_obj_partition_hash (idx_type, obj));
nm_hash_update_val (&h, idx_type->klass->idx_obj_partition_hash (idx_type, obj));
}
if (!lookup_head)
nm_hash_update_uint (&h, idx_type->klass->idx_obj_id_hash (idx_type, obj));
nm_hash_update_val (&h, idx_type->klass->idx_obj_id_hash (idx_type, obj));
nm_hash_update_ptr (&h, idx_type);
nm_hash_update_val (&h, idx_type);
return nm_hash_complete (&h);
}

View File

@@ -23,10 +23,13 @@
#define __NM_HASH_UTILS_H__
#include "siphash24.h"
#include "nm-macros-internal.h"
typedef struct {
struct _NMHashState {
struct siphash _state;
} NMHashState;
};
typedef struct _NMHashState NMHashState;
void nm_hash_init (NMHashState *state, guint static_seed);
@@ -55,23 +58,101 @@ nm_hash_update (NMHashState *state, const void *ptr, gsize n)
siphash24_compress (ptr, n, &state->_state);
}
#define nm_hash_update_val(state, val) \
G_STMT_START { \
typeof (val) _val = (val); \
\
nm_hash_update ((state), &_val, sizeof (_val)); \
} G_STMT_END
static inline void
nm_hash_update_uint (NMHashState *state, guint val)
nm_hash_update_bool (NMHashState *state, bool val)
{
nm_hash_update (state, &val, sizeof (val));
}
static inline void
nm_hash_update_uint64 (NMHashState *state, guint64 val)
{
nm_hash_update (state, &val, sizeof (val));
}
#define _NM_HASH_COMBINE_BOOLS_x_1( t, y) ((y) ? ((t) (1ull << 0)) : ((t) 0ull))
#define _NM_HASH_COMBINE_BOOLS_x_2( t, y, ...) ((y) ? ((t) (1ull << 1)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_1 (t, __VA_ARGS__)
#define _NM_HASH_COMBINE_BOOLS_x_3( t, y, ...) ((y) ? ((t) (1ull << 2)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_2 (t, __VA_ARGS__)
#define _NM_HASH_COMBINE_BOOLS_x_4( t, y, ...) ((y) ? ((t) (1ull << 3)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_3 (t, __VA_ARGS__)
#define _NM_HASH_COMBINE_BOOLS_x_5( t, y, ...) ((y) ? ((t) (1ull << 4)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_4 (t, __VA_ARGS__)
#define _NM_HASH_COMBINE_BOOLS_x_6( t, y, ...) ((y) ? ((t) (1ull << 5)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_5 (t, __VA_ARGS__)
#define _NM_HASH_COMBINE_BOOLS_x_7( t, y, ...) ((y) ? ((t) (1ull << 6)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_6 (t, __VA_ARGS__)
#define _NM_HASH_COMBINE_BOOLS_x_8( t, y, ...) ((y) ? ((t) (1ull << 7)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_7 (t, __VA_ARGS__)
#define _NM_HASH_COMBINE_BOOLS_x_9( t, y, ...) ((y) ? ((t) (1ull << 8)) : ((t) 0ull)) | (G_STATIC_ASSERT_EXPR (sizeof (t) >= 2), (_NM_HASH_COMBINE_BOOLS_x_8 (t, __VA_ARGS__)))
#define _NM_HASH_COMBINE_BOOLS_x_10(t, y, ...) ((y) ? ((t) (1ull << 9)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_9 (t, __VA_ARGS__)
#define _NM_HASH_COMBINE_BOOLS_x_11(t, y, ...) ((y) ? ((t) (1ull << 10)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_10 (t, __VA_ARGS__)
#define _NM_HASH_COMBINE_BOOLS_n2(t, n, ...) _NM_HASH_COMBINE_BOOLS_x_##n (t, __VA_ARGS__)
#define _NM_HASH_COMBINE_BOOLS_n(t, n, ...) _NM_HASH_COMBINE_BOOLS_n2(t, n, __VA_ARGS__)
static inline void
nm_hash_update_ptr (NMHashState *state, gconstpointer ptr)
{
nm_hash_update (state, &ptr, sizeof (ptr));
}
#define NM_HASH_COMBINE_BOOLS(type, ...) ((type) (_NM_HASH_COMBINE_BOOLS_n(type, NM_NARG (__VA_ARGS__), __VA_ARGS__)))
#define nm_hash_update_bools(state, ...) \
nm_hash_update_val (state, NM_HASH_COMBINE_BOOLS (guint8, __VA_ARGS__))
#define _NM_HASH_COMBINE_VALS_typ_x_1( y) typeof (y) _v1;
#define _NM_HASH_COMBINE_VALS_typ_x_2( y, ...) typeof (y) _v2; _NM_HASH_COMBINE_VALS_typ_x_1 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_3( y, ...) typeof (y) _v3; _NM_HASH_COMBINE_VALS_typ_x_2 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_4( y, ...) typeof (y) _v4; _NM_HASH_COMBINE_VALS_typ_x_3 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_5( y, ...) typeof (y) _v5; _NM_HASH_COMBINE_VALS_typ_x_4 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_6( y, ...) typeof (y) _v6; _NM_HASH_COMBINE_VALS_typ_x_5 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_7( y, ...) typeof (y) _v7; _NM_HASH_COMBINE_VALS_typ_x_6 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_8( y, ...) typeof (y) _v8; _NM_HASH_COMBINE_VALS_typ_x_7 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_9( y, ...) typeof (y) _v9; _NM_HASH_COMBINE_VALS_typ_x_8 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_10(y, ...) typeof (y) _v10; _NM_HASH_COMBINE_VALS_typ_x_9 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_11(y, ...) typeof (y) _v11; _NM_HASH_COMBINE_VALS_typ_x_10 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_12(y, ...) typeof (y) _v12; _NM_HASH_COMBINE_VALS_typ_x_11 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_13(y, ...) typeof (y) _v13; _NM_HASH_COMBINE_VALS_typ_x_12 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_14(y, ...) typeof (y) _v14; _NM_HASH_COMBINE_VALS_typ_x_13 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_15(y, ...) typeof (y) _v15; _NM_HASH_COMBINE_VALS_typ_x_14 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_16(y, ...) typeof (y) _v16; _NM_HASH_COMBINE_VALS_typ_x_15 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_17(y, ...) typeof (y) _v17; _NM_HASH_COMBINE_VALS_typ_x_16 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_18(y, ...) typeof (y) _v18; _NM_HASH_COMBINE_VALS_typ_x_17 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_19(y, ...) typeof (y) _v19; _NM_HASH_COMBINE_VALS_typ_x_18 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_x_20(y, ...) typeof (y) _v20; _NM_HASH_COMBINE_VALS_typ_x_19 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_n2(n, ...) _NM_HASH_COMBINE_VALS_typ_x_##n (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_typ_n(n, ...) _NM_HASH_COMBINE_VALS_typ_n2(n, __VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_1( y) ._v1 = (y),
#define _NM_HASH_COMBINE_VALS_val_x_2( y, ...) ._v2 = (y), _NM_HASH_COMBINE_VALS_val_x_1 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_3( y, ...) ._v3 = (y), _NM_HASH_COMBINE_VALS_val_x_2 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_4( y, ...) ._v4 = (y), _NM_HASH_COMBINE_VALS_val_x_3 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_5( y, ...) ._v5 = (y), _NM_HASH_COMBINE_VALS_val_x_4 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_6( y, ...) ._v6 = (y), _NM_HASH_COMBINE_VALS_val_x_5 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_7( y, ...) ._v7 = (y), _NM_HASH_COMBINE_VALS_val_x_6 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_8( y, ...) ._v8 = (y), _NM_HASH_COMBINE_VALS_val_x_7 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_9( y, ...) ._v9 = (y), _NM_HASH_COMBINE_VALS_val_x_8 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_10(y, ...) ._v10 = (y), _NM_HASH_COMBINE_VALS_val_x_9 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_11(y, ...) ._v11 = (y), _NM_HASH_COMBINE_VALS_val_x_10 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_12(y, ...) ._v12 = (y), _NM_HASH_COMBINE_VALS_val_x_11 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_13(y, ...) ._v13 = (y), _NM_HASH_COMBINE_VALS_val_x_12 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_14(y, ...) ._v14 = (y), _NM_HASH_COMBINE_VALS_val_x_13 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_15(y, ...) ._v15 = (y), _NM_HASH_COMBINE_VALS_val_x_14 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_16(y, ...) ._v16 = (y), _NM_HASH_COMBINE_VALS_val_x_15 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_17(y, ...) ._v17 = (y), _NM_HASH_COMBINE_VALS_val_x_16 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_18(y, ...) ._v18 = (y), _NM_HASH_COMBINE_VALS_val_x_17 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_19(y, ...) ._v19 = (y), _NM_HASH_COMBINE_VALS_val_x_18 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_x_20(y, ...) ._v20 = (y), _NM_HASH_COMBINE_VALS_val_x_19 (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_n2(n, ...) _NM_HASH_COMBINE_VALS_val_x_##n (__VA_ARGS__)
#define _NM_HASH_COMBINE_VALS_val_n(n, ...) _NM_HASH_COMBINE_VALS_val_n2(n, __VA_ARGS__)
/* NM_HASH_COMBINE_VALS() is faster then nm_hash_update_val() as it combines multiple
* calls to nm_hash_update() using a packed structure. */
#define NM_HASH_COMBINE_VALS(var, ...) \
const struct _nm_packed { \
_NM_HASH_COMBINE_VALS_typ_n (NM_NARG (__VA_ARGS__), __VA_ARGS__) \
} var _nm_alignas (guint64) = { \
_NM_HASH_COMBINE_VALS_val_n (NM_NARG (__VA_ARGS__), __VA_ARGS__) \
}
/* nm_hash_update_vals() is faster then nm_hash_update_val() as it combines multiple
* calls to nm_hash_update() using a packed structure. */
#define nm_hash_update_vals(state, ...) \
G_STMT_START { \
NM_HASH_COMBINE_VALS (_val, __VA_ARGS__); \
\
nm_hash_update ((state), &_val, sizeof (_val)); \
} G_STMT_END
static inline void
nm_hash_update_mem (NMHashState *state, const void *ptr, gsize n)

View File

@@ -2861,8 +2861,8 @@ _v4_has_shadowed_routes_detect_hash (const IP4RPFilterData *d)
NMHashState h;
nm_hash_init (&h, 1105201169u);
nm_hash_update_uint (&h, d->network);
nm_hash_update_uint (&h, d->plen);
nm_hash_update_val (&h, d->network);
nm_hash_update_val (&h, d->plen);
return nm_hash_complete (&h);
}

View File

@@ -279,8 +279,9 @@ lldp_neighbor_id_hash (gconstpointer ptr)
nm_hash_init (&h, 23423423u);
nm_hash_update_str0 (&h, neigh->chassis_id);
nm_hash_update_str0 (&h, neigh->port_id);
nm_hash_update_uint (&h, neigh->chassis_id_type);
nm_hash_update_uint (&h, neigh->port_id_type);
nm_hash_update_vals (&h,
neigh->chassis_id_type,
neigh->port_id_type);
return nm_hash_complete (&h);
}

View File

@@ -186,18 +186,6 @@ nm_utils_exp10 (gint16 ex)
/*****************************************************************************/
guint
nm_utils_in6_addr_hash (const struct in6_addr *addr)
{
NMHashState h;
nm_hash_init (&h, 3675559913u);
nm_hash_update_in6addr (&h, addr);
return nm_hash_complete (&h);
}
/*****************************************************************************/
/*
* nm_ethernet_address_is_valid:
* @addr: pointer to a binary or ASCII Ethernet address

View File

@@ -92,8 +92,6 @@ GETTER (void) \
/*****************************************************************************/
guint nm_utils_in6_addr_hash (const struct in6_addr *addr);
gboolean nm_ethernet_address_is_valid (gconstpointer addr, gssize len);
gconstpointer nm_utils_ipx_address_clear_host_address (int family, gpointer dst, gconstpointer src, guint8 plen);
@@ -131,7 +129,9 @@ nm_utils_ip6_address_same_prefix (const struct in6_addr *addr_a, const struct in
static inline void
nm_hash_update_in6addr (NMHashState *h, const struct in6_addr *addr)
{
nm_hash_update_mem (h, addr, addr ? sizeof (*addr) : 0);
nm_assert (addr);
nm_hash_update (h, addr, sizeof (*addr));
}
static inline void
@@ -139,8 +139,7 @@ nm_hash_update_in6addr_prefix (NMHashState *h, const struct in6_addr *addr, guin
{
struct in6_addr a;
if (!addr)
g_return_if_reached ();
nm_assert (addr);
nm_utils_ip6_address_clear_host_address (&a, addr, plen);
/* we don't hash plen itself. The caller may want to do that.*/

View File

@@ -5129,26 +5129,29 @@ nm_platform_link_hash (const NMPlatformLink *obj)
NMHashState h;
nm_hash_init (&h, 99413953u);
nm_hash_update_uint (&h, obj->ifindex);
nm_hash_update_uint (&h, obj->type);
nm_hash_update_vals (&h,
obj->ifindex,
obj->master,
obj->parent);
nm_hash_update_val (&h, obj->type);
nm_hash_update_strarr (&h, obj->name);
nm_hash_update_uint (&h, obj->master);
nm_hash_update_uint (&h, obj->parent);
nm_hash_update_uint (&h, obj->n_ifi_flags);
nm_hash_update_uint (&h, obj->connected);
nm_hash_update_uint (&h, obj->mtu);
nm_hash_update_uint (&h, !!obj->initialized);
nm_hash_update_uint (&h, obj->arptype);
nm_hash_update_uint (&h, obj->addr.len);
nm_hash_update_uint (&h, obj->inet6_addr_gen_mode_inv);
nm_hash_update_vals (&h,
obj->n_ifi_flags,
obj->mtu);
nm_hash_update_bools (&h, obj->connected,
obj->initialized);
nm_hash_update_val (&h, obj->arptype);
nm_hash_update_val (&h, obj->inet6_addr_gen_mode_inv);
nm_hash_update_str0 (&h, obj->kind);
nm_hash_update_str0 (&h, obj->driver);
/* nm_hash_update_mem() also hashes the length obj->addr.len */
nm_hash_update_mem (&h, obj->addr.data, obj->addr.len);
nm_hash_update_mem (&h, &obj->inet6_token, sizeof (obj->inet6_token));
nm_hash_update_uint (&h, obj->rx_packets);
nm_hash_update_uint (&h, obj->rx_bytes);
nm_hash_update_uint (&h, obj->tx_packets);
nm_hash_update_uint (&h, obj->tx_bytes);
nm_hash_update (&h, &obj->inet6_token, sizeof (obj->inet6_token));
nm_hash_update_vals (&h,
obj->rx_packets,
obj->rx_bytes,
obj->tx_packets,
obj->tx_bytes);
return nm_hash_complete (&h);
}
@@ -5186,16 +5189,16 @@ nm_platform_lnk_gre_hash (const NMPlatformLnkGre *obj)
NMHashState h;
nm_hash_init (&h, 1887023311u);
nm_hash_update_uint (&h, obj->parent_ifindex);
nm_hash_update_uint (&h, obj->input_flags);
nm_hash_update_uint (&h, obj->output_flags);
nm_hash_update_uint (&h, obj->input_key);
nm_hash_update_uint (&h, obj->output_key);
nm_hash_update_uint (&h, obj->local);
nm_hash_update_uint (&h, obj->remote);
nm_hash_update_uint (&h, obj->ttl);
nm_hash_update_uint (&h, obj->tos);
nm_hash_update_uint (&h, !obj->path_mtu_discovery);
nm_hash_update_val (&h, obj->parent_ifindex);
nm_hash_update_val (&h, obj->input_flags);
nm_hash_update_val (&h, obj->output_flags);
nm_hash_update_val (&h, obj->input_key);
nm_hash_update_val (&h, obj->output_key);
nm_hash_update_val (&h, obj->local);
nm_hash_update_val (&h, obj->remote);
nm_hash_update_val (&h, obj->ttl);
nm_hash_update_val (&h, obj->tos);
nm_hash_update_bool (&h, obj->path_mtu_discovery);
return nm_hash_complete (&h);
}
@@ -5222,7 +5225,7 @@ nm_platform_lnk_infiniband_hash (const NMPlatformLnkInfiniband *obj)
NMHashState h;
nm_hash_init (&h, 1748638583u);
nm_hash_update_uint (&h, obj->p_key);
nm_hash_update_val (&h, obj->p_key);
nm_hash_update_str0 (&h, obj->mode);
return nm_hash_complete (&h);
}
@@ -5242,14 +5245,14 @@ nm_platform_lnk_ip6tnl_hash (const NMPlatformLnkIp6Tnl *obj)
NMHashState h;
nm_hash_init (&h, 1651660009u);
nm_hash_update_uint (&h, obj->parent_ifindex);
nm_hash_update_val (&h, obj->parent_ifindex);
nm_hash_update_in6addr (&h, &obj->local);
nm_hash_update_in6addr (&h, &obj->remote);
nm_hash_update_uint (&h, obj->ttl);
nm_hash_update_uint (&h, obj->tclass);
nm_hash_update_uint (&h, obj->encap_limit);
nm_hash_update_uint (&h, obj->flow_label);
nm_hash_update_uint (&h, obj->proto);
nm_hash_update_val (&h, obj->ttl);
nm_hash_update_val (&h, obj->tclass);
nm_hash_update_val (&h, obj->encap_limit);
nm_hash_update_val (&h, obj->flow_label);
nm_hash_update_val (&h, obj->proto);
return nm_hash_complete (&h);
}
@@ -5274,12 +5277,12 @@ nm_platform_lnk_ipip_hash (const NMPlatformLnkIpIp *obj)
NMHashState h;
nm_hash_init (&h, 861934429u);
nm_hash_update_uint (&h, obj->parent_ifindex);
nm_hash_update_uint (&h, obj->local);
nm_hash_update_uint (&h, obj->remote);
nm_hash_update_uint (&h, obj->ttl);
nm_hash_update_uint (&h, obj->tos);
nm_hash_update_uint (&h, obj->path_mtu_discovery);
nm_hash_update_val (&h, obj->parent_ifindex);
nm_hash_update_val (&h, obj->local);
nm_hash_update_val (&h, obj->remote);
nm_hash_update_val (&h, obj->ttl);
nm_hash_update_val (&h, obj->tos);
nm_hash_update_bool (&h, obj->path_mtu_discovery);
return nm_hash_complete (&h);
}
@@ -5302,19 +5305,21 @@ nm_platform_lnk_macsec_hash (const NMPlatformLnkMacsec *obj)
NMHashState h;
nm_hash_init (&h, 226984267u);
nm_hash_update_uint (&h, obj->parent_ifindex);
nm_hash_update_uint (&h, obj->sci);
nm_hash_update_uint64 (&h, obj->icv_length);
nm_hash_update_uint64 (&h, obj->cipher_suite);
nm_hash_update_uint (&h, obj->window);
nm_hash_update_uint (&h, obj->encoding_sa);
nm_hash_update_uint (&h, obj->validation);
nm_hash_update_uint (&h, obj->encrypt);
nm_hash_update_uint (&h, obj->protect);
nm_hash_update_uint (&h, obj->include_sci);
nm_hash_update_uint (&h, obj->es);
nm_hash_update_uint (&h, obj->scb);
nm_hash_update_uint (&h, obj->replay_protect);
nm_hash_update_val (&h, obj->parent_ifindex);
nm_hash_update_val (&h, obj->window);
nm_hash_update_vals (&h,
obj->cipher_suite,
obj->sci);
nm_hash_update_vals (&h,
obj->icv_length,
obj->encoding_sa,
obj->validation);
nm_hash_update_bools (&h, obj->encrypt,
obj->protect,
obj->include_sci,
obj->es,
obj->scb,
obj->replay_protect);
return nm_hash_complete (&h);
}
@@ -5344,9 +5349,9 @@ nm_platform_lnk_macvlan_hash (const NMPlatformLnkMacvlan *obj)
NMHashState h;
nm_hash_init (&h, 771014989u);
nm_hash_update_uint (&h, obj->mode);
nm_hash_update_uint (&h, obj->no_promisc);
nm_hash_update_uint (&h, obj->tap);
nm_hash_update_val (&h, obj->mode);
nm_hash_update_bools (&h, obj->no_promisc,
obj->tap);
return nm_hash_complete (&h);
}
@@ -5366,14 +5371,14 @@ nm_platform_lnk_sit_hash (const NMPlatformLnkSit *obj)
NMHashState h;
nm_hash_init (&h, 1690154969u);
nm_hash_update_uint (&h, obj->parent_ifindex);
nm_hash_update_uint (&h, obj->local);
nm_hash_update_uint (&h, obj->remote);
nm_hash_update_uint (&h, obj->ttl);
nm_hash_update_uint (&h, obj->tos);
nm_hash_update_uint (&h, obj->path_mtu_discovery);
nm_hash_update_uint (&h, obj->flags);
nm_hash_update_uint (&h, obj->proto);
nm_hash_update_val (&h, obj->parent_ifindex);
nm_hash_update_val (&h, obj->local);
nm_hash_update_val (&h, obj->remote);
nm_hash_update_val (&h, obj->ttl);
nm_hash_update_val (&h, obj->tos);
nm_hash_update_bool (&h, obj->path_mtu_discovery);
nm_hash_update_val (&h, obj->flags);
nm_hash_update_val (&h, obj->proto);
return nm_hash_complete (&h);
}
@@ -5398,8 +5403,8 @@ nm_platform_lnk_vlan_hash (const NMPlatformLnkVlan *obj)
NMHashState h;
nm_hash_init (&h, 58751383u);
nm_hash_update_uint (&h, obj->id);
nm_hash_update_uint (&h, obj->flags);
nm_hash_update_val (&h, obj->id);
nm_hash_update_val (&h, obj->flags);
return nm_hash_complete (&h);
}
@@ -5418,24 +5423,24 @@ nm_platform_lnk_vxlan_hash (const NMPlatformLnkVxlan *obj)
NMHashState h;
nm_hash_init (&h, 461041297u);
nm_hash_update_uint (&h, obj->parent_ifindex);
nm_hash_update_uint (&h, obj->id);
nm_hash_update_uint (&h, obj->group);
nm_hash_update_uint (&h, obj->local);
nm_hash_update_val (&h, obj->parent_ifindex);
nm_hash_update_val (&h, obj->id);
nm_hash_update_val (&h, obj->group);
nm_hash_update_val (&h, obj->local);
nm_hash_update_in6addr (&h, &obj->group6);
nm_hash_update_in6addr (&h, &obj->local6);
nm_hash_update_uint (&h, obj->tos);
nm_hash_update_uint (&h, obj->ttl);
nm_hash_update_uint (&h, obj->learning);
nm_hash_update_uint (&h, obj->ageing);
nm_hash_update_uint (&h, obj->limit);
nm_hash_update_uint (&h, obj->dst_port);
nm_hash_update_uint (&h, obj->src_port_min);
nm_hash_update_uint (&h, obj->src_port_max);
nm_hash_update_uint (&h, obj->proxy);
nm_hash_update_uint (&h, obj->rsc);
nm_hash_update_uint (&h, obj->l2miss);
nm_hash_update_uint (&h, obj->l3miss);
nm_hash_update_val (&h, obj->tos);
nm_hash_update_val (&h, obj->ttl);
nm_hash_update_val (&h, obj->ageing);
nm_hash_update_val (&h, obj->limit);
nm_hash_update_val (&h, obj->dst_port);
nm_hash_update_val (&h, obj->src_port_min);
nm_hash_update_val (&h, obj->src_port_max);
nm_hash_update_bools (&h, obj->learning,
obj->proxy,
obj->rsc,
obj->l2miss,
obj->l3miss);
return nm_hash_complete (&h);
}
@@ -5471,15 +5476,15 @@ nm_platform_ip4_address_hash (const NMPlatformIP4Address *obj)
nm_hash_init (&h, 469681301u);
if (obj) {
nm_hash_update_uint (&h, obj->ifindex);
nm_hash_update_uint (&h, obj->address);
nm_hash_update_uint (&h, obj->plen);
nm_hash_update_uint (&h, obj->peer_address);
nm_hash_update_uint (&h, obj->addr_source);
nm_hash_update_uint (&h, obj->timestamp);
nm_hash_update_uint (&h, obj->lifetime);
nm_hash_update_uint (&h, obj->preferred);
nm_hash_update_uint (&h, obj->n_ifa_flags);
nm_hash_update_val (&h, obj->ifindex);
nm_hash_update_val (&h, obj->address);
nm_hash_update_val (&h, obj->plen);
nm_hash_update_val (&h, obj->peer_address);
nm_hash_update_val (&h, obj->addr_source);
nm_hash_update_val (&h, obj->timestamp);
nm_hash_update_val (&h, obj->lifetime);
nm_hash_update_val (&h, obj->preferred);
nm_hash_update_val (&h, obj->n_ifa_flags);
nm_hash_update_strarr (&h, obj->label);
}
return nm_hash_complete (&h);
@@ -5509,15 +5514,15 @@ nm_platform_ip6_address_hash (const NMPlatformIP6Address *obj)
nm_hash_init (&h, 605908909u);
if (obj) {
nm_hash_update_uint (&h, obj->ifindex);
nm_hash_update_val (&h, obj->ifindex);
nm_hash_update_in6addr (&h, &obj->address);
nm_hash_update_uint (&h, obj->plen);
nm_hash_update_val (&h, obj->plen);
nm_hash_update_in6addr (&h, &obj->peer_address);
nm_hash_update_uint (&h, obj->addr_source);
nm_hash_update_uint (&h, obj->timestamp);
nm_hash_update_uint (&h, obj->lifetime);
nm_hash_update_uint (&h, obj->preferred);
nm_hash_update_uint (&h, obj->n_ifa_flags);
nm_hash_update_val (&h, obj->addr_source);
nm_hash_update_val (&h, obj->timestamp);
nm_hash_update_val (&h, obj->lifetime);
nm_hash_update_val (&h, obj->preferred);
nm_hash_update_val (&h, obj->n_ifa_flags);
}
return nm_hash_complete (&h);
}
@@ -5548,70 +5553,72 @@ nm_platform_ip4_route_hash (const NMPlatformIP4Route *obj, NMPlatformIPRouteCmpT
NMHashState h;
nm_hash_init (&h, 1228913327u);
nm_hash_update_uint (&h, cmp_type);
nm_hash_update_val (&h, cmp_type);
if (obj) {
switch (cmp_type) {
case NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID:
case NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID:
nm_hash_update_uint (&h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
nm_hash_update_uint (&h, nm_utils_ip4_address_clear_host_address (obj->network, obj->plen));
nm_hash_update_uint (&h, obj->plen);
nm_hash_update_uint (&h, obj->metric);
nm_hash_update_uint (&h, obj->tos);
nm_hash_update_val (&h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
nm_hash_update_val (&h, nm_utils_ip4_address_clear_host_address (obj->network, obj->plen));
nm_hash_update_val (&h, obj->plen);
nm_hash_update_val (&h, obj->metric);
nm_hash_update_val (&h, obj->tos);
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) {
nm_hash_update_uint (&h, obj->ifindex);
nm_hash_update_uint (&h, nmp_utils_ip_config_source_round_trip_rtprot (obj->rt_source));
nm_hash_update_uint (&h, _ip_route_scope_inv_get_normalized (obj));
nm_hash_update_uint (&h, obj->gateway);
nm_hash_update_uint (&h, obj->mss);
nm_hash_update_uint (&h, obj->pref_src);
nm_hash_update_uint (&h, obj->window);
nm_hash_update_uint (&h, obj->cwnd);
nm_hash_update_uint (&h, obj->initcwnd);
nm_hash_update_uint (&h, obj->initrwnd);
nm_hash_update_uint (&h, obj->mtu);
nm_hash_update_uint (&h, obj->lock_window);
nm_hash_update_uint (&h, obj->lock_cwnd);
nm_hash_update_uint (&h, obj->lock_initcwnd);
nm_hash_update_uint (&h, obj->lock_initrwnd);
nm_hash_update_uint (&h, obj->lock_mtu);
nm_hash_update_val (&h, obj->ifindex);
nm_hash_update_val (&h, nmp_utils_ip_config_source_round_trip_rtprot (obj->rt_source));
nm_hash_update_val (&h, _ip_route_scope_inv_get_normalized (obj));
nm_hash_update_val (&h, obj->gateway);
nm_hash_update_val (&h, obj->mss);
nm_hash_update_val (&h, obj->pref_src);
nm_hash_update_vals (&h,
obj->window,
obj->cwnd,
obj->initcwnd,
obj->initrwnd,
obj->mtu);
nm_hash_update_bools (&h, obj->lock_window,
obj->lock_cwnd,
obj->lock_initcwnd,
obj->lock_initrwnd,
obj->lock_mtu);
}
break;
case NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY:
case NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL:
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY)
nm_hash_update_uint (&h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
nm_hash_update_val (&h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
else
nm_hash_update_uint (&h, obj->table_coerced);
nm_hash_update_uint (&h, obj->ifindex);
nm_hash_update_val (&h, obj->table_coerced);
nm_hash_update_val (&h, obj->ifindex);
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY)
nm_hash_update_uint (&h, nm_utils_ip4_address_clear_host_address (obj->network, obj->plen));
nm_hash_update_val (&h, nm_utils_ip4_address_clear_host_address (obj->network, obj->plen));
else
nm_hash_update_uint (&h, obj->network);
nm_hash_update_uint (&h, obj->plen);
nm_hash_update_uint (&h, obj->metric);
nm_hash_update_uint (&h, obj->gateway);
nm_hash_update_val (&h, obj->network);
nm_hash_update_val (&h, obj->plen);
nm_hash_update_val (&h, obj->metric);
nm_hash_update_val (&h, obj->gateway);
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY) {
nm_hash_update_uint (&h, nmp_utils_ip_config_source_round_trip_rtprot (obj->rt_source));
nm_hash_update_uint (&h, _ip_route_scope_inv_get_normalized (obj));
nm_hash_update_val (&h, nmp_utils_ip_config_source_round_trip_rtprot (obj->rt_source));
nm_hash_update_val (&h, _ip_route_scope_inv_get_normalized (obj));
} else {
nm_hash_update_uint (&h, obj->rt_source);
nm_hash_update_uint (&h, obj->scope_inv);
nm_hash_update_val (&h, obj->rt_source);
nm_hash_update_val (&h, obj->scope_inv);
}
nm_hash_update_uint (&h, obj->mss);
nm_hash_update_uint (&h, obj->pref_src);
nm_hash_update_uint (&h, obj->rt_cloned);
nm_hash_update_uint (&h, obj->tos);
nm_hash_update_uint (&h, obj->lock_window);
nm_hash_update_uint (&h, obj->lock_cwnd);
nm_hash_update_uint (&h, obj->lock_initcwnd);
nm_hash_update_uint (&h, obj->lock_initrwnd);
nm_hash_update_uint (&h, obj->lock_mtu);
nm_hash_update_uint (&h, obj->window);
nm_hash_update_uint (&h, obj->cwnd);
nm_hash_update_uint (&h, obj->initcwnd);
nm_hash_update_uint (&h, obj->initrwnd);
nm_hash_update_uint (&h, obj->mtu);
nm_hash_update_val (&h, obj->tos);
nm_hash_update_vals (&h,
obj->mss,
obj->pref_src,
obj->window,
obj->cwnd,
obj->initcwnd,
obj->initrwnd,
obj->mtu);
nm_hash_update_bools (&h, obj->rt_cloned,
obj->lock_window,
obj->lock_cwnd,
obj->lock_initcwnd,
obj->lock_initrwnd,
obj->lock_mtu);
break;
}
}
@@ -5701,65 +5708,65 @@ nm_platform_ip6_route_hash (const NMPlatformIP6Route *obj, NMPlatformIPRouteCmpT
NMHashState h;
nm_hash_init (&h, 1053326051u);
nm_hash_update_uint (&h, cmp_type);
nm_hash_update_val (&h, cmp_type);
if (obj) {
switch (cmp_type) {
case NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID:
case NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID:
nm_hash_update_uint (&h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
nm_hash_update_val (&h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
nm_hash_update_in6addr_prefix (&h, &obj->network, obj->plen);
nm_hash_update_uint (&h, obj->plen);
nm_hash_update_uint (&h, nm_utils_ip6_route_metric_normalize (obj->metric));
nm_hash_update_val (&h, obj->plen);
nm_hash_update_val (&h, nm_utils_ip6_route_metric_normalize (obj->metric));
nm_hash_update_in6addr_prefix (&h, &obj->src, obj->src_plen);
nm_hash_update_uint (&h, obj->src_plen);
nm_hash_update_val (&h, obj->src_plen);
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) {
nm_hash_update_uint (&h, obj->ifindex);
nm_hash_update_val (&h, obj->ifindex);
nm_hash_update_in6addr (&h, &obj->gateway);
}
break;
case NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY:
case NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL:
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY)
nm_hash_update_uint (&h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
nm_hash_update_val (&h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
else
nm_hash_update_uint (&h, obj->table_coerced);
nm_hash_update_uint (&h, obj->ifindex);
nm_hash_update_val (&h, obj->table_coerced);
nm_hash_update_val (&h, obj->ifindex);
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY)
nm_hash_update_in6addr_prefix (&h, &obj->network, obj->plen);
else
nm_hash_update_in6addr (&h, &obj->network);
nm_hash_update_uint (&h, obj->plen);
nm_hash_update_val (&h, obj->plen);
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY)
nm_hash_update_uint (&h, nm_utils_ip6_route_metric_normalize (obj->metric));
nm_hash_update_val (&h, nm_utils_ip6_route_metric_normalize (obj->metric));
else
nm_hash_update_uint (&h, obj->metric);
nm_hash_update_val (&h, obj->metric);
nm_hash_update_in6addr (&h, &obj->gateway);
nm_hash_update_in6addr (&h, &obj->pref_src);
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY) {
nm_hash_update_in6addr_prefix (&h, &obj->src, obj->src_plen);
nm_hash_update_uint (&h, obj->src_plen);
nm_hash_update_uint (&h, nmp_utils_ip_config_source_round_trip_rtprot (obj->rt_source));
nm_hash_update_val (&h, obj->src_plen);
nm_hash_update_val (&h, nmp_utils_ip_config_source_round_trip_rtprot (obj->rt_source));
} else {
nm_hash_update_in6addr (&h, &obj->src);
nm_hash_update_uint (&h, obj->src_plen);
nm_hash_update_uint (&h, obj->rt_source);
nm_hash_update_val (&h, obj->src_plen);
nm_hash_update_val (&h, obj->rt_source);
}
nm_hash_update_uint (&h, obj->mss);
nm_hash_update_uint (&h, obj->rt_cloned);
nm_hash_update_uint (&h, obj->lock_window);
nm_hash_update_uint (&h, obj->lock_cwnd);
nm_hash_update_uint (&h, obj->lock_initcwnd);
nm_hash_update_uint (&h, obj->lock_initrwnd);
nm_hash_update_uint (&h, obj->lock_mtu);
nm_hash_update_uint (&h, obj->window);
nm_hash_update_uint (&h, obj->cwnd);
nm_hash_update_uint (&h, obj->initcwnd);
nm_hash_update_uint (&h, obj->initrwnd);
nm_hash_update_uint (&h, obj->mtu);
nm_hash_update_val (&h, obj->mss);
nm_hash_update_bools (&h, obj->rt_cloned,
obj->lock_window,
obj->lock_cwnd,
obj->lock_initcwnd,
obj->lock_initrwnd,
obj->lock_mtu);
nm_hash_update_val (&h, obj->window);
nm_hash_update_val (&h, obj->cwnd);
nm_hash_update_val (&h, obj->initcwnd);
nm_hash_update_val (&h, obj->initrwnd);
nm_hash_update_val (&h, obj->mtu);
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY)
nm_hash_update_uint (&h, _route_pref_normalize (obj->rt_pref));
nm_hash_update_val (&h, _route_pref_normalize (obj->rt_pref));
else
nm_hash_update_uint (&h, obj->rt_pref);
nm_hash_update_val (&h, obj->rt_pref);
break;
}
}

View File

@@ -162,8 +162,9 @@ _idx_obj_part (const DedupMultiIdxType *idx_type,
NMHashState h;
nm_hash_init (&h, 487703243u);
nm_hash_update_uint (&h, idx_type->cache_id_type);
nm_hash_update_uint (&h, NMP_OBJECT_GET_TYPE (obj_a));
nm_hash_update_vals (&h,
idx_type->cache_id_type,
NMP_OBJECT_GET_TYPE (obj_a));
return _HASH_NON_ZERO (&h);
}
return 1;
@@ -185,7 +186,7 @@ _idx_obj_part (const DedupMultiIdxType *idx_type,
/* we request a hash from obj_a. Hash the relevant parts. */
nm_hash_init (&h, 2126752699u);
nm_hash_update_uint (&h, idx_type->cache_id_type);
nm_hash_update_val (&h, idx_type->cache_id_type);
nm_hash_update_strarr (&h, obj_a->link.name);
return _HASH_NON_ZERO (&h);
}
@@ -207,8 +208,9 @@ _idx_obj_part (const DedupMultiIdxType *idx_type,
NMHashState h;
nm_hash_init (&h, 4278960223u);
nm_hash_update_uint (&h, idx_type->cache_id_type);
nm_hash_update_uint (&h, NMP_OBJECT_GET_TYPE (obj_a));
nm_hash_update_vals (&h,
idx_type->cache_id_type,
NMP_OBJECT_GET_TYPE (obj_a));
return _HASH_NON_ZERO (&h);
}
return 1;
@@ -230,9 +232,9 @@ _idx_obj_part (const DedupMultiIdxType *idx_type,
NMHashState h;
nm_hash_init (&h, 920415631u);
nm_hash_update_uint (&h, idx_type->cache_id_type);
nm_hash_update_uint (&h, NMP_OBJECT_GET_TYPE (obj_a));
nm_hash_update_uint (&h, obj_a->object.ifindex);
nm_hash_update_vals (&h,
idx_type->cache_id_type,
obj_a->object.ifindex);
return _HASH_NON_ZERO (&h);
}
return 1;
@@ -252,13 +254,16 @@ _idx_obj_part (const DedupMultiIdxType *idx_type,
}
if (request_hash) {
NMHashState h;
guint h2;
h2 = (obj_type == NMP_OBJECT_TYPE_IP4_ROUTE)
? nm_platform_ip4_route_hash (&obj_a->ip4_route, NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID)
: nm_platform_ip6_route_hash (&obj_a->ip6_route, NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID);
nm_hash_init (&h, 778646573u);
nm_hash_update_uint (&h, idx_type->cache_id_type);
if (obj_type == NMP_OBJECT_TYPE_IP4_ROUTE)
nm_hash_update_uint (&h, nm_platform_ip4_route_hash (&obj_a->ip4_route, NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID));
else
nm_hash_update_uint (&h, nm_platform_ip6_route_hash (&obj_a->ip6_route, NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID));
nm_hash_update_vals (&h,
idx_type->cache_id_type,
h2);
return _HASH_NON_ZERO (&h);
}
return 1;
@@ -325,13 +330,12 @@ _vlan_xgress_qos_mappings_hash_update (guint n_map,
const NMVlanQosMapping *map,
NMHashState *h)
{
guint i;
/* ensure no padding. */
G_STATIC_ASSERT (sizeof (NMVlanQosMapping) == 2 * sizeof (guint32));
nm_hash_update_uint (h, 1453577309u);
for (i = 0; i < n_map; i++) {
nm_hash_update_uint (h, map[i].from);
nm_hash_update_uint (h, map[i].to);
}
nm_hash_update_val (h, n_map);
if (n_map)
nm_hash_update (h, map, n_map * sizeof (*map));
}
static int
@@ -781,13 +785,13 @@ nmp_object_hash (const NMPObject *obj)
klass = NMP_OBJECT_GET_CLASS (obj);
nm_hash_init (&h, 816200863u);
nm_hash_update_uint (&h, klass->obj_type);
nm_hash_update_val (&h, klass->obj_type);
if (klass->cmd_obj_hash)
nm_hash_update_uint (&h, klass->cmd_obj_hash (obj));
nm_hash_update_val (&h, klass->cmd_obj_hash (obj));
else if (klass->cmd_plobj_hash)
nm_hash_update_uint (&h, klass->cmd_plobj_hash (&obj->object));
nm_hash_update_val (&h, klass->cmd_plobj_hash (&obj->object));
else
nm_hash_update_ptr (&h, obj);
nm_hash_update_val (&h, obj);
return nm_hash_complete (&h);
}
@@ -800,11 +804,11 @@ _vt_cmd_obj_hash_link (const NMPObject *obj)
nm_assert (NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_LINK);
nm_hash_init (&h, 3448776161u);
nm_hash_update_uint (&h, nm_platform_link_hash (&obj->link));
nm_hash_update_uint (&h, obj->_link.netlink.is_in_netlink);
nm_hash_update_val (&h, nm_platform_link_hash (&obj->link));
nm_hash_update_val (&h, obj->_link.netlink.is_in_netlink);
if (obj->_link.netlink.lnk)
nm_hash_update_uint (&h, nmp_object_hash (obj->_link.netlink.lnk));
nm_hash_update_ptr (&h, obj->_link.udev.device);
nm_hash_update_val (&h, nmp_object_hash (obj->_link.netlink.lnk));
nm_hash_update_val (&h, obj->_link.udev.device);
return nm_hash_complete (&h);
}
@@ -816,7 +820,7 @@ _vt_cmd_obj_hash_lnk_vlan (const NMPObject *obj)
nm_assert (NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_LNK_VLAN);
nm_hash_init (&h, 914932607u);
nm_hash_update_uint (&h, nm_platform_lnk_vlan_hash (&obj->lnk_vlan));
nm_hash_update_val (&h, nm_platform_lnk_vlan_hash (&obj->lnk_vlan));
_vlan_xgress_qos_mappings_hash_update (obj->_lnk_vlan.n_ingress_qos_map,
obj->_lnk_vlan.ingress_qos_map,
&h);
@@ -1125,25 +1129,27 @@ _vt_cmd_plobj_id_hash_##type (const NMPlatformObject *_obj) \
return nm_hash_complete (&h); \
}
_vt_cmd_plobj_id_hash (link, NMPlatformLink, 3982791431u, {
nm_hash_update_uint (&h, obj->ifindex);
nm_hash_update_val (&h, obj->ifindex);
})
_vt_cmd_plobj_id_hash (ip4_address, NMPlatformIP4Address, 3591309853u, {
nm_hash_update_uint (&h, obj->ifindex);
nm_hash_update_uint (&h, obj->plen);
nm_hash_update_uint (&h, obj->address);
/* for IPv4 we must also consider the net-part of the peer-address (IFA_ADDRESS) */
nm_hash_update_uint (&h, nm_utils_ip4_address_clear_host_address (obj->peer_address, obj->plen));
nm_hash_update_vals (&h,
obj->ifindex,
obj->plen,
obj->address,
/* for IPv4 we must also consider the net-part of the peer-address (IFA_ADDRESS) */
nm_utils_ip4_address_clear_host_address (obj->peer_address, obj->plen));
})
_vt_cmd_plobj_id_hash (ip6_address, NMPlatformIP6Address, 2907861637u, {
nm_hash_update_uint (&h, obj->ifindex);
/* for IPv6 addresses, the prefix length is not part of the primary identifier. */
nm_hash_update_in6addr (&h, &obj->address);
nm_hash_update_vals (&h,
obj->ifindex,
/* for IPv6 addresses, the prefix length is not part of the primary identifier. */
obj->address);
})
_vt_cmd_plobj_id_hash (ip4_route, NMPlatformIP4Route, 1038302471u, {
nm_hash_update_uint (&h, nm_platform_ip4_route_hash (obj, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID));
nm_hash_update_val (&h, nm_platform_ip4_route_hash (obj, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID));
})
_vt_cmd_plobj_id_hash (ip6_route, NMPlatformIP6Route, 1233384151u, {
nm_hash_update_uint (&h, nm_platform_ip6_route_hash (obj, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID));
nm_hash_update_val (&h, nm_platform_ip6_route_hash (obj, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID));
})
gboolean