]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
ID Maps are checking whether their pool is locked
authorMaria Matejka <mq@ucw.cz>
Mon, 8 May 2023 13:13:49 +0000 (15:13 +0200)
committerMaria Matejka <mq@ucw.cz>
Thu, 11 May 2023 09:41:01 +0000 (11:41 +0200)
lib/idm.c
lib/idm.h

index 66e311c6a885077bc43a1a23e01bc066ebff3b0d..ac5ec571d8e74a9416bff6028d0b8315cb776179 100644 (file)
--- a/lib/idm.c
+++ b/lib/idm.c
@@ -22,6 +22,7 @@ idm_init(struct idm *m, pool *p, uint size)
   m->used = 1;
   m->size = size;
   m->data = mb_allocz(p, m->size * sizeof(u32));
+  m->pool = p;
 
   /* ID 0 is reserved */
   m->data[0] = 1;
@@ -34,6 +35,8 @@ idm_alloc(struct idm *m)
 {
   uint i, j;
 
+  ASSERT_DIE(DG_IS_LOCKED(m->pool->domain));
+
   for (i = m->pos; i < m->size; i++)
     if (m->data[i] != 0xffffffff)
       goto found;
@@ -67,6 +70,8 @@ found:
 void
 idm_free(struct idm *m, u32 id)
 {
+  ASSERT_DIE(DG_IS_LOCKED(m->pool->domain));
+
   uint i = id / 32;
   uint j = id % 32;
 
index e3380cceae8dc4e32fe77146cc342a10efd6da30..69e26ff5d7b1097ff12d804e5c83e2109b6cadb5 100644 (file)
--- a/lib/idm.h
+++ b/lib/idm.h
@@ -12,6 +12,7 @@
 
 struct idm
 {
+  pool *pool;
   u32 *data;
   u32 pos;
   u32 used;