The hash key function choosen for mac vni's would tend
to clump the key value to the same number. Use a better
hash key generator to spread the hash values out.
A bad hash key might lead to O(2^n) memory consumption
because the hash size is doubled, each time a backet
exceeds a predefined threshold. This quickly leads
to OOM. Fixing this issue by fixing the hash
key generation to actually spread the keys out.
Ticket: CM-17412
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
static unsigned int mac_hash_keymake(void *p)
{
zebra_mac_t *pmac = p;
- char *pnt = (char *)pmac->macaddr.octet;
- unsigned int key = 0;
- int c = 0;
-
- key += pnt[c];
- key += pnt[c + 1];
- key += pnt[c + 2];
- key += pnt[c + 3];
- key += pnt[c + 4];
- key += pnt[c + 5];
-
- return (key);
+ const void *pnt = (void *)pmac->macaddr.octet;
+
+ return jhash(pnt, ETHER_ADDR_LEN, 0xa5a5a55a);
}
/*