]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Nest: Rename channel class
authorVojtech Vilimek <vojtech.vilimek@nic.cz>
Wed, 21 Aug 2024 08:54:36 +0000 (10:54 +0200)
committerVojtech Vilimek <vojtech.vilimek@nic.cz>
Wed, 21 Aug 2024 09:24:38 +0000 (11:24 +0200)
nest/proto.c
nest/protocol.h
proto/bgp/attrs.c
proto/bgp/bgp.c
proto/bgp/bgp.h
proto/pipe/pipe.c

index 88f4813ef572de5ca5a92cd360e4ca3dbf062815..6caf6dc2e172c4dc886a581a6f7ca0c932a1dea1 100644 (file)
@@ -159,10 +159,10 @@ proto_find_channel_by_name(struct proto *p, const char *n)
 struct channel *
 proto_add_channel(struct proto *p, struct channel_config *cf)
 {
-  struct channel *c = mb_allocz(proto_pool, cf->channel->channel_size);
+  struct channel *c = mb_allocz(proto_pool, cf->class->channel_size);
 
   c->name = cf->name;
-  c->channel = cf->channel;
+  c->class = cf->class;
   c->proto = p;
   c->table = cf->table->table;
 
@@ -186,9 +186,12 @@ proto_add_channel(struct proto *p, struct channel_config *cf)
   c->last_state_change = current_time();
   c->reloadable = 1;
 
+  c->config = cf;
+  cf->channel = c;
+
   init_list(&c->roa_subscriptions);
 
-  CALL(c->channel->init, c, cf);
+  CALL(c->class->init, c, cf);
 
   add_tail(&p->channels, &c->n);
 
@@ -202,6 +205,9 @@ proto_remove_channel(struct proto *p UNUSED, struct channel *c)
 {
   ASSERT(c->channel_state == CS_DOWN);
 
+  c->config->channel = NULL;
+  c->config = NULL;
+
   CD(c, "Removed", c->name);
 
   rem_node(&c->n);
@@ -399,7 +405,7 @@ channel_roa_subscribe_filter(struct channel *c, int dir)
 
 #ifdef CONFIG_BGP
   /* No automatic reload for BGP channels without in_table / out_table */
-  if (c->channel == &channel_bgp)
+  if (c->class == &channel_bgp)
     valid = dir ? !!c->in_table : !!c->out_table;
 #endif
 
@@ -558,7 +564,7 @@ channel_do_start(struct channel *c)
   channel_reset_limit(&c->in_limit);
   channel_reset_limit(&c->out_limit);
 
-  CALL(c->channel->start, c);
+  CALL(c->class->start, c);
 }
 
 static void
@@ -582,7 +588,7 @@ channel_do_flush(struct channel *c)
   if (c->gr_lock)
     channel_graceful_restart_unlock(c);
 
-  CALL(c->channel->shutdown, c);
+  CALL(c->class->shutdown, c);
 
   /* This have to be done in here, as channel pool is freed before channel_do_down() */
   bmap_free(&c->export_map);
@@ -614,7 +620,7 @@ channel_do_down(struct channel *c)
 
   /* The in_table and out_table are going to be freed by freeing their resource pools. */
 
-  CALL(c->channel->cleanup, c);
+  CALL(c->class->cleanup, c);
 
   /* Schedule protocol shutddown */
   if (proto_is_done(c->proto))
@@ -776,7 +782,7 @@ channel_config_new(const struct channel_class *cc, const char *name, uint net_ty
 
   cf = cfg_allocz(cc->config_size);
   cf->name = name;
-  cf->channel = cc;
+  cf->class = cc;
   cf->parent = proto;
   cf->table = tab;
   cf->out_filter = FILTER_REJECT;
@@ -816,12 +822,12 @@ channel_config_get(const struct channel_class *cc, const char *name, uint net_ty
 struct channel_config *
 channel_copy_config(struct channel_config *src, struct proto_config *proto)
 {
-  struct channel_config *dst = cfg_alloc(src->channel->config_size);
+  struct channel_config *dst = cfg_alloc(src->class->config_size);
 
-  memcpy(dst, src, src->channel->config_size);
+  memcpy(dst, src, src->class->config_size);
   memset(&dst->n, 0, sizeof(node));
   add_tail(&proto->channels, &dst->n);
-  CALL(src->channel->copy_config, dst, src);
+  CALL(src->class->copy_config, dst, src);
 
   return dst;
 }
@@ -867,7 +873,7 @@ channel_reconfigure(struct channel *c, struct channel_config *cf)
   channel_verify_limits(c);
 
   /* Execute channel-specific reconfigure hook */
-  if (c->channel->reconfigure && !c->channel->reconfigure(c, cf, &import_changed, &export_changed))
+  if (c->class->reconfigure && !c->class->reconfigure(c, cf, &import_changed, &export_changed))
     return 0;
 
   /* If the channel is not open, it has no routes and we cannot reload it anyways */
index c87d38148005deaea1ced73545fb291540031335..4f69a6a77b6fde735bd6a824580d9add9a77fd54 100644 (file)
@@ -487,7 +487,8 @@ extern const struct channel_class channel_bgp;
 struct channel_config {
   node n;
   const char *name;
-  const struct channel_class *channel;
+  const struct channel_class *class;
+  struct channel *channel;
 
   struct proto_config *parent;         /* Where channel is defined (proto or template) */
   struct rtable_config *table;         /* Table we're attached to */
@@ -513,8 +514,9 @@ struct channel {
   node table_node;                     /* Node in table->channels */
 
   const char *name;                    /* Channel name (may be NULL) */
-  const struct channel_class *channel;
+  const struct channel_class *class;
   struct proto *proto;
+  struct channel_config *config;
 
   struct rtable *table;
   const struct filter *in_filter;      /* Input filter */
index 5bd05fb26335d516d46a31b501f6bbc61357ad99..2a92d4e1375da4c1fca8dcb53094611dfb83fb64 100644 (file)
@@ -1741,7 +1741,7 @@ bgp_preexport(struct channel *C, rte *e)
   struct bgp_channel *c = (struct bgp_channel *) C;
 
   /* Ignore non-BGP channels */
-  if (C->channel != &channel_bgp)
+  if (C->class != &channel_bgp)
     return -1;
 
   /* Reject our routes */
@@ -1942,7 +1942,7 @@ bgp_rt_notify(struct proto *P, struct channel *C, net *n, rte *new, rte *old)
   u32 path;
 
   /* Ignore non-BGP channels */
-  if (C->channel != &channel_bgp)
+  if (C->class != &channel_bgp)
     return;
 
   if (new)
index bd6e90d6e454f203b289abb2306cfbb52bb2e604..69950bdb0aae520b486b92e03a60cce12a0c4405 100644 (file)
@@ -1440,7 +1440,7 @@ bgp_reload_routes(struct channel *C)
   }
 
   /* Ignore non-BGP channels */
-  if (C->channel != &channel_bgp)
+  if (C->class != &channel_bgp)
     return;
 
   ASSERT(p->conn && (p->route_refresh || c->c.in_table));
@@ -1458,7 +1458,7 @@ bgp_feed_begin(struct channel *C, int initial)
   struct bgp_channel *c = (void *) C;
 
   /* Ignore non-BGP channels */
-  if (C->channel != &channel_bgp)
+  if (C->class != &channel_bgp)
     return;
 
   /* This should not happen */
@@ -1487,7 +1487,7 @@ bgp_feed_end(struct channel *C)
   struct bgp_channel *c = (void *) C;
 
   /* Ignore non-BGP channels */
-  if (C->channel != &channel_bgp)
+  if (C->class != &channel_bgp)
     return;
 
   /* This should not happen */
@@ -2682,7 +2682,7 @@ bgp_show_proto_info(struct proto *P)
     {
       channel_show_info(&c->c);
 
-      if (c->c.channel != &channel_bgp)
+      if (c->c.class != &channel_bgp)
        continue;
 
       if (p->gr_active_num)
index 7127bc88a38aad31d9bee4e68d57733a4bb8d3d5..b1da44a39b6c7fde4a7c6734def3eb0d11fa327a 100644 (file)
@@ -513,8 +513,8 @@ struct bgp_parse_state {
 #define BGP_RX_BUFFER_EXT_SIZE 65535
 #define BGP_TX_BUFFER_EXT_SIZE 65535
 
-#define BGP_CF_WALK_CHANNELS(P,C) WALK_LIST(C, P->c.channels) if (C->c.channel == &channel_bgp)
-#define BGP_WALK_CHANNELS(P,C) WALK_LIST(C, P->p.channels) if (C->c.channel == &channel_bgp)
+#define BGP_CF_WALK_CHANNELS(P,C) WALK_LIST(C, P->c.channels) if (C->c.class == &channel_bgp)
+#define BGP_WALK_CHANNELS(P,C) WALK_LIST(C, P->p.channels) if (C->c.class == &channel_bgp)
 
 #define BGP_MSG_HDR_MARKER_SIZE        16
 #define BGP_MSG_HDR_MARKER_POS 0
index d48ce3870f2b9469ae5bb272ddd2146f4299955e..cab3b331f1dd4777f7602435e15425ab06c52ff8 100644 (file)
@@ -140,7 +140,7 @@ pipe_configure_channels(struct pipe_proto *p, struct pipe_config *cf)
 
   struct channel_config pri_cf = {
     .name = "pri",
-    .channel = cc->channel,
+    .class = cc->class,
     .table = cc->table,
     .out_filter = cc->out_filter,
     .in_limit = cc->in_limit,
@@ -151,7 +151,7 @@ pipe_configure_channels(struct pipe_proto *p, struct pipe_config *cf)
 
   struct channel_config sec_cf = {
     .name = "sec",
-    .channel = cc->channel,
+    .class = cc->class,
     .table = cf->peer,
     .out_filter = cc->in_filter,
     .in_limit = cc->out_limit,