diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-09-04 00:57:30 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-09-05 20:33:06 +0200 |
commit | 3f65c5b1f7db20c1ee3ab723483f294975ce2f94 (patch) | |
tree | 298e5547fd5d36b177e2d3eb31a4ff88d76a158c /bgpd/bgp_lcommunity.c | |
parent | zebra: Add hash name to mpls hash (diff) | |
download | frr-3f65c5b1f7db20c1ee3ab723483f294975ce2f94.tar.xz frr-3f65c5b1f7db20c1ee3ab723483f294975ce2f94.zip |
bgpd: Add various hash optimizations
1) Add hash names to all hash_create calls
2) Fix community_hash, ecommunity_hash and lcommunity_hash key
creation
3) Fix output of community and lcommunity iterators( why would
we want to see the memory location of the backet? ).
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'bgpd/bgp_lcommunity.c')
-rw-r--r-- | bgpd/bgp_lcommunity.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/bgpd/bgp_lcommunity.c b/bgpd/bgp_lcommunity.c index 395ae5271..d75f33f58 100644 --- a/bgpd/bgp_lcommunity.c +++ b/bgpd/bgp_lcommunity.c @@ -25,6 +25,7 @@ #include "prefix.h" #include "command.h" #include "filter.h" +#include "jhash.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_lcommunity.h" @@ -230,26 +231,8 @@ unsigned int lcommunity_hash_make(void *arg) { const struct lcommunity *lcom = arg; int size = lcom_length(lcom); - u_int8_t *pnt = lcom->val; - unsigned int key = 0; - int c; - - for (c = 0; c < size; c += LCOMMUNITY_SIZE) { - key += pnt[c]; - key += pnt[c + 1]; - key += pnt[c + 2]; - key += pnt[c + 3]; - key += pnt[c + 4]; - key += pnt[c + 5]; - key += pnt[c + 6]; - key += pnt[c + 7]; - key += pnt[c + 8]; - key += pnt[c + 9]; - key += pnt[c + 10]; - key += pnt[c + 11]; - } - return key; + return jhash(lcom->val, size, 0xab125423); } /* Compare two Large Communities Attribute structure. */ @@ -272,7 +255,9 @@ struct hash *lcommunity_hash(void) /* Initialize Large Comminities related hash. */ void lcommunity_init(void) { - lcomhash = hash_create(lcommunity_hash_make, lcommunity_cmp, NULL); + lcomhash = hash_create(lcommunity_hash_make, + lcommunity_cmp, + "BGP lcommunity hash"); } void lcommunity_finish(void) |