BGP_ADV_FIFO_INIT(&sync->withdraw_low);
peer->sync[afi][safi] = sync;
peer->hash[afi][safi] =
- hash_create(baa_hash_key, baa_hash_cmp, NULL);
+ hash_create(baa_hash_key,
+ baa_hash_cmp,
+ "BGP Sync Hash");
}
}
/* AS path hash initialize. */
void aspath_init(void)
{
- ashash = hash_create_size(32768, aspath_key_make, aspath_cmp, NULL);
+ ashash = hash_create_size(32768,
+ aspath_key_make,
+ aspath_cmp,
+ "BGP AS Path");
}
void aspath_finish(void)
static void cluster_init(void)
{
- cluster_hash =
- hash_create(cluster_hash_key_make, cluster_hash_cmp, NULL);
+ cluster_hash = hash_create(cluster_hash_key_make,
+ cluster_hash_cmp,
+ "BGP Cluster");
}
static void cluster_finish(void)
static void encap_init(void)
{
- encap_hash = hash_create(encap_hash_key_make, encap_hash_cmp, NULL);
+ encap_hash = hash_create(encap_hash_key_make,
+ encap_hash_cmp,
+ "BGP Encap Hash");
#if ENABLE_BGP_VNC
- vnc_hash = hash_create(encap_hash_key_make, encap_hash_cmp, NULL);
+ vnc_hash = hash_create(encap_hash_key_make,
+ encap_hash_cmp,
+ "BGP VNC Hash");
#endif
}
static void transit_init(void)
{
- transit_hash =
- hash_create(transit_hash_key_make, transit_hash_cmp, NULL);
+ transit_hash = hash_create(transit_hash_key_make,
+ transit_hash_cmp,
+ "BGP Transit Hash");
}
static void transit_finish(void)
static void attrhash_init(void)
{
- attrhash =
- hash_create(attrhash_key_make, attrhash_cmp, "BGP Attributes");
+ attrhash = hash_create(attrhash_key_make,
+ attrhash_cmp,
+ "BGP Attributes");
}
/*
#include "command.h"
#include "hash.h"
#include "memory.h"
+#include "jhash.h"
#include "bgpd/bgp_memory.h"
#include "bgpd/bgp_community.h"
hash package.*/
unsigned int community_hash_make(struct community *com)
{
- unsigned char *pnt = (unsigned char *)com->val;
- int size = com->size * 4;
- unsigned int key = 0;
- int c;
-
- for (c = 0; c < size; c += 4) {
- key += pnt[c];
- key += pnt[c + 1];
- key += pnt[c + 2];
- key += pnt[c + 3];
- }
+ u_int32_t *pnt = (u_int32_t *)com->val;
- return key;
+ return jhash2(pnt, com->size, 0x43ea96c1);
}
int community_match(const struct community *com1, const struct community *com2)
{
comhash = hash_create(
(unsigned int (*)(void *))community_hash_make,
- (int (*)(const void *, const void *))community_cmp, NULL);
+ (int (*)(const void *, const void *))community_cmp,
+ "BGP Community Hash");
}
void community_finish(void)
#include "command.h"
#include "queue.h"
#include "filter.h"
+#include "jhash.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_ecommunity.h"
{
const struct ecommunity *ecom = arg;
int size = ecom->size * ECOMMUNITY_SIZE;
- u_int8_t *pnt = ecom->val;
- unsigned int key = 0;
- int c;
-
- for (c = 0; c < size; c += ECOMMUNITY_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];
- }
- return key;
+ return jhash(ecom->val, size, 0x564321ab);
}
/* Compare two Extended Communities Attribute structure. */
/* Initialize Extended Comminities related hash. */
void ecommunity_init(void)
{
- ecomhash = hash_create(ecommunity_hash_make, ecommunity_cmp, NULL);
+ ecomhash = hash_create(ecommunity_hash_make,
+ ecommunity_cmp,
+ "BGP ecommunity hash");
}
void ecommunity_finish(void)
#include "prefix.h"
#include "command.h"
#include "filter.h"
+#include "jhash.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_lcommunity.h"
{
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. */
/* 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)
void bgp_tip_hash_init(struct bgp *bgp)
{
- bgp->tip_hash =
- hash_create(bgp_tip_hash_key_make, bgp_tip_hash_cmp, NULL);
+ bgp->tip_hash = hash_create(bgp_tip_hash_key_make,
+ bgp_tip_hash_cmp,
+ "BGP TIP hash");
}
void bgp_tip_hash_destroy(struct bgp *bgp)
void bgp_address_init(struct bgp *bgp)
{
bgp->address_hash = hash_create(bgp_address_hash_key_make,
- bgp_address_hash_cmp, NULL);
+ bgp_address_hash_cmp,
+ "BGP Address Hash");
}
void bgp_address_destroy(struct bgp *bgp)
BGP_ADV_FIFO_INIT(&subgrp->sync->update);
BGP_ADV_FIFO_INIT(&subgrp->sync->withdraw);
BGP_ADV_FIFO_INIT(&subgrp->sync->withdraw_low);
- subgrp->hash = hash_create(baa_hash_key, baa_hash_cmp, NULL);
+ subgrp->hash = hash_create(baa_hash_key,
+ baa_hash_cmp,
+ "BGP SubGroup Hash");
/* We use a larger buffer for subgrp->work in the event that:
* - We RX a BGP_UPDATE where the attributes alone are just
int afid;
AF_FOREACH(afid)
- bgp->update_groups[afid] =
- hash_create(updgrp_hash_key_make, updgrp_hash_cmp, NULL);
+ bgp->update_groups[afid] =
+ hash_create(updgrp_hash_key_make,
+ updgrp_hash_cmp,
+ "BGP Update Group Hash");
}
void update_bgp_group_free(struct bgp *bgp)
struct community *com;
com = (struct community *)backet->data;
- vty_out(vty, "[%p] (%ld) %s\n", (void *)backet, com->refcnt,
+ vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt,
community_str(com));
}
struct lcommunity *lcom;
lcom = (struct lcommunity *)backet->data;
- vty_out(vty, "[%p] (%ld) %s\n", (void *)backet, lcom->refcnt,
+ vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt,
lcommunity_str(lcom));
}
XSTRDUP(MTYPE_BGP_PEER_HOST, cmd_domainname_get());
bgp->peer = list_new();
bgp->peer->cmp = (int (*)(void *, void *))peer_cmp;
- bgp->peerhash = hash_create(peer_hash_key_make, peer_hash_same, NULL);
+ bgp->peerhash = hash_create(peer_hash_key_make,
+ peer_hash_same,
+ "BGP Peer Hash");
bgp->peerhash->max_size = BGP_PEER_MAX_HASH_SIZE;
bgp->group = list_new();