Change in openvpn[master]: Replace custom hash_func with siphash
A message that is not in the archive (sent off-list or not yet received): gerrit.1773255066000.I807f398903ac2047530800c29949793c6f4f0ec9@...2715...
plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/1573?usp=email )
Change subject: Replace custom hash_func with siphash
......................................................................
Replace custom hash_func with siphash
---
M CMakeLists.txt
M src/openvpn/Makefile.am
M src/openvpn/list.c
M src/openvpn/list.h
M src/openvpn/mroute.c
M src/openvpn/multi.c
A src/openvpn/siphash.c
M src/openvpn/siphash.h
M tests/unit_tests/openvpn/Makefile.am
M tests/unit_tests/openvpn/test_misc.c
10 files changed, 140 insertions(+), 208 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/73/1573/1
CMakeLists.txt +6 -1
@@ -557,6 +557,7 @@ src/openvpn/sig.c src/openvpn/sig.h src/openvpn/siphash.h + src/openvpn/siphash.c src/openvpn/siphash_openssl.c src/openvpn/siphash_reference.c src/openvpn/socket.c
@@ -821,7 +822,11 @@ src/openvpn/options_util.c src/openvpn/ssl_util.c src/openvpn/list.c - ) + src/openvpn/siphash.h + src/openvpn/siphash.c + src/openvpn/siphash_reference.c + src/openvpn/siphash_openssl.c + ) target_sources(test_ncp PRIVATE src/openvpn/crypto_epoch.c
src/openvpn/Makefile.am +2 -1
@@ -128,7 +128,8 @@ session_id.c session_id.h \ shaper.c shaper.h \ sig.c sig.h \ - siphash_reference.c siphash.h \ + siphash.c siphash.h \ + siphash_reference.c \ siphash_openssl.c \ socket.c socket.h \ socket_util.c socket_util.h \
src/openvpn/list.c +1 -187
198 lines not on this page · raw message
src/openvpn/list.h +0 -4
@@ -101,10 +101,6 @@void hash_iterator_free (struct hash_iterator *hi); -uint64_t hash_func (const uint8_t *k,uint32_t length,uint32_t initval); - -void *hash_func_new_ctx (void ); -static inline uint64_t hash_value (const struct hash *hash,const void *key) {
src/openvpn/mroute.c +3 -3
@@ -33,6 +33,7 @@#include "socket_util.h" #include "memdbg.h" +#include "siphash.h" void mroute_addr_init (struct mroute_addr *addr)
@@ -357,9 +358,8 @@uint64_t mroute_addr_hash_function (const void *key,void *ctx) { -uint32_t *iv = ctx; -return hash_func (mroute_addr_hash_ptr ((const struct mroute_addr *)key), -mroute_addr_hash_len ((const struct mroute_addr *)key), *iv); +return siphash_hash_func (mroute_addr_hash_ptr ((const struct mroute_addr *)key), +mroute_addr_hash_len ((const struct mroute_addr *)key), ctx); }bool
src/openvpn/multi.c +3 -2
@@ -23,6 +23,7 @@#ifdef HAVE_CONFIG_H #include "config.h" #endif +#include "siphash.h" #ifdef HAVE_SYS_INOTIFY_H #include <sys/inotify.h>
@@ -290,14 +291,14 @@* to determine which client sent an incoming packet * which is seen on the TCP/UDP socket. */ - m->hash =hash_init (t->options.real_hash_size,hash_func_new_ctx (), free, + m->hash =hash_init (t->options.real_hash_size,siphash_new_context (), siphash_free_context, mroute_addr_hash_function, mroute_addr_compare_function);/* * Virtual address hash table. Used to determine * which client to route a packet to. */ - m->vhash =hash_init (t->options.virtual_hash_size,hash_func_new_ctx (), free, + m->vhash =hash_init (t->options.virtual_hash_size,siphash_new_context (), siphash_free_context, mroute_addr_hash_function, mroute_addr_compare_function);#ifdef ENABLE_MANAGEMENT
src/openvpn/siphash.c new file +77 -0
78 lines not on this page · raw message
src/openvpn/siphash.h +39 -5
65 lines not on this page · raw message
tests/unit_tests/openvpn/Makefile.am +5 -1
@@ -85,6 +85,7 @@ $(top_srcdir)/src/openvpn/mtu.c \ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/openvpn/mss.c \ + $(top_srcdir)/src/openvpn/siphash.c \ $(top_srcdir)/src/openvpn/siphash_openssl.c \ $(top_srcdir)/src/openvpn/siphash_reference.c
@@ -378,7 +379,10 @@ $(top_srcdir)/src/openvpn/ssl_util.c \ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/openvpn/platform.c \ - $(top_srcdir)/src/openvpn/list.c + $(top_srcdir)/src/openvpn/list.c \ + $(top_srcdir)/src/openvpn/siphash.c \ + $(top_srcdir)/src/openvpn/siphash_openssl.c \ + $(top_srcdir)/src/openvpn/siphash_reference.c push_update_msg_testdriver_CFLAGS = -I$(top_srcdir)/src/openvpn \ -I$(top_srcdir)/src/compat \
tests/unit_tests/openvpn/test_misc.c +4 -4
@@ -32,6 +32,7 @@#include <string.h> #include <setjmp.h> #include <cmocka.h> +#include <siphash.h> #include "ssl_util.h" #include "options_util.h"
@@ -127,10 +128,9 @@static uint64_t word_hash_function (const void *key,void *ctx) { -uint32_t *iv = (uint32_t *)ctx;const char *str = (const char *)key;const uint32_t len = (uint32_t )strlen (str); -return hash_func ((const uint8_t *)str, len, *iv); +return siphash_hash_func ((const uint8_t *)str, len, ctx); } static bool
@@ -173,8 +173,8 @@* word frequency algorithm. */ struct gc_arena gc =gc_new (); -struct hash *hash =hash_init (10000 ,hash_func_new_ctx (), free, word_hash_function, word_compare_function); -struct hash *nhash =hash_init (256 ,hash_func_new_ctx (), free, word_hash_function, word_compare_function); +struct hash *hash =hash_init (10000 ,siphash_new_context (), siphash_free_context, word_hash_function, word_compare_function); +struct hash *nhash =hash_init (256 ,siphash_new_context (), siphash_free_context, word_hash_function, word_compare_function);printf ("hash_init n_buckets=%u mask=0x%08x\n" , hash->n_buckets, hash->mask);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1573?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I807f398903ac2047530800c29949793c6f4f0ec9
Gerrit-Change-Number: 1573
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>