[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/27] Jhash: add linux kernel jhashtable in qemu
From: |
Jason Wang |
Subject: |
[Qemu-devel] [PULL 06/27] Jhash: add linux kernel jhashtable in qemu |
Date: |
Mon, 26 Sep 2016 16:59:14 +0800 |
From: Zhang Chen <address@hidden>
Jhash will be used by colo-compare and filter-rewriter
to save and lookup net connection info
Signed-off-by: Zhang Chen <address@hidden>
Signed-off-by: Li Zhijian <address@hidden>
Signed-off-by: Wen Congyang <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
---
include/qemu/jhash.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++
net/colo.h | 1 +
2 files changed, 60 insertions(+)
create mode 100644 include/qemu/jhash.h
diff --git a/include/qemu/jhash.h b/include/qemu/jhash.h
new file mode 100644
index 0000000..7222242
--- /dev/null
+++ b/include/qemu/jhash.h
@@ -0,0 +1,59 @@
+/* jhash.h: Jenkins hash support.
+ *
+ * Copyright (C) 2006. Bob Jenkins (address@hidden)
+ *
+ * http://burtleburtle.net/bob/hash/
+ *
+ * These are the credits from Bob's sources:
+ *
+ * lookup3.c, by Bob Jenkins, May 2006, Public Domain.
+ *
+ * These are functions for producing 32-bit hashes for hash table lookup.
+ * hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final()
+ * are externally useful functions. Routines to test the hash are included
+ * if SELF_TEST is defined. You can use this free for any purpose. It's in
+ * the public domain. It has no warranty.
+ *
+ * Copyright (C) 2009-2010 Jozsef Kadlecsik (address@hidden)
+ *
+ * I've modified Bob's hash to be useful in the Linux kernel, and
+ * any bugs present are my fault.
+ * Jozsef
+ */
+
+#ifndef QEMU_JHASH_H__
+#define QEMU_JHASH_H__
+
+#include "qemu/bitops.h"
+
+/*
+ * hashtable relation copy from linux kernel jhash
+ */
+
+/* __jhash_mix -- mix 3 32-bit values reversibly. */
+#define __jhash_mix(a, b, c) \
+{ \
+ a -= c; a ^= rol32(c, 4); c += b; \
+ b -= a; b ^= rol32(a, 6); a += c; \
+ c -= b; c ^= rol32(b, 8); b += a; \
+ a -= c; a ^= rol32(c, 16); c += b; \
+ b -= a; b ^= rol32(a, 19); a += c; \
+ c -= b; c ^= rol32(b, 4); b += a; \
+}
+
+/* __jhash_final - final mixing of 3 32-bit values (a,b,c) into c */
+#define __jhash_final(a, b, c) \
+{ \
+ c ^= b; c -= rol32(b, 14); \
+ a ^= c; a -= rol32(c, 11); \
+ b ^= a; b -= rol32(a, 25); \
+ c ^= b; c -= rol32(b, 16); \
+ a ^= c; a -= rol32(c, 4); \
+ b ^= a; b -= rol32(a, 14); \
+ c ^= b; c -= rol32(b, 24); \
+}
+
+/* An arbitrary initial parameter */
+#define JHASH_INITVAL 0xdeadbeef
+
+#endif /* QEMU_JHASH_H__ */
diff --git a/net/colo.h b/net/colo.h
index e211eda..05dc0b6 100644
--- a/net/colo.h
+++ b/net/colo.h
@@ -16,6 +16,7 @@
#define QEMU_COLO_PROXY_H
#include "slirp/slirp.h"
+#include "qemu/jhash.h"
#define HASHTABLE_MAX_SIZE 16384
--
2.7.4
- [Qemu-devel] [PULL 00/27] Net patches, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 01/27] virtio-net: allow increasing rx queue size, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 02/27] net: hmp_host_net_remove: Del the -net option of the removed host_net, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 03/27] qemu-char: Add qemu_chr_add_handlers_full() for GMaincontext, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 05/27] net/colo.c: add colo.c to define and handle packet, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 04/27] colo-compare: introduce colo compare initialization, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 06/27] Jhash: add linux kernel jhashtable in qemu,
Jason Wang <=
- [Qemu-devel] [PULL 07/27] colo-compare: track connection and enqueue packet, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 08/27] colo-compare: introduce packet comparison thread, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 09/27] colo-compare: add TCP, UDP, ICMP packet comparison, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 10/27] filter-rewriter: introduce filter-rewriter initialization, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 11/27] filter-rewriter: track connection and parse packet, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 12/27] filter-rewriter: rewrite tcp packet to keep secondary connection, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 13/27] MAINTAINERS: add maintainer for COLO-proxy, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 14/27] docs: Add documentation for COLO-proxy, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 15/27] e1000: fix buliding complaint, Jason Wang, 2016/09/26
- [Qemu-devel] [PULL 16/27] tap: Allow specifying a bridge, Jason Wang, 2016/09/26