all: use siphash24 for hashing

System Internals / NetworkManager - Thomas Haller [redhat.com] - 18 October 2017 07:27 EDT

siphash24() is wildly used by projects nowadays.

It's certainly slower then our djb hashing that we used before. But quite likely it's fast enough for us, given how wildly it is used. I think it would be hard to profile NetworkManager to show that the performance of hash tables is the issue, be it with djb or siphash24.

Certainly with siphash24() it's much harder to exploit the hashing algorithm to cause worst case hash operations (provided that the seed is kept private). Does this better resistance against a denial of service matter for us? Probably not, but let's better be safe then sorry.

Note that systemd's implementation uses a different seed for each hash table (at least, after the hash table grows to a certain size). We don't do that and use only one global seed.

ee76b09 all: use siphash24 for hashing
Makefile.am | 11 +-
libnm-core/tests/test-general.c | 44 ++-----
shared/nm-utils/nm-hash-utils.c | 80 ++++++++++---
shared/nm-utils/nm-hash-utils.h | 111 +++++++++---------
.../src/basic => shared/nm-utils}/siphash24.c | 5 +-
.../src/basic => shared/nm-utils}/siphash24.h | 0
src/devices/nm-lldp-listener.c | 4 +-
src/platform/nm-platform.c | 11 +-
src/platform/nmp-object.c | 2 +-
src/systemd/src/basic/unaligned.h | 129 ---------------------
10 files changed, 146 insertions(+), 251 deletions(-)

Upstream: cgit.freedesktop.org


  • Share