mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
Netindex: fixed resolving net by index
This commit is contained in:
parent
2537e7f924
commit
b6e70f5ecf
@ -70,6 +70,8 @@ netindex_hash_cleanup(void *_nh)
|
|||||||
{
|
{
|
||||||
HASH_DO_REMOVE(nh->net[t].hash, NETINDEX, ii);
|
HASH_DO_REMOVE(nh->net[t].hash, NETINDEX, ii);
|
||||||
hmap_clear(&nh->net[t].id_map, i->index);
|
hmap_clear(&nh->net[t].id_map, i->index);
|
||||||
|
nh->net[t].block[i->index] = NULL;
|
||||||
|
|
||||||
if (nh->net[t].slab)
|
if (nh->net[t].slab)
|
||||||
sl_free(i);
|
sl_free(i);
|
||||||
else
|
else
|
||||||
@ -143,6 +145,17 @@ net_new_index_locked(struct netindex_hash_private *hp, const net_addr *n)
|
|||||||
net_copy(ni->addr, n);
|
net_copy(ni->addr, n);
|
||||||
|
|
||||||
HASH_INSERT2(hp->net[n->type].hash, NETINDEX, hp->pool, ni);
|
HASH_INSERT2(hp->net[n->type].hash, NETINDEX, hp->pool, ni);
|
||||||
|
while (hp->net[n->type].block_size <= i)
|
||||||
|
{
|
||||||
|
u32 bs = hp->net[n->type].block_size;
|
||||||
|
struct netindex **nb = mb_alloc(hp->pool, bs * 2 * sizeof *nb);
|
||||||
|
memcpy(nb, hp->net[n->type].block, bs * sizeof *nb);
|
||||||
|
memset(&nb[bs], 0, bs * sizeof *nb);
|
||||||
|
hp->net[n->type].block_size *= 2;
|
||||||
|
hp->net[n->type].block = nb;
|
||||||
|
}
|
||||||
|
|
||||||
|
hp->net[n->type].block[i] = ni;
|
||||||
|
|
||||||
return net_lock_revive_unlock(hp, ni);
|
return net_lock_revive_unlock(hp, ni);
|
||||||
}
|
}
|
||||||
@ -186,6 +199,8 @@ net_resolve_index(netindex_hash *h, u8 net_type, u32 i)
|
|||||||
NH_LOCK(h, hp);
|
NH_LOCK(h, hp);
|
||||||
if (i >= hp->net[net_type].block_size)
|
if (i >= hp->net[net_type].block_size)
|
||||||
return NULL;
|
return NULL;
|
||||||
else
|
|
||||||
return net_lock_revive_unlock(hp, hp->net[net_type].block[i]);
|
struct netindex *ni = hp->net[net_type].block[i];
|
||||||
|
ASSERT_DIE(!ni || (ni->addr->type == net_type));
|
||||||
|
return net_lock_revive_unlock(hp, ni);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user