Skip to content

Commit

Permalink
datapath: replace remaining users of arch_fast_hash with jhash
Browse files Browse the repository at this point in the history
This patch effectively reverts commit 500f80872645 ("net: ovs: use CRC32
accelerated flow hash if available"), and other remaining arch_fast_hash()
users such as from nfsd via commit 6282cd565553 ("NFSD: Don't hand out
delegations for 30 seconds after recalling them.") where it has been used
as a hash function for bloom filtering.

While we think that these users are actually not much of concern, it has
been requested to remove the arch_fast_hash() library bits that arose
from [1] entirely as per recent discussion [2]. The main argument is that
using it as a hash may introduce bias due to its linearity (see avalanche
criterion) and thus makes it less clear (though we tried to document that)
when this security/performance trade-off is actually acceptable for a
general purpose library function.

Lets therefore avoid any further confusion on this matter and remove it to
prevent any future accidental misuse of it. For the time being, this is
going to make hashing of flow keys a bit more expensive in the ovs case,
but future work could reevaluate a different hashing discipline.

  [1] https://patchwork.ozlabs.org/patch/299369/
  [2] https://patchwork.ozlabs.org/patch/418756/

Upstream: 8754589 ("net: replace remaining users of arch_fast_hash with jhash")
Signed-off-by: Thomas Graf <[email protected]>
Acked-by: Pravin B Shelar <[email protected]>
  • Loading branch information
Thomas Graf committed Jan 7, 2015
1 parent 5282e28 commit 1dfb9f3
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 215 deletions.
1 change: 0 additions & 1 deletion acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [ERR_CAST])
OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [IS_ERR_OR_NULL])
OVS_GREP_IFELSE([$KSRC/include/linux/hash.h], [fast_hash_ops])
OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [eth_hw_addr_random])
OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [ether_addr_copy])
Expand Down
4 changes: 2 additions & 2 deletions datapath/flow_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <linux/if_vlan.h>
#include <net/llc_pdu.h>
#include <linux/kernel.h>
#include <linux/hash.h>
#include <linux/jhash.h>
#include <linux/jiffies.h>
#include <linux/llc.h>
#include <linux/module.h>
Expand Down Expand Up @@ -448,7 +448,7 @@ static u32 flow_hash(const struct sw_flow_key *key, int key_start,
/* Make sure number of hash bytes are multiple of u32. */
BUILD_BUG_ON(sizeof(long) % sizeof(u32));

return arch_fast_hash2(hash_key, hash_u32s, 0);
return jhash2(hash_key, hash_u32s, 0);
}

static int flow_key_start(const struct sw_flow_key *key)
Expand Down
4 changes: 0 additions & 4 deletions datapath/linux/Modules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ openvswitch_sources += \
linux/compat/gre.c \
linux/compat/gso.c \
linux/compat/genetlink-openvswitch.c \
linux/compat/hash.c \
linux/compat/hash-x86.c \
linux/compat/ip_tunnels_core.c \
linux/compat/netdevice.c \
linux/compat/net_namespace.c \
Expand All @@ -17,7 +15,6 @@ openvswitch_sources += \
linux/compat/utils.c
openvswitch_headers += \
linux/compat/gso.h \
linux/compat/include/asm/hash.h \
linux/compat/include/linux/percpu.h \
linux/compat/include/linux/bug.h \
linux/compat/include/linux/compiler.h \
Expand All @@ -26,7 +23,6 @@ openvswitch_headers += \
linux/compat/include/linux/err.h \
linux/compat/include/linux/etherdevice.h \
linux/compat/include/linux/flex_array.h \
linux/compat/include/linux/hash.h \
linux/compat/include/linux/icmp.h \
linux/compat/include/linux/icmpv6.h \
linux/compat/include/linux/if.h \
Expand Down
95 changes: 0 additions & 95 deletions datapath/linux/compat/hash-x86.c

This file was deleted.

51 changes: 0 additions & 51 deletions datapath/linux/compat/hash.c

This file was deleted.

18 changes: 0 additions & 18 deletions datapath/linux/compat/include/asm/hash.h

This file was deleted.

44 changes: 0 additions & 44 deletions datapath/linux/compat/include/linux/hash.h

This file was deleted.

0 comments on commit 1dfb9f3

Please sign in to comment.