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;
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);
{
ASSERT(c->channel_state == CS_DOWN);
+ c->config->channel = NULL;
+ c->config = NULL;
+
CD(c, "Removed", c->name);
rem_node(&c->n);
#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
channel_reset_limit(&c->in_limit);
channel_reset_limit(&c->out_limit);
- CALL(c->channel->start, c);
+ CALL(c->class->start, c);
}
static void
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);
/* 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))
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;
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;
}
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 */
}
/* 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));
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 */
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 */
{
channel_show_info(&c->c);
- if (c->c.channel != &channel_bgp)
+ if (c->c.class != &channel_bgp)
continue;
if (p->gr_active_num)
#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