do_recalculate:
/* Add the new route to the list right behind the old one */
if (new_stored)
+ {
+ /* There is the same piece of code several lines farther. Needs refactoring.
+ * The old_stored check is needed because of the possible jump from deterministic med */
+ if (old_stored)
{
atomic_store_explicit(&new_stored->next, atomic_load_explicit(&old_stored->next, memory_order_relaxed), memory_order_release);
atomic_store_explicit(&old_stored->next, new_stored, memory_order_release);
-
- table->rt_count++;
}
+ else
+ {
+ atomic_store_explicit(&new_stored->next, NULL, memory_order_release);
+ atomic_store_explicit(last_ptr, new_stored, memory_order_release);
+ }
+
+ table->rt_count++;
+ }
/* Find a new optimal route (if there is any) */
struct rte_storage * _Atomic *bp = &local_sentinel.next;
struct rte_storage *new_stored, struct rte_storage *old_stored, struct rte_storage *old_best_stored)
{
struct rte_storage *key_stored = new_stored ? new_stored : old_stored;
- const struct rte *new = &new_stored->rte,
- *old = &old_stored->rte,
- *old_best = &old_best_stored->rte,
- *key = &key_stored->rte;
+ const struct rte *new = RTE_OR_NULL(new_stored),
+ *old = RTE_OR_NULL(old_stored),
+ *old_best = RTE_OR_NULL(old_best_stored),
+ *key = RTE_OR_NULL(key_stored);
u32 lpref = rt_get_preference(key);
u32 lasn = bgp_get_neighbor(key);