mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-25 16:11:45 +00:00
[INET]: Use jhash + random secret for ehash.
The days are gone when this was not an issue, there are folks out there with huge bot networks that can be used to attack the established hash tables on remote systems. So just like the routing cache and connection tracking hash, use Jenkins hash with random secret input. Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d30045a0bc
commit
b3da2cf37c
4 changed files with 35 additions and 9 deletions
|
@ -19,6 +19,9 @@
|
|||
#include <linux/in6.h>
|
||||
#include <linux/ipv6.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/jhash.h>
|
||||
|
||||
#include <net/inet_sock.h>
|
||||
|
||||
#include <net/ipv6.h>
|
||||
|
||||
|
@ -28,12 +31,11 @@ struct inet_hashinfo;
|
|||
static inline unsigned int inet6_ehashfn(const struct in6_addr *laddr, const u16 lport,
|
||||
const struct in6_addr *faddr, const __be16 fport)
|
||||
{
|
||||
unsigned int hashent = (lport ^ (__force u16)fport);
|
||||
u32 ports = (lport ^ (__force u16)fport);
|
||||
|
||||
hashent ^= (__force u32)(laddr->s6_addr32[3] ^ faddr->s6_addr32[3]);
|
||||
hashent ^= hashent >> 16;
|
||||
hashent ^= hashent >> 8;
|
||||
return hashent;
|
||||
return jhash_3words((__force u32)laddr->s6_addr32[3],
|
||||
(__force u32)faddr->s6_addr32[3],
|
||||
ports, inet_ehash_secret);
|
||||
}
|
||||
|
||||
static inline int inet6_sk_ehashfn(const struct sock *sk)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue