]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
babel: move babel into its own loop kk-babel-to-loop
authorKaterina Kubecova <katerina.kubecova@nic.cz>
Fri, 25 Apr 2025 14:19:25 +0000 (16:19 +0200)
committerKaterina Kubecova <katerina.kubecova@nic.cz>
Wed, 7 May 2025 15:40:37 +0000 (17:40 +0200)
nest/rt-dev.c
proto/babel/babel.c
proto/babel/config.Y
proto/babel/packets.c

index 8a8d6d6def5e181bb7e30ae965280b02d22617c0..bfae44f200ef2160f5de78d3b8fc6355bfb1ca20 100644 (file)
@@ -191,6 +191,7 @@ struct protocol proto_device = {
   .channel_mask =      NB_IP | NB_IP6_SADR,
   .proto_size =                sizeof(struct rt_dev_proto),
   .config_size =       sizeof(struct rt_dev_config),
+  .startup =           PROTOCOL_STARTUP_GENERATOR,
   .postconfig =                dev_postconfig,
   .init =              dev_init,
   .reconfigure =       dev_reconfigure,
index e249938addcb55c559b4ed31c2aae20d01f1d00b..0a11722f90f62ced2f5b0e352d64a5c866263c60 100644 (file)
@@ -311,6 +311,7 @@ babel_add_seqno_request(struct babel_proto *p, struct babel_entry *e,
                        u64 router_id, u16 seqno, u8 hop_count,
                        struct babel_neighbor *target)
 {
+  ASSERT_DIE(birdloop_inside(p->p.loop));
   struct babel_seqno_request *sr;
   btime now_ = current_time();
 
@@ -1214,6 +1215,7 @@ babel_handle_ack_req(union babel_msg *m, struct babel_iface *ifa)
 {
   struct babel_proto *p = ifa->proto;
   struct babel_msg_ack_req *msg = &m->ack_req;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
 
   TRACE(D_PACKETS, "Handling ACK request nonce %d interval %t",
        msg->nonce, (btime) msg->interval);
@@ -1226,6 +1228,7 @@ babel_handle_hello(union babel_msg *m, struct babel_iface *ifa)
 {
   struct babel_proto *p = ifa->proto;
   struct babel_msg_hello *msg = &m->hello;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
 
   TRACE(D_PACKETS, "Handling hello seqno %d interval %t",
        msg->seqno, (btime) msg->interval);
@@ -1258,6 +1261,7 @@ babel_handle_ihu(union babel_msg *m, struct babel_iface *ifa)
 {
   struct babel_proto *p = ifa->proto;
   struct babel_msg_ihu *msg = &m->ihu;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
 
   /* Ignore IHUs that are not about us */
   if ((msg->ae != BABEL_AE_WILDCARD) && !ipa_equal(msg->addr, ifa->addr))
@@ -1321,6 +1325,7 @@ babel_handle_update(union babel_msg *m, struct babel_iface *ifa)
 {
   struct babel_proto *p = ifa->proto;
   struct babel_msg_update *msg = &m->update;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
 
   struct babel_neighbor *nbr;
   struct babel_entry *e;
@@ -1451,6 +1456,7 @@ babel_handle_route_request(union babel_msg *m, struct babel_iface *ifa)
 {
   struct babel_proto *p = ifa->proto;
   struct babel_msg_route_request *msg = &m->route_request;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
 
   /* RFC 8966 3.8.1.1 */
 
@@ -1509,6 +1515,7 @@ babel_handle_seqno_request(union babel_msg *m, struct babel_iface *ifa)
 {
   struct babel_proto *p = ifa->proto;
   struct babel_msg_seqno_request *msg = &m->seqno_request;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
 
   /* RFC 8966 3.8.1.2 */
 
@@ -1573,6 +1580,7 @@ babel_handle_seqno_request(union babel_msg *m, struct babel_iface *ifa)
 void
 babel_auth_reset_index(struct babel_iface *ifa)
 {
+  ASSERT_DIE(birdloop_inside(ifa->proto->p.loop));
   random_bytes(ifa->auth_index, BABEL_AUTH_INDEX_LEN);
   ifa->auth_pc = 1;
 }
@@ -1620,6 +1628,7 @@ babel_auth_check_pc(struct babel_iface *ifa, struct babel_msg_auth *msg)
 {
   struct babel_proto *p = ifa->proto;
   struct babel_neighbor *n;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
 
   /*
    * We create the neighbour entry at this point because it makes it easier to
@@ -1757,14 +1766,14 @@ babel_iface_timer(timer *t)
 
   btime next_event = MIN(ifa->next_hello, ifa->next_regular);
   if (ifa->want_triggered) next_event = MIN(next_event, ifa->next_triggered);
-  tm_set(ifa->timer, next_event);
+  tm_set_in(ifa->timer, next_event, ifa->proto->p.loop);
 }
 
 static inline void
 babel_iface_kick_timer(struct babel_iface *ifa)
 {
   if (ifa->timer->expires > (current_time() + 100 MS))
-    tm_start(ifa->timer, 100 MS);
+    tm_start_in(ifa->timer, 100 MS, ifa->proto->p.loop);
 }
 
 static void
@@ -1778,7 +1787,7 @@ babel_iface_start(struct babel_iface *ifa)
   ifa->next_regular = current_time() + (random() % ifa->cf->update_interval);
   ifa->next_triggered = current_time() + MIN(1 S, ifa->cf->update_interval / 2);
   ifa->want_triggered = 0;     /* We send an immediate update (below) */
-  tm_start(ifa->timer, 100 MS);
+  tm_start_in(ifa->timer, 100 MS, p->p.loop);
   ifa->up = 1;
 
   babel_send_hello(ifa, 0);
@@ -1943,7 +1952,7 @@ babel_add_iface(struct babel_proto *p, struct iface *new, struct babel_iface_con
     .hook = babel_iface_locked,
     .data = ifa,
   };
-  lock->target = &global_event_list;
+  lock->target = proto_event_list(&p->p);
 
   olock_acquire(lock);
 }
@@ -2415,6 +2424,7 @@ static void
 babel_timer(timer *t)
 {
   struct babel_proto *p = t->data;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
 
   babel_expire_routes(p);
   babel_expire_neighbors(p);
@@ -2424,7 +2434,7 @@ static inline void
 babel_kick_timer(struct babel_proto *p)
 {
   if (p->timer->expires > (current_time() + 100 MS))
-    tm_start(p->timer, 100 MS);
+    tm_start_in(p->timer, 100 MS, p->p.loop);
 }
 
 
@@ -2598,7 +2608,7 @@ babel_start(struct proto *P)
 
   init_list(&p->interfaces);
   p->timer = tm_new_init(P->pool, babel_timer, p, 1 S, 0);
-  tm_start(p->timer, 1 S);
+  tm_start_in(p->timer, 1 S, P->loop);
   p->update_seqno = 1;
   p->router_id = proto_get_router_id(&cf->c);
 
index 5ca74c182ba599733defbeb09bc5b2c4e2d11fba..5aa8b602c5d6d29e970995b37e1724927f118ddb 100644 (file)
@@ -63,6 +63,7 @@ babel_iface_start:
   init_list(&this_ipatt->ipn_list);
   reset_passwords();
 
+  this_proto->loop_order = DOMAIN_ORDER(proto);
   BABEL_IFACE->port = BABEL_PORT;
   BABEL_IFACE->type = BABEL_IFACE_TYPE_WIRED;
   BABEL_IFACE->limit = BABEL_HELLO_LIMIT;
index 1c784c2135226421121b6c216a0c8702037429d2..6e3fc18981111296af7fcf81e31eba1e8873deae 100644 (file)
@@ -547,7 +547,6 @@ babel_read_ihu(struct babel_tlv *hdr, union babel_msg *m,
 {
   struct babel_tlv_ihu *tlv = (void *) hdr;
   struct babel_msg_ihu *msg = &m->ihu;
-
   msg->type = BABEL_TLV_IHU;
   msg->ae = tlv->ae;
   msg->rxcost = get_u16(&tlv->rxcost);
@@ -1520,6 +1519,7 @@ void
 babel_send_queue(void *arg)
 {
   struct babel_iface *ifa = arg;
+  ASSERT_DIE(birdloop_inside(ifa->proto->p.loop));
   while ((babel_write_queue(ifa, &ifa->msg_queue) > 0) &&
         (babel_send_to(ifa, IP6_BABEL_ROUTERS) > 0));
 }
@@ -1533,7 +1533,7 @@ babel_kick_queue(struct babel_iface *ifa)
    */
 
   if ((ifa->sk->tpos == ifa->sk->tbuf) && !ev_active(ifa->send_event))
-    ev_schedule(ifa->send_event);
+    ev_send(proto_event_list(&ifa->proto->p), ifa->send_event);
 }
 
 /**
@@ -1550,6 +1550,7 @@ void
 babel_send_unicast(union babel_msg *msg, struct babel_iface *ifa, ip_addr dest)
 {
   struct babel_proto *p = ifa->proto;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
   struct babel_msg_node *msgn = sl_alloc(p->msg_slab);
   list queue;
 
@@ -1579,6 +1580,7 @@ void
 babel_enqueue(union babel_msg *msg, struct babel_iface *ifa)
 {
   struct babel_proto *p = ifa->proto;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
   struct babel_msg_node *msgn = sl_alloc(p->msg_slab);
 
   *msgn = (struct babel_msg_node) { .msg = *msg };
@@ -1764,6 +1766,7 @@ int
 babel_open_socket(struct babel_iface *ifa)
 {
   struct babel_proto *p = ifa->proto;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
 
   sock *sk;
   sk = sk_new(ifa->pool);
@@ -2030,6 +2033,7 @@ babel_auth_check(struct babel_iface *ifa,
 {
   uint frame_err UNUSED = 0;
   struct babel_proto *p = ifa->proto;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
   struct babel_tlv *tlv;
 
   struct babel_parse_state state = {
@@ -2099,6 +2103,7 @@ int
 babel_auth_add_tlvs(struct babel_iface *ifa, struct babel_tlv *hdr, uint max_len)
 {
   struct babel_proto *p = ifa->proto;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
   struct babel_tlv_pc *tlv;
   uint len;
 
@@ -2139,6 +2144,7 @@ int
 babel_auth_sign(struct babel_iface *ifa, ip_addr dest)
 {
   struct babel_proto *p = ifa->proto;
+  ASSERT_DIE(birdloop_inside(p->p.loop));
   sock *sk = ifa->sk;
 
   if (ifa->cf->auth_type == BABEL_AUTH_NONE)
@@ -2193,6 +2199,7 @@ babel_auth_sign(struct babel_iface *ifa, ip_addr dest)
 void
 babel_auth_set_tx_overhead(struct babel_iface *ifa)
 {
+  ASSERT_DIE(birdloop_inside(ifa->proto->p.loop));
   if (ifa->cf->auth_type == BABEL_AUTH_NONE)
   {
     ifa->auth_tx_overhead = 0;