summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-08-03 13:43:47 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-08-04 15:05:13 +0200
commit25331def553ad84804e49d63a51e2dde379989a6 (patch)
tree36b64016232ca98fe61c1409c358963efa88daeb
parentMerge pull request #909 from opensourcerouting/isis-perf (diff)
downloadfrr-25331def553ad84804e49d63a51e2dde379989a6.tar.xz
frr-25331def553ad84804e49d63a51e2dde379989a6.zip
zebra: Fix crash when OOM happens.
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>
-rw-r--r--zebra/zebra_vxlan.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index c96f07306..e89f05374 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -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);
}
/*