Avoid inlining siphash globally to avoid hitting BPF instruction limits
[flowspec-xdp] / siphash.h
index 4c2ec7aa3d2db82582c978a7a27729475faa18d9..298a3a2dd626470915f21c7fe39fa0f0d56e827d 100644 (file)
--- a/siphash.h
+++ b/siphash.h
@@ -140,3 +140,15 @@ static inline uint64_t siphash(const void *in, const size_t inlen, const uint8_t
     b = v0 ^ v1 ^ v2 ^ v3;
     return b;
 }
+
+#include "rand.h"
+static uint64_t siphash_uint64_t(const uint64_t in) {
+       return siphash(&in, sizeof(uint64_t), COMPILE_TIME_RAND);
+}
+__attribute__((always_inline))
+static inline uint64_t siphash_uint32_t(const uint32_t in) {
+       return siphash_uint64_t(in);
+}
+static uint64_t siphash_uint128_t(const __uint128_t in) {
+       return siphash(&in, sizeof(__uint128_t), COMPILE_TIME_RAND);
+}