Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Kubecek <mkubecek@suse.cz>2018-10-25 14:46:03 +0200
committerMichal Kubecek <mkubecek@suse.cz>2018-10-25 14:46:03 +0200
commitedb4e4eb38bc01e4c1bdd5b6bb4f3809ed761287 (patch)
tree2ba1c85e38a4f333390689df4457487f999c41ec
parenteb308cd8a0f3816e6ba88fb97de4efd958b6ebc1 (diff)
xfrm: use complete IPv6 addresses for hash (bsc#1109330).
-rw-r--r--patches.fixes/xfrm-use-complete-IPv6-addresses-for-hash.patch45
-rw-r--r--series.conf1
2 files changed, 46 insertions, 0 deletions
diff --git a/patches.fixes/xfrm-use-complete-IPv6-addresses-for-hash.patch b/patches.fixes/xfrm-use-complete-IPv6-addresses-for-hash.patch
new file mode 100644
index 0000000000..adfee8bd4c
--- /dev/null
+++ b/patches.fixes/xfrm-use-complete-IPv6-addresses-for-hash.patch
@@ -0,0 +1,45 @@
+From: Michal Kubecek <mkubecek@suse.cz>
+Date: Fri, 12 Oct 2018 14:24:44 +0200
+Subject: xfrm: use complete IPv6 addresses for hash
+Patch-mainline: v4.20-rc1
+Git-commit: 8d4b6bce2559755cf2db6513a267fccdfbf7c3ab
+References: bsc#1109330
+
+In some environments it is common that many hosts share the same lower half
+of their IPv6 addresses (in particular ::1). As __xfrm6_addr_hash() and
+__xfrm6_daddr_saddr_hash() calculate the hash only from the lower halves,
+as much as 1/3 of the hosts ends up in one hashtable chain which harms the
+performance.
+
+Use complete IPv6 addresses when calculating the hashes. Rather than just
+adding two more words to the xor, use jhash2() for consistency with
+__xfrm6_pref_hash() and __xfrm6_dpref_spref_hash().
+
+Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
+Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
+
+---
+ net/xfrm/xfrm_hash.h | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+--- a/net/xfrm/xfrm_hash.h
++++ b/net/xfrm/xfrm_hash.h
+@@ -12,7 +12,7 @@ static inline unsigned int __xfrm4_addr_hash(const xfrm_address_t *addr)
+
+ static inline unsigned int __xfrm6_addr_hash(const xfrm_address_t *addr)
+ {
+- return ntohl(addr->a6[2] ^ addr->a6[3]);
++ return jhash2((__force u32 *)addr->a6, 4, 0);
+ }
+
+ static inline unsigned int __xfrm4_daddr_saddr_hash(const xfrm_address_t *daddr,
+@@ -25,8 +25,7 @@ static inline unsigned int __xfrm4_daddr_saddr_hash(const xfrm_address_t *daddr,
+ static inline unsigned int __xfrm6_daddr_saddr_hash(const xfrm_address_t *daddr,
+ const xfrm_address_t *saddr)
+ {
+- return ntohl(daddr->a6[2] ^ daddr->a6[3] ^
+- saddr->a6[2] ^ saddr->a6[3]);
++ return __xfrm6_addr_hash(daddr) ^ __xfrm6_addr_hash(saddr);
+ }
+
+ static inline u32 __bits2mask32(__u8 bits)
diff --git a/series.conf b/series.conf
index 1afded114c..1c506255fa 100644
--- a/series.conf
+++ b/series.conf
@@ -18051,6 +18051,7 @@
patches.drivers/iwlwifi-mvm-check-for-n_profiles-validity-in-EWRD-AC.patch
patches.drivers/iwlwifi-mvm-clear-HW_RESTART_REQUESTED-when-stopping.patch
patches.drivers/mac80211-minstrel-fix-using-short-preamble-CCK-rates.patch
+ patches.fixes/xfrm-use-complete-IPv6-addresses-for-hash.patch
patches.arch/signal-properly-deliver-sigsegv-from-x86-uprobes
patches.fixes/jbd2-fix-use-after-free-in-jbd2_log_do_checkpoint.patch