Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f610b74b authored by David S. Miller's avatar David S. Miller
Browse files

ipv4: Use universal hash for ARP.



We need to make sure the multiplier is odd.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cd089336
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -8,6 +8,13 @@

extern struct neigh_table arp_tbl;

static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd)
{
	u32 val = key ^ dev->ifindex;

	return val * hash_rnd;
}

extern void	arp_init(void);
extern int	arp_find(unsigned char *haddr, struct sk_buff *skb);
extern int	arp_ioctl(struct net *net, unsigned int cmd, void __user *arg);
+1 −0
Original line number Diff line number Diff line
@@ -334,6 +334,7 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int shift)
	ret->hash_buckets = buckets;
	ret->hash_shift = shift;
	get_random_bytes(&ret->hash_rnd, sizeof(ret->hash_rnd));
	ret->hash_rnd |= 1;
	return ret;
}

+1 −2
Original line number Diff line number Diff line
@@ -97,7 +97,6 @@
#include <linux/init.h>
#include <linux/net.h>
#include <linux/rcupdate.h>
#include <linux/jhash.h>
#include <linux/slab.h>
#ifdef CONFIG_SYSCTL
#include <linux/sysctl.h>
@@ -232,7 +231,7 @@ static u32 arp_hash(const void *pkey,
		    const struct net_device *dev,
		    __u32 hash_rnd)
{
	return jhash_2words(*(u32 *)pkey, dev->ifindex, hash_rnd);
	return arp_hashfn(*(u32 *)pkey, dev, hash_rnd);
}

static int arp_constructor(struct neighbour *neigh)