]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
ospf: move ospf to its own loop kk-ospf-to-loop
authorKaterina Kubecova <katerina.kubecova@nic.cz>
Fri, 9 May 2025 12:29:10 +0000 (14:29 +0200)
committerKaterina Kubecova <katerina.kubecova@nic.cz>
Fri, 9 May 2025 12:54:32 +0000 (14:54 +0200)
proto/ospf/config.Y
proto/ospf/dbdes.c
proto/ospf/iface.c
proto/ospf/lsupd.c
proto/ospf/neighbor.c
proto/ospf/ospf.c
proto/ospf/rt.c

index 7184d7dd930a483a924f7b15242c6bcfbf9817d3..026e261b795ff6d5b4215832243c888b08b7ef9e 100644 (file)
@@ -461,6 +461,7 @@ nbma_item: ipa nbma_eligible ';'
 
 ospf_iface_start:
  {
+  this_proto->loop_order = DOMAIN_ORDER(proto);
   this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt));
   add_tail(&this_area->patt_list, NODE this_ipatt);
   init_list(&this_ipatt->ipn_list);
index 6d33bf8e05b11403980ebc2f3b65489ca3365b54..f0ba0d6cbe8ebc536cb6154b3c9d90cc15e80208 100644 (file)
@@ -300,7 +300,7 @@ ospf_process_dbdes(struct ospf_proto *p, struct ospf_packet *pkt, struct ospf_ne
       req->lsa_body = LSA_BODY_DUMMY;
 
       if (!tm_active(n->lsrq_timer))
-       tm_start(n->lsrq_timer, 0);
+       tm_start_in(n->lsrq_timer, 0, p->p.loop);
     }
   }
 
@@ -453,7 +453,7 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
       }
 
       ospf_send_dbdes(p, n);
-      tm_start(n->dbdes_timer, n->ifa->rxmtint S);
+      tm_start_in(n->dbdes_timer, n->ifa->rxmtint S, p->p.loop);
     }
     else
     {
@@ -473,7 +473,7 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
       if (!(n->myimms & DBDES_M) && !(n->imms & DBDES_M))
       {
        /* Use dbdes timer to postpone freeing of Last DBDES packet buffer */
-       tm_start(n->dbdes_timer, n->ifa->deadint S);
+       tm_start_in(n->dbdes_timer, n->ifa->deadint S, p->p.loop);
        ospf_neigh_sm(n, INM_EXDONE);
       }
     }
index edfbcda433a99ef5648687b68898ea854fbf651e..b115095560e7ff39a628bcd84432372386d27dab 100644 (file)
@@ -386,6 +386,7 @@ ospf_iface_sm(struct ospf_iface *ifa, int event)
   case ISM_UP:
     if (ifa->state <= OSPF_IS_LOOP)
     {
+      struct ospf_proto *p = ifa->oa->po;
       /* Now, nothing should be adjacent */
       if ((ifa->type == OSPF_IT_PTP) ||
          (ifa->type == OSPF_IT_PTMP) ||
@@ -401,15 +402,15 @@ ospf_iface_sm(struct ospf_iface *ifa, int event)
        {
          ospf_iface_chstate(ifa, OSPF_IS_WAITING);
          if (ifa->wait_timer)
-           tm_start(ifa->wait_timer, ifa->waitint S);
+           tm_start_in(ifa->wait_timer, ifa->waitint S, p->p.loop);
        }
       }
 
       if (ifa->hello_timer)
-       tm_start(ifa->hello_timer, ifa->helloint S);
+       tm_start_in(ifa->hello_timer, ifa->helloint S, p->p.loop);
 
       if (ifa->poll_timer)
-       tm_start(ifa->poll_timer, ifa->pollint S);
+       tm_start_in(ifa->poll_timer, ifa->pollint S, p->p.loop);
 
       ospf_send_hello(ifa, OHS_HELLO, NULL);
     }
@@ -672,7 +673,7 @@ ospf_iface_new(struct ospf_area *oa, struct ifa *addr, struct ospf_iface_patt *i
     .hook = ospf_iface_add,
     .data = ifa,
   };
-  lock->target = &global_event_list;
+  lock->target = proto_event_list(&p->p);
 
   olock_acquire(lock);
 }
@@ -734,7 +735,7 @@ ospf_iface_new_vlink(struct ospf_proto *p, struct ospf_iface_patt *ip)
 }
 
 static void
-ospf_iface_change_timer(timer *tm, uint val)
+ospf_iface_change_timer(timer *tm, uint val, struct birdloop *loop)
 {
   if (!tm)
     return;
@@ -742,7 +743,7 @@ ospf_iface_change_timer(timer *tm, uint val)
   tm->recurrent = val S;
 
   if (tm_active(tm))
-    tm_start(tm, val S);
+    tm_start_in(tm, val S, loop);
 }
 
 static inline void
@@ -803,7 +804,7 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new)
               ifname, ifa->helloint, new->helloint);
 
     ifa->helloint = new->helloint;
-    ospf_iface_change_timer(ifa->hello_timer, ifa->helloint);
+    ospf_iface_change_timer(ifa->hello_timer, ifa->helloint, p->p.loop);
   }
 
   /* RXMT TIMER */
@@ -823,7 +824,7 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new)
               ifname, ifa->pollint, new->pollint);
 
     ifa->pollint = new->pollint;
-    ospf_iface_change_timer(ifa->poll_timer, ifa->pollint);
+    ospf_iface_change_timer(ifa->poll_timer, ifa->pollint, p->p.loop);
   }
 
   /* WAIT TIMER */
@@ -834,7 +835,7 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new)
 
     ifa->waitint = new->waitint;
     if (ifa->wait_timer && tm_active(ifa->wait_timer))
-      tm_start(ifa->wait_timer, ifa->waitint S);
+      tm_start_in(ifa->wait_timer, ifa->waitint S, p->p.loop);
   }
 
   /* DEAD TIMER */
index 12c9cfaafb14e4d4347083b30656caf79e1bb0fe..60964bedb04ffc102e769dec5e7210cef6a416c3 100644 (file)
@@ -137,7 +137,10 @@ ospf_lsa_lsrt_up(struct top_hash_entry *en, struct ospf_neighbor *n)
   ret->lsa_body = LSA_BODY_DUMMY;
 
   if (!tm_active(n->lsrt_timer))
-    tm_start(n->lsrt_timer, n->ifa->rxmtint S);
+  {
+    struct ospf_proto *p = n->ifa->oa->po;
+    tm_start_in(n->lsrt_timer, n->ifa->rxmtint S, p->p.loop);
+  }
 }
 
 void
@@ -177,7 +180,7 @@ ospf_add_flushed_to_lsrt(struct ospf_proto *p, struct ospf_neighbor *n)
 
   /* If we found any flushed LSA, we send them ASAP */
   if (tm_active(n->lsrt_timer))
-    tm_start(n->lsrt_timer, 0);
+    tm_start_in(n->lsrt_timer, 0, p->p.loop);
 }
 
 static int ospf_flood_lsupd(struct ospf_proto *p, struct top_hash_entry **lsa_list, uint lsa_count, uint lsa_min_count, struct ospf_iface *ifa);
@@ -185,6 +188,8 @@ static int ospf_flood_lsupd(struct ospf_proto *p, struct top_hash_entry **lsa_li
 static void
 ospf_enqueue_lsa(struct ospf_proto *p, struct top_hash_entry *en, struct ospf_iface *ifa)
 {
+  ASSERT_DIE(birdloop_inside(p->p.loop));
+
   /* Exception for local Grace-LSA, they are flooded synchronously */
   if ((en->lsa_type == LSA_T_GR) && (en->lsa.rt == p->router_id))
   {
@@ -211,7 +216,7 @@ ospf_enqueue_lsa(struct ospf_proto *p, struct top_hash_entry *en, struct ospf_if
   ifa->flood_queue_used++;
 
   if (!ev_active(p->flood_event))
-    ev_schedule(p->flood_event);
+    ev_send(proto_event_list(&p->p), p->flood_event);
 }
 
 void
@@ -709,7 +714,7 @@ ospf_receive_lsupd(struct ospf_packet *pkt, struct ospf_iface *ifa,
   if (!EMPTY_SLIST(n->lsrql) && (n->lsrqi == SHEAD(n->lsrql)))
   {
     ospf_send_lsreq(p, n);
-    tm_start(n->lsrq_timer, n->ifa->rxmtint S);
+    tm_start_in(n->lsrq_timer, n->ifa->rxmtint S, p->p.loop);
   }
 
   return;
index acc0acfb2e461146af308bc03286ec7c9d88350c..792c1a2e094f9594c56a27a57d9d19fc80f6a4d9 100644 (file)
@@ -189,8 +189,8 @@ ospf_neigh_chstate(struct ospf_neighbor *n, u8 state)
     n->myimms = DBDES_IMMS;
     n->got_my_rt_lsa = 0;
 
-    tm_start(n->dbdes_timer, 0);
-    tm_start(n->ackd_timer, ifa->rxmtint S / 2);
+    tm_start_in(n->dbdes_timer, 0, p->p.loop);
+    tm_start_in(n->ackd_timer, ifa->rxmtint S / 2, p->p.loop);
   }
 
   if (state > NEIGHBOR_EXSTART)
@@ -235,7 +235,7 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
       ospf_neigh_chstate(n, NEIGHBOR_INIT);
 
     /* Restart inactivity timer */
-    tm_start(n->inactim, n->ifa->deadint S);
+    tm_start_in(n->inactim, n->ifa->deadint S, p->p.loop);
     break;
 
   case INM_2WAYREC:
@@ -385,7 +385,7 @@ ospf_neigh_start_graceful_restart(struct ospf_neighbor *n, uint gr_time)
   p->gr_count++;
 
   n->gr_timer = tm_new_init(n->pool, graceful_restart_timeout, n, 0, 0);
-  tm_start(n->gr_timer, gr_time S);
+  tm_start_in(n->gr_timer, gr_time S, p->p.loop);
 }
 
 static void
@@ -496,7 +496,7 @@ ospf_neigh_notify_grace_lsa(struct ospf_neighbor *n, struct top_hash_entry *en)
     /* Exception for updating grace period */
     if (n->gr_active)
     {
-      tm_start(n->gr_timer, (period S) - (en->lsa.age S));
+      tm_start_in(n->gr_timer, (period S) - (en->lsa.age S), p->p.loop);
       return;
     }
 
index bde7d8051804ac6aa58592761c92b65aeea27fbe..0a5595473c97f59e17132c0194cef47816a21fb4 100644 (file)
@@ -296,7 +296,7 @@ ospf_start(struct proto *P)
   p->gr_time = c->gr_time;
   p->tick = c->tick;
   p->disp_timer = tm_new_init(P->pool_up, ospf_disp, p, p->tick S, 0);
-  tm_start(p->disp_timer, 100 MS);
+  tm_start_in(p->disp_timer, 100 MS, P->loop);
   p->lsab_size = 256;
   p->lsab_used = 0;
   p->lsab = mb_alloc(P->pool, p->lsab_size);
@@ -711,7 +711,7 @@ ospf_reconfigure(struct proto *P, struct proto_config *CF)
   p->gr_time = new->gr_time;
   p->tick = new->tick;
   p->disp_timer->recurrent = p->tick S;
-  tm_start(p->disp_timer, 10 MS);
+  tm_start_in(p->disp_timer, 10 MS, P->loop);
 
   /* Mark all areas and ifaces */
   WALK_LIST(oa, p->area_list)
index b9b992a5b4d3b12e76cff7a127e3b1d713220763..939aad732c16a22956dcd4844f0e08ea3134a9b2 100644 (file)
@@ -1350,7 +1350,7 @@ ospf_rt_abr2(struct ospf_proto *p)
          oa->translator_timer = tm_new_init(p->p.pool, translator_timer_hook, oa, 0, 0);
 
        /* Schedule the end of translation */
-       tm_start(oa->translator_timer, oa->ac->transint S);
+       tm_start_in(oa->translator_timer, oa->ac->transint S, p->p.loop);
        oa->translate = TRANS_WAIT;
       }
     }