* Prefix hash table
*/
-#define PXH_KEY(px) px->ni->index, px->path_id, px->hash
+#define PXH_KEY(px) px->ni->index, px->src
#define PXH_NEXT(px) px->next
-#define PXH_EQ(n1,i1,h1,n2,i2,h2) h1 == h2 && (add_path_tx ? (i1 == i2) : 1) && (n1 == n2)
-#define PXH_FN(n,i,h) h
+#define PXH_EQ(n1,i1,n2,i2) (add_path_tx ? (i1 == i2) : 1) && (n1 == n2)
+#define PXH_FN(n,i) u32_hash(n)
#define PXH_REHASH bgp_pxh_rehash
#define PXH_PARAMS /16, *1, 2, 2, 12, 24
static struct bgp_prefix *
bgp_get_prefix(struct bgp_channel *c, struct netindex *ni, struct rte_src *src, int add_path_tx)
{
- u32 path_id = src->global_id;
- u32 path_id_hash = add_path_tx ? path_id : 0;
- /* We must use a different hash function than the rtable */
- u32 hash = u32_hash(u32_hash(ni->index) ^ u32_hash(path_id_hash));
- struct bgp_prefix *px = HASH_FIND(c->prefix_hash, PXH, ni->index, path_id_hash, hash);
+ struct bgp_prefix *px = HASH_FIND(c->prefix_hash, PXH, ni->index, src);
if (px)
{
- if (!add_path_tx && (path_id != px->path_id))
+ if (!add_path_tx && (src != px->src))
{
- rt_unlock_source(rt_find_source_global(px->path_id));
+ rt_unlock_source(px->src);
rt_lock_source(src);
- px->path_id = path_id;
+ px->src = src;
}
return px;
px = sl_alloc(c->prefix_slab);
*px = (struct bgp_prefix) {
- .hash = hash,
- .path_id = path_id,
+ .src = src,
.ni = ni,
};
#define BPX_TRACE(what) do { \
if (c->c.debug & D_ROUTES) log(L_TRACE "%s.%s < %s %N %uG %s", \
c->c.proto->name, c->c.name, what, \
- px->ni->addr, px->path_id, IS_WITHDRAW_BUCKET(b) ? "withdraw" : "update"); } while (0)
+ px->ni->addr, px->src->global_id, IS_WITHDRAW_BUCKET(b) ? "withdraw" : "update"); } while (0)
px->lastmod = current_time();
/* Already queued for the same bucket */
HASH_REMOVE2(c->prefix_hash, PXH, c->pool, px);
net_unlock_index(c->c.table->netindex, px->ni);
- rt_unlock_source(rt_find_source_global(px->path_id));
+ rt_unlock_source(px->src);
sl_free(px);
}
/* Encode path ID */
if (s->add_path)
{
- put_u32(pos, px->path_id);
+ put_u32(pos, px->src->global_id);
ADVANCE(pos, size, 4);
}
/* Encode path ID */
if (s->add_path)
{
- put_u32(pos, px->path_id);
+ put_u32(pos, px->src->global_id);
ADVANCE(pos, size, 4);
}
/* Encode path ID */
if (s->add_path)
{
- put_u32(pos, px->path_id);
+ put_u32(pos, px->src->global_id);
ADVANCE(pos, size, 4);
}
/* Encode path ID */
if (s->add_path)
{
- put_u32(pos, px->path_id);
+ put_u32(pos, px->src->global_id);
ADVANCE(pos, size, 4);
}
/* Encode path ID */
if (s->add_path)
{
- put_u32(pos, px->path_id);
+ put_u32(pos, px->src->global_id);
ADVANCE(pos, size, 4);
}
/* Encode path ID */
if (s->add_path)
{
- put_u32(pos, px->path_id);
+ put_u32(pos, px->src->global_id);
ADVANCE(pos, size, 4);
}