]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Route subscription uses events
authorMaria Matejka <mq@jmq.cz>
Wed, 27 Oct 2021 12:42:05 +0000 (12:42 +0000)
committerMaria Matejka <mq@ucw.cz>
Mon, 22 Nov 2021 18:05:44 +0000 (19:05 +0100)
nest/proto.c
nest/route.h
nest/rt-table.c

index f55f347ac3ad87d6aac195eefa271d450851e8d2..35af3c6c8d9a729999a92cdddbb8fdb74fc5c110 100644 (file)
@@ -319,9 +319,9 @@ proto_remove_channels(struct proto *p)
 }
 
 static void
-channel_roa_in_changed(struct rt_subscription *s)
+channel_roa_in_changed(void *_data)
 {
-  struct channel *c = s->data;
+  struct channel *c = _data;
 
   CD(c, "Reload triggered by RPKI change");
 
@@ -329,9 +329,9 @@ channel_roa_in_changed(struct rt_subscription *s)
 }
 
 static void
-channel_roa_out_changed(struct rt_subscription *s)
+channel_roa_out_changed(void *_data)
 {
-  struct channel *c = s->data;
+  struct channel *c = _data;
   CD(c, "Feeding triggered by RPKI change");
 
   c->refeed_pending = 1;
@@ -349,14 +349,14 @@ struct roa_subscription {
 static int
 channel_roa_is_subscribed(struct channel *c, rtable *tab, int dir)
 {
-  void (*hook)(struct rt_subscription *) =
+  void (*hook)(void *) =
     dir ? channel_roa_in_changed : channel_roa_out_changed;
 
   struct roa_subscription *s;
   node *n;
 
   WALK_LIST2(s, n, c->roa_subscriptions, roa_node)
-    if ((s->s.tab == tab) && (s->s.hook == hook))
+    if ((s->s.tab == tab) && (s->s.event->hook == hook))
       return 1;
 
   return 0;
@@ -370,9 +370,9 @@ channel_roa_subscribe(struct channel *c, rtable *tab, int dir)
     return;
 
   struct roa_subscription *s = mb_allocz(c->proto->pool, sizeof(struct roa_subscription));
+  s->s.event = ev_new_init(c->proto->pool, dir ? channel_roa_in_changed : channel_roa_out_changed, c);
+  s->s.event->list = proto_work_list(c->proto);
 
-  s->s.hook = dir ? channel_roa_in_changed : channel_roa_out_changed;
-  s->s.data = c;
   rt_subscribe(tab, &s->s);
 
   add_tail(&c->roa_subscriptions, &s->roa_node);
@@ -383,6 +383,7 @@ channel_roa_unsubscribe(struct roa_subscription *s)
 {
   rt_unsubscribe(&s->s);
   rem_node(&s->roa_node);
+  rfree(s->s.event);
   mb_free(s);
 }
 
index e2dc9986b1db864be062dea75afabf98e53bb622..683c966ea7a863bf2fc25f15755ea254aa3036b2 100644 (file)
@@ -213,8 +213,7 @@ typedef struct rtable {
 struct rt_subscription {
   node n;
   rtable *tab;
-  void (*hook)(struct rt_subscription *b);
-  void *data;
+  event *event;
 };
 
 #define NHU_CLEAN      0
index e307449a39abf8ef6b2dcaeb6da90f7a4a2fa586..fb0496bd1c2b16468e7e642d407f4147e614f492 100644 (file)
@@ -1979,7 +1979,7 @@ rt_settle_timer(timer *t)
 
   struct rt_subscription *s;
   WALK_LIST(s, tab->subscribers)
-    s->hook(s);
+    ev_send(s->event->list, s->event);
 }
 
 static void