]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: Fix crash when OOM happens.
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 3 Aug 2017 11:43:47 +0000 (07:43 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 4 Aug 2017 13:05:13 +0000 (09:05 -0400)
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>
zebra/zebra_vxlan.c

index c96f073064d80d1d347049e4e5345e9543990dc0..e89f05374f2057e70220659b9e668c0b6792530d 100644 (file)
@@ -776,18 +776,9 @@ static void zvni_install_neigh_hash(struct hash_backet *backet, void *ctxt)
 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);
 }
 
 /*