summaryrefslogtreecommitdiff
path: root/nest/rt-attr.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-04-24 10:39:13 +0200
committerMaria Matejka <mq@ucw.cz>2023-04-24 10:39:13 +0200
commitfa8848aca3f0473412f3ae6288d71dee8458bcfa (patch)
tree20aa1c64f866079684f4923f857021baff4d2b53 /nest/rt-attr.c
parent942d3cbcdd548a73ecc1915a97e297e9bf0bb5e6 (diff)
parent22f54eaee6c6dbe12ad7bb0ee1da09e3e026b970 (diff)
Merge branch 'mq-resource-locking' into thread-next
Diffstat (limited to 'nest/rt-attr.c')
-rw-r--r--nest/rt-attr.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/nest/rt-attr.c b/nest/rt-attr.c
index 903926f6..38612a4e 100644
--- a/nest/rt-attr.c
+++ b/nest/rt-attr.c
@@ -605,9 +605,16 @@ ea_register(pool *p, struct ea_class *def)
struct ea_class_ref *
ea_register_alloc(pool *p, struct ea_class cl)
{
+ struct ea_class_ref *ref;
+
+ RTA_LOCK;
struct ea_class *clp = ea_class_find_by_name(cl.name);
if (clp && clp->type == cl.type)
- return ea_ref_class(p, clp);
+ {
+ ref = ea_ref_class(p, clp);
+ RTA_UNLOCK;
+ return ref;
+ }
uint namelen = strlen(cl.name) + 1;
@@ -619,14 +626,18 @@ ea_register_alloc(pool *p, struct ea_class cl)
memcpy(cla->name, cl.name, namelen);
cla->cl.name = cla->name;
- return ea_register(p, &cla->cl);
+ ref = ea_register(p, &cla->cl);
+ RTA_UNLOCK;
+ return ref;
}
void
ea_register_init(struct ea_class *clp)
{
+ RTA_LOCK;
ASSERT_DIE(!ea_class_find_by_name(clp->name));
ea_register(&root_pool, clp);
+ RTA_UNLOCK;
}
struct ea_class *
@@ -1598,7 +1609,8 @@ rta_init(void)
{
attrs_domain = DOMAIN_NEW(attrs, "Attributes");
- rta_pool = rp_new(&root_pool, "Attributes");
+ RTA_LOCK;
+ rta_pool = rp_new(&root_pool, attrs_domain.attrs, "Attributes");
for (uint i=0; i<ARRAY_SIZE(ea_slab_sizes); i++)
ea_slab[i] = sl_new(rta_pool, ea_slab_sizes[i]);
@@ -1607,6 +1619,8 @@ rta_init(void)
rte_src_init();
ea_class_init();
+ RTA_UNLOCK;
+
/* These attributes are required to be first for nice "show route" output */
ea_register_init(&ea_gen_nexthop);
ea_register_init(&ea_gen_hostentry);