mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 20:40:34 +01:00
all: refactor hashing by introducing NMHashState
The privious NM_HASH_* macros directly operated on a guint value and were thus close to the actual implementation. Replace them by adding a NMHashState struct and accessors to update the hash state. This hides the implementation better and would allow us to carry more state. For example, we could switch to siphash24() transparently. For now, we still do a form basically djb2 hashing, albeit with differing start seed. Also add nm_hash_str() and nm_str_hash(): - nm_hash_str() is our own string hashing implementation - nm_str_hash() is our own string implementation, but with a GHashFunc signature, suitable to pass it to g_hash_table_new(). Also, it has this name in order to remind you of g_str_hash(), which it is replacing.
This commit is contained in:
parent
281d2d9fad
commit
0e9e35e309
11 changed files with 556 additions and 358 deletions
|
|
@ -4007,27 +4007,27 @@ _nm_utils_strstrdictkey_hash (gconstpointer a)
|
|||
{
|
||||
const NMUtilsStrStrDictKey *k = a;
|
||||
const signed char *p;
|
||||
guint32 h = NM_HASH_INIT (76642997u);
|
||||
NMHashState h;
|
||||
|
||||
nm_hash_init (&h, 76642997u);
|
||||
if (k) {
|
||||
if (((int) k->type) & ~STRSTRDICTKEY_ALL_SET)
|
||||
g_return_val_if_reached (0);
|
||||
|
||||
h = NM_HASH_COMBINE (h, k->type);
|
||||
nm_hash_update_uint (&h, k->type);
|
||||
if (k->type & STRSTRDICTKEY_ALL_SET) {
|
||||
p = (void *) k->data;
|
||||
for (; *p != '\0'; p++)
|
||||
h = NM_HASH_COMBINE (h, *p);
|
||||
nm_hash_update_uint (&h, *p);
|
||||
if (k->type == STRSTRDICTKEY_ALL_SET) {
|
||||
/* the key contains two strings. Continue... */
|
||||
h = NM_HASH_COMBINE (h, '\0');
|
||||
nm_hash_update_uint (&h, '\0');
|
||||
for (p++; *p != '\0'; p++)
|
||||
h = NM_HASH_COMBINE (h, *p);
|
||||
nm_hash_update_uint (&h, *p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return h;
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#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"
|
||||
|
|
@ -78,6 +79,66 @@ G_STATIC_ASSERT (sizeof (bool) <= sizeof (int));
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static guint
|
||||
_test_hash_str (const char *str)
|
||||
{
|
||||
NMHashState h;
|
||||
guint v, v2;
|
||||
const guint SEED = 10;
|
||||
|
||||
nm_hash_init (&h, SEED);
|
||||
nm_hash_update_str (&h, str);
|
||||
v = nm_hash_complete (&h);
|
||||
|
||||
{
|
||||
/* assert that hashing a string and a buffer yields the
|
||||
* same result.
|
||||
*
|
||||
* I think that is a desirable property. */
|
||||
nm_hash_init (&h, SEED);
|
||||
nm_hash_update_mem (&h, str, str ? strlen (str) : 0);
|
||||
v2 = nm_hash_complete (&h);
|
||||
}
|
||||
g_assert (v == v2);
|
||||
return v;
|
||||
}
|
||||
|
||||
static void
|
||||
test_nm_hash (void)
|
||||
{
|
||||
NMHashState h;
|
||||
|
||||
_test_hash_str ("");
|
||||
_test_hash_str ("a");
|
||||
_test_hash_str ("aa");
|
||||
_test_hash_str ("diceros bicornis longipes");
|
||||
|
||||
memset (&h, 0, sizeof (h));
|
||||
g_assert_cmpint (nm_hash_complete (&h), ==, 1396707757u);
|
||||
|
||||
/* note how two different string still always hash the same,
|
||||
* although we use a global seed that we initialize each time
|
||||
* differently.
|
||||
*
|
||||
* The aim would be that two collisions depend on the seed value,
|
||||
* which they currently don't. */
|
||||
g_assert_cmpint (nm_hash_str ("BA"), ==, nm_hash_str ("Ab"));
|
||||
|
||||
/* with the current hasing algorighm, once we know two words that hash
|
||||
* the same, we can trivally find more collions by concatenating
|
||||
* them (which is bad). */
|
||||
g_assert_cmpint (nm_hash_str ("BABABA"), ==, nm_hash_str ("AbAbAb"));
|
||||
g_assert_cmpint (nm_hash_str ("BABABA"), ==, nm_hash_str ("AbAbBA"));
|
||||
g_assert_cmpint (nm_hash_str ("BABABA"), ==, nm_hash_str ("AbBAAb"));
|
||||
g_assert_cmpint (nm_hash_str ("BABABA"), ==, nm_hash_str ("AbBABA"));
|
||||
g_assert_cmpint (nm_hash_str ("BABABA"), ==, nm_hash_str ("BAAbAb"));
|
||||
g_assert_cmpint (nm_hash_str ("BABABA"), ==, nm_hash_str ("BAAbBA"));
|
||||
g_assert_cmpint (nm_hash_str ("BABABA"), ==, nm_hash_str ("BABAAb"));
|
||||
g_assert_cmpint (nm_hash_str ("BABABA"), ==, nm_hash_str ("BABABA"));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_nm_g_slice_free_fcn (void)
|
||||
{
|
||||
|
|
@ -6341,6 +6402,7 @@ int main (int argc, char **argv)
|
|||
{
|
||||
nmtst_init (&argc, &argv, TRUE);
|
||||
|
||||
g_test_add_func ("/core/general/test_nm_hash", test_nm_hash);
|
||||
g_test_add_func ("/core/general/test_nm_g_slice_free_fcn", test_nm_g_slice_free_fcn);
|
||||
g_test_add_func ("/core/general/test_c_list_sort", test_c_list_sort);
|
||||
g_test_add_func ("/core/general/test_dedup_multi", test_dedup_multi);
|
||||
|
|
|
|||
|
|
@ -176,21 +176,21 @@ _dict_idx_entries_hash (const NMDedupMultiEntry *entry)
|
|||
const NMDedupMultiIdxType *idx_type;
|
||||
const NMDedupMultiObj *obj;
|
||||
gboolean lookup_head;
|
||||
guint h;
|
||||
NMHashState h;
|
||||
|
||||
_entry_unpack (entry, &idx_type, &obj, &lookup_head);
|
||||
|
||||
nm_hash_init (&h, 1914869417u);
|
||||
if (idx_type->klass->idx_obj_partition_hash) {
|
||||
nm_assert (obj);
|
||||
h = idx_type->klass->idx_obj_partition_hash (idx_type, obj);
|
||||
} else
|
||||
h = NM_HASH_INIT (1914869417u);
|
||||
nm_hash_update_uint (&h, idx_type->klass->idx_obj_partition_hash (idx_type, obj));
|
||||
}
|
||||
|
||||
if (!lookup_head)
|
||||
h = NM_HASH_COMBINE (h, idx_type->klass->idx_obj_id_hash (idx_type, obj));
|
||||
nm_hash_update_uint (&h, idx_type->klass->idx_obj_id_hash (idx_type, obj));
|
||||
|
||||
h = NM_HASH_COMBINE (h, GPOINTER_TO_UINT (idx_type));
|
||||
return h;
|
||||
nm_hash_update_ptr (&h, idx_type);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -28,12 +28,14 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
guint
|
||||
NM_HASH_INIT (guint seed)
|
||||
void
|
||||
nm_hash_init (NMHashState *state, guint static_seed)
|
||||
{
|
||||
static volatile guint global_seed = 0;
|
||||
guint g, s;
|
||||
|
||||
nm_assert (state);
|
||||
|
||||
/* we xor @seed with a random @global_seed. This is to make the hashing behavior
|
||||
* less predictable and harder to exploit collisions. */
|
||||
g = global_seed;
|
||||
|
|
@ -46,5 +48,28 @@ NM_HASH_INIT (guint seed)
|
|||
nm_assert (g);
|
||||
}
|
||||
|
||||
return g ^ seed;
|
||||
s = g ^ static_seed;
|
||||
state->hash = s;
|
||||
}
|
||||
|
||||
guint
|
||||
nm_hash_str (const char *str)
|
||||
{
|
||||
NMHashState h;
|
||||
|
||||
nm_hash_init (&h, 1867854211u);
|
||||
nm_hash_update_str (&h, str);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
guint
|
||||
nm_str_hash (gconstpointer str)
|
||||
{
|
||||
return nm_hash_str (str);
|
||||
}
|
||||
|
||||
guint
|
||||
nm_direct_hash (gconstpointer ptr)
|
||||
{
|
||||
return nm_hash_ptr (ptr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,26 +22,107 @@
|
|||
#ifndef __NM_HASH_UTILS_H__
|
||||
#define __NM_HASH_UTILS_H__
|
||||
|
||||
guint NM_HASH_INIT (guint seed);
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
guint hash;
|
||||
} NMHashState;
|
||||
|
||||
void nm_hash_init (NMHashState *state, guint static_seed);
|
||||
|
||||
static inline guint
|
||||
NM_HASH_COMBINE (guint h, guint val)
|
||||
nm_hash_complete (NMHashState *state)
|
||||
{
|
||||
/* see g_str_hash() for reasons */
|
||||
return (h << 5) + h + val;
|
||||
nm_assert (state);
|
||||
/* we don't ever want to return a zero hash.
|
||||
*
|
||||
* NMPObject requires that in _idx_obj_part(), and it's just a good idea. */
|
||||
return state->hash ?: 1396707757u;
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_hash_update_uint (NMHashState *state, guint val)
|
||||
{
|
||||
guint h;
|
||||
|
||||
nm_assert (state);
|
||||
|
||||
h = state->hash;
|
||||
h = (h << 5) + h + val;
|
||||
state->hash = h;
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_hash_update_uint64 (NMHashState *state, guint64 val)
|
||||
{
|
||||
guint h;
|
||||
|
||||
nm_assert (state);
|
||||
|
||||
h = state->hash;
|
||||
h = (h << 5) + h + ((guint) val);
|
||||
h = (h << 5) + h + ((guint) (val >> 32));
|
||||
state->hash = h;
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_hash_update_ptr (NMHashState *state, gconstpointer ptr)
|
||||
{
|
||||
if (sizeof (ptr) <= sizeof (guint))
|
||||
nm_hash_update_uint (state, ((guint) ((uintptr_t) ptr)));
|
||||
else
|
||||
nm_hash_update_uint64 (state, (guint64) ((uintptr_t) ptr));
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_hash_update_mem (NMHashState *state, const void *ptr, gsize n)
|
||||
{
|
||||
gsize i;
|
||||
guint h;
|
||||
|
||||
nm_assert (state);
|
||||
|
||||
/* use the same hash seed as nm_hash_update_str().
|
||||
* That way, nm_hash_update_str(&h, s) is identical to
|
||||
* nm_hash_update_mem(&h, s, strlen(s)). */
|
||||
h = state->hash;
|
||||
for (i = 0; i < n; i++)
|
||||
h = (h << 5) + h + ((guint) ((const guint8 *) ptr)[i]);
|
||||
h = (h << 5) + h + 1774132687u;
|
||||
state->hash = h;
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_hash_update_str (NMHashState *state, const char *str)
|
||||
{
|
||||
const guint8 *p = (const guint8 *) str;
|
||||
guint8 c;
|
||||
guint h;
|
||||
|
||||
nm_assert (state);
|
||||
|
||||
/* Note that NULL hashes differently from "". */
|
||||
h = state->hash;
|
||||
if (str) {
|
||||
while ((c = *p++))
|
||||
h = (h << 5) + h + ((guint) c);
|
||||
h = (h << 5) + h + 1774132687u;
|
||||
} else
|
||||
h = (h << 5) + h + 2967906233u;
|
||||
state->hash = h;
|
||||
}
|
||||
|
||||
static inline guint
|
||||
NM_HASH_COMBINE_UINT64 (guint h, guint64 val)
|
||||
nm_hash_ptr (gconstpointer ptr)
|
||||
{
|
||||
return NM_HASH_COMBINE (h, (((guint) val) & 0xFFFFFFFFu) + ((guint) (val >> 32)));
|
||||
if (sizeof (ptr) <= sizeof (guint))
|
||||
return (guint) ((uintptr_t) ptr);
|
||||
else
|
||||
return ((guint) (((uintptr_t) ptr) >> 32)) ^ ((guint) ((uintptr_t) ptr));
|
||||
}
|
||||
guint nm_direct_hash (gconstpointer str);
|
||||
|
||||
static inline guint
|
||||
NM_HASH_POINTER (gconstpointer ptr)
|
||||
{
|
||||
/* same as g_direct_hash(), but inline. */
|
||||
return GPOINTER_TO_UINT (ptr);
|
||||
}
|
||||
guint nm_hash_str (const char *str);
|
||||
guint nm_str_hash (gconstpointer str);
|
||||
|
||||
#endif /* __NM_HASH_UTILS_H__ */
|
||||
|
|
|
|||
|
|
@ -2858,11 +2858,12 @@ typedef struct {
|
|||
static guint
|
||||
_v4_has_shadowed_routes_detect_hash (const IP4RPFilterData *d)
|
||||
{
|
||||
guint h = NM_HASH_INIT (1105201169u);
|
||||
NMHashState h;
|
||||
|
||||
h = NM_HASH_COMBINE (h, d->network);
|
||||
h = NM_HASH_COMBINE (h, d->plen);
|
||||
return h;
|
||||
nm_hash_init (&h, 1105201169u);
|
||||
nm_hash_update_uint (&h, d->network);
|
||||
nm_hash_update_uint (&h, d->plen);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -274,13 +274,14 @@ static guint
|
|||
lldp_neighbor_id_hash (gconstpointer ptr)
|
||||
{
|
||||
const LldpNeighbor *neigh = ptr;
|
||||
guint hash = NM_HASH_INIT (23423423u);
|
||||
NMHashState h;
|
||||
|
||||
hash = NM_HASH_COMBINE (hash, neigh->chassis_id ? g_str_hash (neigh->chassis_id) : 12321u);
|
||||
hash = NM_HASH_COMBINE (hash, neigh->port_id ? g_str_hash (neigh->port_id) : 34342343u);
|
||||
hash = NM_HASH_COMBINE (hash, neigh->chassis_id_type);
|
||||
hash = NM_HASH_COMBINE (hash, neigh->port_id_type);
|
||||
return hash;
|
||||
nm_hash_init (&h, 23423423u);
|
||||
nm_hash_update_str (&h, neigh->chassis_id);
|
||||
nm_hash_update_str (&h, neigh->port_id);
|
||||
nm_hash_update_uint (&h, neigh->chassis_id_type);
|
||||
nm_hash_update_uint (&h, neigh->port_id_type);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
|||
|
|
@ -189,12 +189,11 @@ nm_utils_exp10 (gint16 ex)
|
|||
guint
|
||||
nm_utils_in6_addr_hash (const struct in6_addr *addr)
|
||||
{
|
||||
guint hash = NM_HASH_INIT (3675559913u);
|
||||
int i;
|
||||
NMHashState h;
|
||||
|
||||
for (i = 0; i < sizeof (*addr); i++)
|
||||
hash = NM_HASH_COMBINE (hash, ((const guint8 *) addr)[i]);
|
||||
return hash;
|
||||
nm_hash_init (&h, 3675559913u);
|
||||
nm_hash_update_in6addr (&h, addr);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -128,24 +128,23 @@ nm_utils_ip6_address_same_prefix (const struct in6_addr *addr_a, const struct in
|
|||
#define NM_CMP_DIRECT_IN6ADDR_SAME_PREFIX(a, b, plen) \
|
||||
NM_CMP_RETURN (nm_utils_ip6_address_same_prefix_cmp ((a), (b), (plen)))
|
||||
|
||||
static inline guint
|
||||
NM_HASH_COMBINE_IN6ADDR (guint h, const struct in6_addr *addr)
|
||||
static inline void
|
||||
nm_hash_update_in6addr (NMHashState *h, const struct in6_addr *addr)
|
||||
{
|
||||
if (!addr)
|
||||
g_return_val_if_reached (h);
|
||||
return NM_HASH_COMBINE (h, nm_utils_in6_addr_hash (addr));
|
||||
nm_hash_update_mem (h, addr, addr ? sizeof (*addr) : 0);
|
||||
}
|
||||
|
||||
static inline guint
|
||||
NM_HASH_COMBINE_IN6ADDR_PREFIX (guint h, const struct in6_addr *addr, guint8 plen)
|
||||
static inline void
|
||||
nm_hash_update_in6addr_prefix (NMHashState *h, const struct in6_addr *addr, guint8 plen)
|
||||
{
|
||||
struct in6_addr a;
|
||||
|
||||
if (!addr)
|
||||
g_return_val_if_reached (h);
|
||||
g_return_if_reached ();
|
||||
|
||||
nm_utils_ip6_address_clear_host_address (&a, addr, plen);
|
||||
/* we don't hash plen itself. The caller may want to do that.*/
|
||||
return NM_HASH_COMBINE (h, nm_utils_in6_addr_hash (&a));
|
||||
nm_hash_update_in6addr (h, &a);
|
||||
}
|
||||
|
||||
double nm_utils_exp10 (gint16 e);
|
||||
|
|
|
|||
|
|
@ -5126,34 +5126,30 @@ nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route, char *buf, gsi
|
|||
guint
|
||||
nm_platform_link_hash (const NMPlatformLink *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (99413953u);
|
||||
guint8 i8;
|
||||
NMHashState h;
|
||||
|
||||
h = NM_HASH_COMBINE (h, obj->ifindex);
|
||||
h = NM_HASH_COMBINE (h, obj->type);
|
||||
h = NM_HASH_COMBINE (h, g_str_hash (obj->name));
|
||||
h = NM_HASH_COMBINE (h, obj->master);
|
||||
h = NM_HASH_COMBINE (h, obj->parent);
|
||||
h = NM_HASH_COMBINE (h, obj->n_ifi_flags);
|
||||
h = NM_HASH_COMBINE (h, obj->connected);
|
||||
h = NM_HASH_COMBINE (h, obj->mtu);
|
||||
h = NM_HASH_COMBINE (h, !!obj->initialized);
|
||||
h = NM_HASH_COMBINE (h, obj->arptype);
|
||||
h = NM_HASH_COMBINE (h, obj->addr.len);
|
||||
h = NM_HASH_COMBINE (h, obj->inet6_addr_gen_mode_inv);
|
||||
if (obj->kind)
|
||||
h = NM_HASH_COMBINE (h, g_str_hash (obj->kind));
|
||||
if (obj->driver)
|
||||
h = NM_HASH_COMBINE (h, g_str_hash (obj->driver));
|
||||
for (i8 = 0; i8 < obj->addr.len; i8++)
|
||||
h = NM_HASH_COMBINE (h, obj->addr.data[i8]);
|
||||
for (i8 = 0; i8 < sizeof (obj->inet6_token); i8++)
|
||||
h = NM_HASH_COMBINE (h, obj->inet6_token.id_u8[i8]);
|
||||
h = NM_HASH_COMBINE (h, obj->rx_packets);
|
||||
h = NM_HASH_COMBINE (h, obj->rx_bytes);
|
||||
h = NM_HASH_COMBINE (h, obj->tx_packets);
|
||||
h = NM_HASH_COMBINE (h, obj->tx_bytes);
|
||||
return h;
|
||||
nm_hash_init (&h, 99413953u);
|
||||
nm_hash_update_uint (&h, obj->ifindex);
|
||||
nm_hash_update_uint (&h, obj->type);
|
||||
nm_hash_update_str (&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_str (&h, obj->kind);
|
||||
nm_hash_update_str (&h, obj->driver);
|
||||
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);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -5187,19 +5183,20 @@ nm_platform_link_cmp (const NMPlatformLink *a, const NMPlatformLink *b)
|
|||
guint
|
||||
nm_platform_lnk_gre_hash (const NMPlatformLnkGre *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (1887023311u);
|
||||
NMHashState h;
|
||||
|
||||
h = NM_HASH_COMBINE (h, obj->parent_ifindex);
|
||||
h = NM_HASH_COMBINE (h, obj->input_flags);
|
||||
h = NM_HASH_COMBINE (h, obj->output_flags);
|
||||
h = NM_HASH_COMBINE (h, obj->input_key);
|
||||
h = NM_HASH_COMBINE (h, obj->output_key);
|
||||
h = NM_HASH_COMBINE (h, obj->local);
|
||||
h = NM_HASH_COMBINE (h, obj->remote);
|
||||
h = NM_HASH_COMBINE (h, obj->ttl);
|
||||
h = NM_HASH_COMBINE (h, obj->tos);
|
||||
h = NM_HASH_COMBINE (h, !obj->path_mtu_discovery);
|
||||
return 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);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -5222,12 +5219,13 @@ nm_platform_lnk_gre_cmp (const NMPlatformLnkGre *a, const NMPlatformLnkGre *b)
|
|||
guint
|
||||
nm_platform_lnk_infiniband_hash (const NMPlatformLnkInfiniband *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (1748638583u);
|
||||
NMHashState h;
|
||||
|
||||
h = NM_HASH_COMBINE (h, obj->p_key);
|
||||
nm_hash_init (&h, 1748638583u);
|
||||
nm_hash_update_uint (&h, obj->p_key);
|
||||
if (obj->mode)
|
||||
h = NM_HASH_COMBINE (h, g_str_hash (obj->mode));
|
||||
return h;
|
||||
nm_hash_update_str (&h, obj->mode);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -5242,17 +5240,18 @@ nm_platform_lnk_infiniband_cmp (const NMPlatformLnkInfiniband *a, const NMPlatfo
|
|||
guint
|
||||
nm_platform_lnk_ip6tnl_hash (const NMPlatformLnkIp6Tnl *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (1651660009u);
|
||||
NMHashState h;
|
||||
|
||||
h = NM_HASH_COMBINE (h, obj->parent_ifindex);
|
||||
h = NM_HASH_COMBINE_IN6ADDR (h, &obj->local);
|
||||
h = NM_HASH_COMBINE_IN6ADDR (h, &obj->remote);
|
||||
h = NM_HASH_COMBINE (h, obj->ttl);
|
||||
h = NM_HASH_COMBINE (h, obj->tclass);
|
||||
h = NM_HASH_COMBINE (h, obj->encap_limit);
|
||||
h = NM_HASH_COMBINE (h, obj->flow_label);
|
||||
h = NM_HASH_COMBINE (h, obj->proto);
|
||||
return h;
|
||||
nm_hash_init (&h, 1651660009u);
|
||||
nm_hash_update_uint (&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);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -5273,15 +5272,16 @@ nm_platform_lnk_ip6tnl_cmp (const NMPlatformLnkIp6Tnl *a, const NMPlatformLnkIp6
|
|||
guint
|
||||
nm_platform_lnk_ipip_hash (const NMPlatformLnkIpIp *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (861934429u);
|
||||
NMHashState h;
|
||||
|
||||
h = NM_HASH_COMBINE (h, obj->parent_ifindex);
|
||||
h = NM_HASH_COMBINE (h, obj->local);
|
||||
h = NM_HASH_COMBINE (h, obj->remote);
|
||||
h = NM_HASH_COMBINE (h, obj->ttl);
|
||||
h = NM_HASH_COMBINE (h, obj->tos);
|
||||
h = NM_HASH_COMBINE (h, obj->path_mtu_discovery);
|
||||
return 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);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -5300,22 +5300,23 @@ nm_platform_lnk_ipip_cmp (const NMPlatformLnkIpIp *a, const NMPlatformLnkIpIp *b
|
|||
guint
|
||||
nm_platform_lnk_macsec_hash (const NMPlatformLnkMacsec *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (226984267u);
|
||||
NMHashState h;
|
||||
|
||||
h = NM_HASH_COMBINE (h, obj->parent_ifindex);
|
||||
h = NM_HASH_COMBINE (h, obj->sci);
|
||||
h = NM_HASH_COMBINE_UINT64 (h, obj->icv_length);
|
||||
h = NM_HASH_COMBINE_UINT64 (h, obj->cipher_suite);
|
||||
h = NM_HASH_COMBINE (h, obj->window);
|
||||
h = NM_HASH_COMBINE (h, obj->encoding_sa);
|
||||
h = NM_HASH_COMBINE (h, obj->validation);
|
||||
h = NM_HASH_COMBINE (h, obj->encrypt);
|
||||
h = NM_HASH_COMBINE (h, obj->protect);
|
||||
h = NM_HASH_COMBINE (h, obj->include_sci);
|
||||
h = NM_HASH_COMBINE (h, obj->es);
|
||||
h = NM_HASH_COMBINE (h, obj->scb);
|
||||
h = NM_HASH_COMBINE (h, obj->replay_protect);
|
||||
return 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);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -5341,12 +5342,13 @@ nm_platform_lnk_macsec_cmp (const NMPlatformLnkMacsec *a, const NMPlatformLnkMac
|
|||
guint
|
||||
nm_platform_lnk_macvlan_hash (const NMPlatformLnkMacvlan *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (771014989u);
|
||||
NMHashState h;
|
||||
|
||||
h = NM_HASH_COMBINE (h, obj->mode);
|
||||
h = NM_HASH_COMBINE (h, obj->no_promisc);
|
||||
h = NM_HASH_COMBINE (h, obj->tap);
|
||||
return 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);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -5362,17 +5364,18 @@ nm_platform_lnk_macvlan_cmp (const NMPlatformLnkMacvlan *a, const NMPlatformLnkM
|
|||
guint
|
||||
nm_platform_lnk_sit_hash (const NMPlatformLnkSit *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (1690154969u);
|
||||
NMHashState h;
|
||||
|
||||
h = NM_HASH_COMBINE (h, obj->parent_ifindex);
|
||||
h = NM_HASH_COMBINE (h, obj->local);
|
||||
h = NM_HASH_COMBINE (h, obj->remote);
|
||||
h = NM_HASH_COMBINE (h, obj->ttl);
|
||||
h = NM_HASH_COMBINE (h, obj->tos);
|
||||
h = NM_HASH_COMBINE (h, obj->path_mtu_discovery);
|
||||
h = NM_HASH_COMBINE (h, obj->flags);
|
||||
h = NM_HASH_COMBINE (h, obj->proto);
|
||||
return 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);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -5393,11 +5396,12 @@ nm_platform_lnk_sit_cmp (const NMPlatformLnkSit *a, const NMPlatformLnkSit *b)
|
|||
guint
|
||||
nm_platform_lnk_vlan_hash (const NMPlatformLnkVlan *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (58751383u);
|
||||
NMHashState h;
|
||||
|
||||
h = NM_HASH_COMBINE (h, obj->id);
|
||||
h = NM_HASH_COMBINE (h, obj->flags);
|
||||
return h;
|
||||
nm_hash_init (&h, 58751383u);
|
||||
nm_hash_update_uint (&h, obj->id);
|
||||
nm_hash_update_uint (&h, obj->flags);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -5412,27 +5416,28 @@ nm_platform_lnk_vlan_cmp (const NMPlatformLnkVlan *a, const NMPlatformLnkVlan *b
|
|||
guint
|
||||
nm_platform_lnk_vxlan_hash (const NMPlatformLnkVxlan *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (461041297u);
|
||||
NMHashState h;
|
||||
|
||||
h = NM_HASH_COMBINE (h, obj->parent_ifindex);
|
||||
h = NM_HASH_COMBINE (h, obj->id);
|
||||
h = NM_HASH_COMBINE (h, obj->group);
|
||||
h = NM_HASH_COMBINE (h, obj->local);
|
||||
h = NM_HASH_COMBINE_IN6ADDR (h, &obj->group6);
|
||||
h = NM_HASH_COMBINE_IN6ADDR (h, &obj->local6);
|
||||
h = NM_HASH_COMBINE (h, obj->tos);
|
||||
h = NM_HASH_COMBINE (h, obj->ttl);
|
||||
h = NM_HASH_COMBINE (h, obj->learning);
|
||||
h = NM_HASH_COMBINE (h, obj->ageing);
|
||||
h = NM_HASH_COMBINE (h, obj->limit);
|
||||
h = NM_HASH_COMBINE (h, obj->dst_port);
|
||||
h = NM_HASH_COMBINE (h, obj->src_port_min);
|
||||
h = NM_HASH_COMBINE (h, obj->src_port_max);
|
||||
h = NM_HASH_COMBINE (h, obj->proxy);
|
||||
h = NM_HASH_COMBINE (h, obj->rsc);
|
||||
h = NM_HASH_COMBINE (h, obj->l2miss);
|
||||
h = NM_HASH_COMBINE (h, obj->l3miss);
|
||||
return 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_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);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -5463,21 +5468,22 @@ nm_platform_lnk_vxlan_cmp (const NMPlatformLnkVxlan *a, const NMPlatformLnkVxlan
|
|||
guint
|
||||
nm_platform_ip4_address_hash (const NMPlatformIP4Address *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (469681301u);
|
||||
NMHashState h;
|
||||
|
||||
nm_hash_init (&h, 469681301u);
|
||||
if (obj) {
|
||||
h = NM_HASH_COMBINE (h, obj->ifindex);
|
||||
h = NM_HASH_COMBINE (h, obj->address);
|
||||
h = NM_HASH_COMBINE (h, obj->plen);
|
||||
h = NM_HASH_COMBINE (h, obj->peer_address);
|
||||
h = NM_HASH_COMBINE (h, obj->addr_source);
|
||||
h = NM_HASH_COMBINE (h, obj->timestamp);
|
||||
h = NM_HASH_COMBINE (h, obj->lifetime);
|
||||
h = NM_HASH_COMBINE (h, obj->preferred);
|
||||
h = NM_HASH_COMBINE (h, obj->n_ifa_flags);
|
||||
h = NM_HASH_COMBINE (h, g_str_hash (obj->label));
|
||||
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_str (&h, obj->label);
|
||||
}
|
||||
return h;
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -5500,20 +5506,21 @@ nm_platform_ip4_address_cmp (const NMPlatformIP4Address *a, const NMPlatformIP4A
|
|||
guint
|
||||
nm_platform_ip6_address_hash (const NMPlatformIP6Address *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (605908909u);
|
||||
NMHashState h;
|
||||
|
||||
nm_hash_init (&h, 605908909u);
|
||||
if (obj) {
|
||||
h = NM_HASH_COMBINE (h, obj->ifindex);
|
||||
h = NM_HASH_COMBINE_IN6ADDR (h, &obj->address);
|
||||
h = NM_HASH_COMBINE (h, obj->plen);
|
||||
h = NM_HASH_COMBINE_IN6ADDR (h, &obj->peer_address);
|
||||
h = NM_HASH_COMBINE (h, obj->addr_source);
|
||||
h = NM_HASH_COMBINE (h, obj->timestamp);
|
||||
h = NM_HASH_COMBINE (h, obj->lifetime);
|
||||
h = NM_HASH_COMBINE (h, obj->preferred);
|
||||
h = NM_HASH_COMBINE (h, obj->n_ifa_flags);
|
||||
nm_hash_update_uint (&h, obj->ifindex);
|
||||
nm_hash_update_in6addr (&h, &obj->address);
|
||||
nm_hash_update_uint (&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);
|
||||
}
|
||||
return h;
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -5539,76 +5546,77 @@ nm_platform_ip6_address_cmp (const NMPlatformIP6Address *a, const NMPlatformIP6A
|
|||
guint
|
||||
nm_platform_ip4_route_hash (const NMPlatformIP4Route *obj, NMPlatformIPRouteCmpType cmp_type)
|
||||
{
|
||||
guint h = NM_HASH_INIT (1228913327u);
|
||||
NMHashState h;
|
||||
|
||||
h = NM_HASH_COMBINE (h, cmp_type);
|
||||
nm_hash_init (&h, 1228913327u);
|
||||
nm_hash_update_uint (&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:
|
||||
h = NM_HASH_COMBINE (h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
|
||||
h = NM_HASH_COMBINE (h, nm_utils_ip4_address_clear_host_address (obj->network, obj->plen));
|
||||
h = NM_HASH_COMBINE (h, obj->plen);
|
||||
h = NM_HASH_COMBINE (h, obj->metric);
|
||||
h = NM_HASH_COMBINE (h, obj->tos);
|
||||
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);
|
||||
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) {
|
||||
h = NM_HASH_COMBINE (h, obj->ifindex);
|
||||
h = NM_HASH_COMBINE (h, nmp_utils_ip_config_source_round_trip_rtprot (obj->rt_source));
|
||||
h = NM_HASH_COMBINE (h, _ip_route_scope_inv_get_normalized (obj));
|
||||
h = NM_HASH_COMBINE (h, obj->gateway);
|
||||
h = NM_HASH_COMBINE (h, obj->mss);
|
||||
h = NM_HASH_COMBINE (h, obj->pref_src);
|
||||
h = NM_HASH_COMBINE (h, obj->window);
|
||||
h = NM_HASH_COMBINE (h, obj->cwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->initcwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->initrwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->mtu);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_window);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_cwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_initcwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_initrwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_mtu);
|
||||
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);
|
||||
}
|
||||
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)
|
||||
h = NM_HASH_COMBINE (h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
|
||||
nm_hash_update_uint (&h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
|
||||
else
|
||||
h = NM_HASH_COMBINE (h, obj->table_coerced);
|
||||
h = NM_HASH_COMBINE (h, obj->ifindex);
|
||||
nm_hash_update_uint (&h, obj->table_coerced);
|
||||
nm_hash_update_uint (&h, obj->ifindex);
|
||||
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY)
|
||||
h = NM_HASH_COMBINE (h, nm_utils_ip4_address_clear_host_address (obj->network, obj->plen));
|
||||
nm_hash_update_uint (&h, nm_utils_ip4_address_clear_host_address (obj->network, obj->plen));
|
||||
else
|
||||
h = NM_HASH_COMBINE (h, obj->network);
|
||||
h = NM_HASH_COMBINE (h, obj->plen);
|
||||
h = NM_HASH_COMBINE (h, obj->metric);
|
||||
h = NM_HASH_COMBINE (h, obj->gateway);
|
||||
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);
|
||||
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY) {
|
||||
h = NM_HASH_COMBINE (h, nmp_utils_ip_config_source_round_trip_rtprot (obj->rt_source));
|
||||
h = NM_HASH_COMBINE (h, _ip_route_scope_inv_get_normalized (obj));
|
||||
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));
|
||||
} else {
|
||||
h = NM_HASH_COMBINE (h, obj->rt_source);
|
||||
h = NM_HASH_COMBINE (h, obj->scope_inv);
|
||||
nm_hash_update_uint (&h, obj->rt_source);
|
||||
nm_hash_update_uint (&h, obj->scope_inv);
|
||||
}
|
||||
h = NM_HASH_COMBINE (h, obj->mss);
|
||||
h = NM_HASH_COMBINE (h, obj->pref_src);
|
||||
h = NM_HASH_COMBINE (h, obj->rt_cloned);
|
||||
h = NM_HASH_COMBINE (h, obj->tos);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_window);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_cwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_initcwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_initrwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_mtu);
|
||||
h = NM_HASH_COMBINE (h, obj->window);
|
||||
h = NM_HASH_COMBINE (h, obj->cwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->initcwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->initrwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->mtu);
|
||||
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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return h;
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -5691,71 +5699,72 @@ nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route
|
|||
guint
|
||||
nm_platform_ip6_route_hash (const NMPlatformIP6Route *obj, NMPlatformIPRouteCmpType cmp_type)
|
||||
{
|
||||
guint h = NM_HASH_INIT (1053326051u);
|
||||
NMHashState h;
|
||||
|
||||
h = NM_HASH_COMBINE (h, cmp_type);
|
||||
nm_hash_init (&h, 1053326051u);
|
||||
nm_hash_update_uint (&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:
|
||||
h = NM_HASH_COMBINE (h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
|
||||
h = NM_HASH_COMBINE_IN6ADDR_PREFIX (h, &obj->network, obj->plen);
|
||||
h = NM_HASH_COMBINE (h, obj->plen);
|
||||
h = NM_HASH_COMBINE (h, nm_utils_ip6_route_metric_normalize (obj->metric));
|
||||
h = NM_HASH_COMBINE_IN6ADDR_PREFIX (h, &obj->src, obj->src_plen);
|
||||
h = NM_HASH_COMBINE (h, obj->src_plen);
|
||||
nm_hash_update_uint (&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_in6addr_prefix (&h, &obj->src, obj->src_plen);
|
||||
nm_hash_update_uint (&h, obj->src_plen);
|
||||
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) {
|
||||
h = NM_HASH_COMBINE (h, obj->ifindex);
|
||||
h = NM_HASH_COMBINE_IN6ADDR (h, &obj->gateway);
|
||||
nm_hash_update_uint (&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)
|
||||
h = NM_HASH_COMBINE (h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
|
||||
nm_hash_update_uint (&h, nm_platform_route_table_uncoerce (obj->table_coerced, TRUE));
|
||||
else
|
||||
h = NM_HASH_COMBINE (h, obj->table_coerced);
|
||||
h = NM_HASH_COMBINE (h, obj->ifindex);
|
||||
nm_hash_update_uint (&h, obj->table_coerced);
|
||||
nm_hash_update_uint (&h, obj->ifindex);
|
||||
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY)
|
||||
h = NM_HASH_COMBINE_IN6ADDR_PREFIX (h, &obj->network, obj->plen);
|
||||
nm_hash_update_in6addr_prefix (&h, &obj->network, obj->plen);
|
||||
else
|
||||
h = NM_HASH_COMBINE_IN6ADDR (h, &obj->network);
|
||||
h = NM_HASH_COMBINE (h, obj->plen);
|
||||
nm_hash_update_in6addr (&h, &obj->network);
|
||||
nm_hash_update_uint (&h, obj->plen);
|
||||
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY)
|
||||
h = NM_HASH_COMBINE (h, nm_utils_ip6_route_metric_normalize (obj->metric));
|
||||
nm_hash_update_uint (&h, nm_utils_ip6_route_metric_normalize (obj->metric));
|
||||
else
|
||||
h = NM_HASH_COMBINE (h, obj->metric);
|
||||
h = NM_HASH_COMBINE_IN6ADDR (h, &obj->gateway);
|
||||
h = NM_HASH_COMBINE_IN6ADDR (h, &obj->pref_src);
|
||||
nm_hash_update_uint (&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) {
|
||||
h = NM_HASH_COMBINE_IN6ADDR_PREFIX (h, &obj->src, obj->src_plen);
|
||||
h = NM_HASH_COMBINE (h, obj->src_plen);
|
||||
h = NM_HASH_COMBINE (h, nmp_utils_ip_config_source_round_trip_rtprot (obj->rt_source));
|
||||
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));
|
||||
} else {
|
||||
h = NM_HASH_COMBINE_IN6ADDR (h, &obj->src);
|
||||
h = NM_HASH_COMBINE (h, obj->src_plen);
|
||||
h = NM_HASH_COMBINE (h, obj->rt_source);
|
||||
nm_hash_update_in6addr (&h, &obj->src);
|
||||
nm_hash_update_uint (&h, obj->src_plen);
|
||||
nm_hash_update_uint (&h, obj->rt_source);
|
||||
}
|
||||
h = NM_HASH_COMBINE (h, obj->mss);
|
||||
h = NM_HASH_COMBINE (h, obj->rt_cloned);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_window);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_cwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_initcwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_initrwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->lock_mtu);
|
||||
h = NM_HASH_COMBINE (h, obj->window);
|
||||
h = NM_HASH_COMBINE (h, obj->cwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->initcwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->initrwnd);
|
||||
h = NM_HASH_COMBINE (h, obj->mtu);
|
||||
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);
|
||||
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY)
|
||||
h = NM_HASH_COMBINE (h, _route_pref_normalize (obj->rt_pref));
|
||||
nm_hash_update_uint (&h, _route_pref_normalize (obj->rt_pref));
|
||||
else
|
||||
h = NM_HASH_COMBINE (h, obj->rt_pref);
|
||||
nm_hash_update_uint (&h, obj->rt_pref);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return h;
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -121,9 +121,19 @@ _idx_obj_id_equal (const NMDedupMultiIdxType *idx_type,
|
|||
* on whether the objects are equal.
|
||||
*
|
||||
* _HASH_NON_ZERO() is used to for case 2), to avoid that the a zero hash value
|
||||
* is returned. */
|
||||
#define _HASH_NON_ZERO(h) \
|
||||
((h) ?: (1998098407 + __LINE__)) \
|
||||
* is returned.
|
||||
*
|
||||
* Actually, nm_hash_complete() never returns zero. This code is only
|
||||
* here as a safeguard and a reminder that the has MUST not be zero. */
|
||||
static inline guint
|
||||
_HASH_NON_ZERO (NMHashState *h)
|
||||
{
|
||||
guint v;
|
||||
|
||||
v = nm_hash_complete (h);
|
||||
nm_assert (v != 0);
|
||||
return v;
|
||||
}
|
||||
|
||||
static guint
|
||||
_idx_obj_part (const DedupMultiIdxType *idx_type,
|
||||
|
|
@ -131,7 +141,6 @@ _idx_obj_part (const DedupMultiIdxType *idx_type,
|
|||
const NMPObject *obj_a,
|
||||
const NMPObject *obj_b)
|
||||
{
|
||||
guint h;
|
||||
NMPObjectType obj_type;
|
||||
|
||||
/* the hash/equals functions are strongly related. So, keep them
|
||||
|
|
@ -150,10 +159,12 @@ _idx_obj_part (const DedupMultiIdxType *idx_type,
|
|||
if (obj_b)
|
||||
return NMP_OBJECT_GET_TYPE (obj_a) == NMP_OBJECT_GET_TYPE (obj_b);
|
||||
if (request_hash) {
|
||||
h = NM_HASH_INIT (487703243u);
|
||||
h = NM_HASH_COMBINE (h, idx_type->cache_id_type);
|
||||
h = NM_HASH_COMBINE (h, NMP_OBJECT_GET_TYPE (obj_a));
|
||||
return _HASH_NON_ZERO (h);
|
||||
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));
|
||||
return _HASH_NON_ZERO (&h);
|
||||
}
|
||||
return 1;
|
||||
|
||||
|
|
@ -170,11 +181,13 @@ _idx_obj_part (const DedupMultiIdxType *idx_type,
|
|||
&& nm_streq (obj_a->link.name, obj_b->link.name);
|
||||
}
|
||||
if (request_hash) {
|
||||
NMHashState h;
|
||||
|
||||
/* we request a hash from obj_a. Hash the relevant parts. */
|
||||
h = NM_HASH_INIT (2126752699u);
|
||||
h = NM_HASH_COMBINE (h, idx_type->cache_id_type);
|
||||
h = NM_HASH_COMBINE (h, g_str_hash (obj_a->link.name));
|
||||
return _HASH_NON_ZERO (h);
|
||||
nm_hash_init (&h, 2126752699u);
|
||||
nm_hash_update_uint (&h, idx_type->cache_id_type);
|
||||
nm_hash_update_str (&h, obj_a->link.name);
|
||||
return _HASH_NON_ZERO (&h);
|
||||
}
|
||||
/* just return 1, to indicate that obj_a is partitionable by this idx_type. */
|
||||
return 1;
|
||||
|
|
@ -191,10 +204,12 @@ _idx_obj_part (const DedupMultiIdxType *idx_type,
|
|||
&& nmp_object_is_visible (obj_b);
|
||||
}
|
||||
if (request_hash) {
|
||||
h = NM_HASH_INIT (4278960223u);
|
||||
h = NM_HASH_COMBINE (h, idx_type->cache_id_type);
|
||||
h = NM_HASH_COMBINE (h, NMP_OBJECT_GET_TYPE (obj_a));
|
||||
return _HASH_NON_ZERO (h);
|
||||
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));
|
||||
return _HASH_NON_ZERO (&h);
|
||||
}
|
||||
return 1;
|
||||
|
||||
|
|
@ -212,11 +227,13 @@ _idx_obj_part (const DedupMultiIdxType *idx_type,
|
|||
&& nmp_object_is_visible (obj_b);
|
||||
}
|
||||
if (request_hash) {
|
||||
h = NM_HASH_INIT (920415631u);
|
||||
h = NM_HASH_COMBINE (h, idx_type->cache_id_type);
|
||||
h = NM_HASH_COMBINE (h, NMP_OBJECT_GET_TYPE (obj_a));
|
||||
h = NM_HASH_COMBINE (h, obj_a->object.ifindex);
|
||||
return _HASH_NON_ZERO (h);
|
||||
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);
|
||||
return _HASH_NON_ZERO (&h);
|
||||
}
|
||||
return 1;
|
||||
|
||||
|
|
@ -234,13 +251,15 @@ _idx_obj_part (const DedupMultiIdxType *idx_type,
|
|||
: (nm_platform_ip6_route_cmp (&obj_a->ip6_route, &obj_b->ip6_route, NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID) == 0));
|
||||
}
|
||||
if (request_hash) {
|
||||
h = NM_HASH_INIT (778646573u);
|
||||
h = NM_HASH_COMBINE (h, idx_type->cache_id_type);
|
||||
NMHashState h;
|
||||
|
||||
nm_hash_init (&h, 778646573u);
|
||||
nm_hash_update_uint (&h, idx_type->cache_id_type);
|
||||
if (obj_type == NMP_OBJECT_TYPE_IP4_ROUTE)
|
||||
h = NM_HASH_COMBINE (h, nm_platform_ip4_route_hash (&obj_a->ip4_route, NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID));
|
||||
nm_hash_update_uint (&h, nm_platform_ip4_route_hash (&obj_a->ip4_route, NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID));
|
||||
else
|
||||
h = NM_HASH_COMBINE (h, nm_platform_ip6_route_hash (&obj_a->ip6_route, NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID));
|
||||
return _HASH_NON_ZERO (h);
|
||||
nm_hash_update_uint (&h, nm_platform_ip6_route_hash (&obj_a->ip6_route, NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID));
|
||||
return _HASH_NON_ZERO (&h);
|
||||
}
|
||||
return 1;
|
||||
|
||||
|
|
@ -301,18 +320,18 @@ _dedup_multi_idx_type_init (DedupMultiIdxType *idx_type, NMPCacheIdType cache_id
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static guint
|
||||
_vlan_xgress_qos_mappings_hash (guint n_map,
|
||||
static void
|
||||
_vlan_xgress_qos_mappings_hash (NMHashState *h,
|
||||
guint n_map,
|
||||
const NMVlanQosMapping *map)
|
||||
{
|
||||
guint h = NM_HASH_INIT (1453577309u);
|
||||
guint i;
|
||||
|
||||
nm_hash_update_uint (h, 1453577309u);
|
||||
for (i = 0; i < n_map; i++) {
|
||||
h = NM_HASH_COMBINE (h, map[i].from);
|
||||
h = NM_HASH_COMBINE (h, map[i].to);
|
||||
nm_hash_update_uint (h, map[i].from);
|
||||
nm_hash_update_uint (h, map[i].to);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -745,14 +764,14 @@ _vt_cmd_plobj_to_string_id_##type (const NMPlatformObject *_obj, char *buf, gsiz
|
|||
_vt_cmd_plobj_to_string_id (link, NMPlatformLink, "%d", obj->ifindex);
|
||||
_vt_cmd_plobj_to_string_id (ip4_address, NMPlatformIP4Address, "%d: %s/%d%s%s", obj->ifindex, nm_utils_inet4_ntop ( obj->address, buf1), obj->plen,
|
||||
obj->peer_address != obj->address ? "," : "",
|
||||
obj->peer_address != obj->address ? nm_utils_inet4_ntop (obj->peer_address & _nm_utils_ip4_prefix_to_netmask (obj->plen), buf2) : "");
|
||||
obj->peer_address != obj->address ? nm_utils_inet4_ntop (nm_utils_ip4_address_clear_host_address (obj->peer_address, obj->plen), buf2) : "");
|
||||
_vt_cmd_plobj_to_string_id (ip6_address, NMPlatformIP6Address, "%d: %s", obj->ifindex, nm_utils_inet6_ntop (&obj->address, buf1));
|
||||
|
||||
guint
|
||||
nmp_object_hash (const NMPObject *obj)
|
||||
{
|
||||
const NMPClass *klass;
|
||||
guint h;
|
||||
NMHashState h;
|
||||
|
||||
if (!obj)
|
||||
return 0;
|
||||
|
|
@ -761,44 +780,50 @@ nmp_object_hash (const NMPObject *obj)
|
|||
|
||||
klass = NMP_OBJECT_GET_CLASS (obj);
|
||||
|
||||
h = NM_HASH_INIT (816200863u);
|
||||
nm_hash_init (&h, 816200863u);
|
||||
nm_hash_update_uint (&h, klass->obj_type);
|
||||
if (klass->cmd_obj_hash)
|
||||
h = NM_HASH_COMBINE (h, klass->cmd_obj_hash (obj));
|
||||
nm_hash_update_uint (&h, klass->cmd_obj_hash (obj));
|
||||
else if (klass->cmd_plobj_hash)
|
||||
h = NM_HASH_COMBINE (h, klass->cmd_plobj_hash (&obj->object));
|
||||
nm_hash_update_uint (&h, klass->cmd_plobj_hash (&obj->object));
|
||||
else
|
||||
return NM_HASH_POINTER (obj);
|
||||
return NM_HASH_COMBINE (h, klass->obj_type);
|
||||
nm_hash_update_ptr (&h, obj);
|
||||
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
static guint
|
||||
_vt_cmd_obj_hash_link (const NMPObject *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (3448776161u);
|
||||
NMHashState h;
|
||||
|
||||
nm_assert (NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_LINK);
|
||||
|
||||
h = NM_HASH_COMBINE (h, nm_platform_link_hash (&obj->link));
|
||||
h = NM_HASH_COMBINE (h, obj->_link.netlink.is_in_netlink);
|
||||
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);
|
||||
if (obj->_link.netlink.lnk)
|
||||
h = NM_HASH_COMBINE (h, nmp_object_hash (obj->_link.netlink.lnk));
|
||||
h = NM_HASH_COMBINE (h, GPOINTER_TO_UINT (obj->_link.udev.device));
|
||||
return h;
|
||||
nm_hash_update_uint (&h, nmp_object_hash (obj->_link.netlink.lnk));
|
||||
nm_hash_update_ptr (&h, obj->_link.udev.device);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
static guint
|
||||
_vt_cmd_obj_hash_lnk_vlan (const NMPObject *obj)
|
||||
{
|
||||
guint h = NM_HASH_INIT (914932607u);
|
||||
NMHashState h;
|
||||
|
||||
nm_assert (NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_LNK_VLAN);
|
||||
|
||||
h = NM_HASH_COMBINE (h, nm_platform_lnk_vlan_hash (&obj->lnk_vlan));
|
||||
h = NM_HASH_COMBINE (h, _vlan_xgress_qos_mappings_hash (obj->_lnk_vlan.n_ingress_qos_map,
|
||||
obj->_lnk_vlan.ingress_qos_map));
|
||||
h = NM_HASH_COMBINE (h, _vlan_xgress_qos_mappings_hash (obj->_lnk_vlan.n_egress_qos_map,
|
||||
obj->_lnk_vlan.egress_qos_map));
|
||||
return h;
|
||||
nm_hash_init (&h, 914932607u);
|
||||
nm_hash_update_uint (&h, nm_platform_lnk_vlan_hash (&obj->lnk_vlan));
|
||||
_vlan_xgress_qos_mappings_hash (&h,
|
||||
obj->_lnk_vlan.n_ingress_qos_map,
|
||||
obj->_lnk_vlan.ingress_qos_map);
|
||||
_vlan_xgress_qos_mappings_hash (&h,
|
||||
obj->_lnk_vlan.n_egress_qos_map,
|
||||
obj->_lnk_vlan.egress_qos_map);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -1082,47 +1107,43 @@ nmp_object_id_hash (const NMPObject *obj)
|
|||
|
||||
if (!klass->cmd_plobj_id_hash) {
|
||||
/* The klass doesn't implement ID compare. It means, to use pointer
|
||||
* equality (g_direct_hash). */
|
||||
return NM_HASH_POINTER (obj);
|
||||
* equality. */
|
||||
return nm_hash_ptr (obj);
|
||||
}
|
||||
|
||||
return klass->cmd_plobj_id_hash (&obj->object);
|
||||
}
|
||||
|
||||
#define _vt_cmd_plobj_id_hash(type, plat_type, cmd) \
|
||||
#define _vt_cmd_plobj_id_hash(type, plat_type, hash_seed, cmd) \
|
||||
static guint \
|
||||
_vt_cmd_plobj_id_hash_##type (const NMPlatformObject *_obj) \
|
||||
{ \
|
||||
const plat_type *const obj = (const plat_type *) _obj; \
|
||||
guint hash; \
|
||||
NMHashState h; \
|
||||
nm_hash_init (&h, (hash_seed)); \
|
||||
{ cmd; } \
|
||||
return hash; \
|
||||
return nm_hash_complete (&h); \
|
||||
}
|
||||
_vt_cmd_plobj_id_hash (link, NMPlatformLink, {
|
||||
hash = NM_HASH_INIT (3982791431u);
|
||||
hash = NM_HASH_COMBINE (hash, ((guint) obj->ifindex));
|
||||
_vt_cmd_plobj_id_hash (link, NMPlatformLink, 3982791431u, {
|
||||
nm_hash_update_uint (&h, obj->ifindex);
|
||||
})
|
||||
_vt_cmd_plobj_id_hash (ip4_address, NMPlatformIP4Address, {
|
||||
hash = NM_HASH_INIT (3591309853u);
|
||||
hash = NM_HASH_COMBINE (hash, ((guint) obj->ifindex));
|
||||
hash = NM_HASH_COMBINE (hash, obj->plen);
|
||||
hash = NM_HASH_COMBINE (hash, obj->address);
|
||||
_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) */
|
||||
hash = NM_HASH_COMBINE (hash, (obj->peer_address & _nm_utils_ip4_prefix_to_netmask (obj->plen)));
|
||||
nm_hash_update_uint (&h, nm_utils_ip4_address_clear_host_address (obj->peer_address, obj->plen));
|
||||
})
|
||||
_vt_cmd_plobj_id_hash (ip6_address, NMPlatformIP6Address, {
|
||||
hash = NM_HASH_INIT (2907861637u);
|
||||
hash = NM_HASH_COMBINE (hash, ((guint) obj->ifindex));
|
||||
_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. */
|
||||
hash = NM_HASH_COMBINE (hash, nm_utils_in6_addr_hash (&obj->address));
|
||||
nm_hash_update_in6addr (&h, &obj->address);
|
||||
})
|
||||
_vt_cmd_plobj_id_hash (ip4_route, NMPlatformIP4Route, {
|
||||
hash = NM_HASH_INIT (1038302471u);
|
||||
hash = NM_HASH_COMBINE (hash, nm_platform_ip4_route_hash (obj, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID));
|
||||
_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));
|
||||
})
|
||||
_vt_cmd_plobj_id_hash (ip6_route, NMPlatformIP6Route, {
|
||||
hash = NM_HASH_INIT (1233384151u);
|
||||
hash = NM_HASH_COMBINE (hash, nm_platform_ip6_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));
|
||||
})
|
||||
|
||||
gboolean
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue