summaryrefslogtreecommitdiff
path: root/nest/rt-attr.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-09-14 09:59:45 +0200
committerMaria Matejka <mq@ucw.cz>2022-09-14 09:59:45 +0200
commit1518970c128e6ab68884a7f49e09e2dc2a5d9fe3 (patch)
tree37abff70b2edc5fcc34b6f93f75abcbd7bfa335f /nest/rt-attr.c
parent878eeec12bf020c9e7460040d225a929bbbd2bd2 (diff)
Revert "Routing tables now have their own loops."
This reverts commit 878eeec12bf020c9e7460040d225a929bbbd2bd2. These changes have been done in a different way in the other branch of the future merge.
Diffstat (limited to 'nest/rt-attr.c')
-rw-r--r--nest/rt-attr.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/nest/rt-attr.c b/nest/rt-attr.c
index cd4c6892..20f9835d 100644
--- a/nest/rt-attr.c
+++ b/nest/rt-attr.c
@@ -1287,7 +1287,7 @@ rta_lookup(rta *o)
for(r=rta_hash_table[h & rta_cache_mask]; r; r=r->next)
if (r->hash_key == h && rta_same(r, o))
{
- r->uc++;
+ atomic_fetch_add_explicit(&r->uc, 1, memory_order_acq_rel);
RTA_UNLOCK;
return r;
}
@@ -1308,6 +1308,14 @@ rta_lookup(rta *o)
void
rta__free(rta *a)
{
+ RTA_LOCK;
+ if (atomic_load_explicit(&a->uc, memory_order_acquire))
+ {
+ /* Somebody has cloned this rta inbetween. This sometimes happens. */
+ RTA_UNLOCK;
+ return;
+ }
+
ASSERT(rta_cache_count && a->cached);
rta_cache_count--;
*a->pprev = a->next;
@@ -1319,6 +1327,7 @@ rta__free(rta *a)
ea_free(a->eattrs);
a->cached = 0;
sl_free(rta_slab(a), a);
+ RTA_UNLOCK;
}
rta *