From 053dfc8225feac0edcc01e66aaf3c72415ce37db Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 10 Feb 2014 23:18:47 +0100 Subject: [PATCH] backports: add ipv6_addr_hash() This is needed by net-core-flow_dissector.c Kernel < 2.6.25 and kernel > 3.6 have this function. Signed-off-by: Hauke Mehrtens --- backport/backport-include/net/ipv6.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 backport/backport-include/net/ipv6.h diff --git a/backport/backport-include/net/ipv6.h b/backport/backport-include/net/ipv6.h new file mode 100644 index 000000000000..9a370a07d106 --- /dev/null +++ b/backport/backport-include/net/ipv6.h @@ -0,0 +1,23 @@ +#ifndef __BACKPORT_NET_IPV6_H +#define __BACKPORT_NET_IPV6_H +#include_next +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) && (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) +#define ipv6_addr_hash LINUX_BACKPORT(ipv6_addr_hash) +static inline u32 ipv6_addr_hash(const struct in6_addr *a) +{ +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64 + const unsigned long *ul = (const unsigned long *)a; + unsigned long x = ul[0] ^ ul[1]; + + return (u32)(x ^ (x >> 32)); +#else + return (__force u32)(a->s6_addr32[0] ^ a->s6_addr32[1] ^ + a->s6_addr32[2] ^ a->s6_addr32[3]); +#endif +} +#endif + +#endif /* __BACKPORT_NET_IPV6_H */ -- 2.30.2