diff --git a/nest/proto.c b/nest/proto.c index 1d480ba2..bc98f94d 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -225,10 +225,10 @@ void rt_notify_merged(struct rt_export_request *req, const net_addr *net, struct 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; rt_lock_table(c->table); @@ -253,9 +253,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); @@ -268,6 +271,9 @@ void 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); @@ -400,7 +406,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_keep & RIK_PREFILTER) == RIK_PREFILTER) : !!c->out_table; #endif @@ -671,7 +677,7 @@ channel_do_start(struct channel *c) { c->proto->active_channels++; - CALL(c->channel->start, c); + CALL(c->class->start, c); channel_start_import(c); } @@ -718,7 +724,7 @@ channel_do_stop(struct channel *c) if (c->gr_lock) channel_graceful_restart_unlock(c); - CALL(c->channel->shutdown, c); + CALL(c->class->shutdown, c); } @@ -737,7 +743,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)) @@ -871,7 +877,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; @@ -910,12 +916,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; } @@ -963,7 +969,7 @@ channel_reconfigure(struct channel *c, struct channel_config *cf) c->rpki_reload = cf->rpki_reload; /* 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 */ diff --git a/nest/protocol.h b/nest/protocol.h index 0b927446..c20d743d 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -453,7 +453,8 @@ extern struct channel_class channel_snmp; 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 */ @@ -478,8 +479,9 @@ struct channel { node n; /* Node in proto->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 */ diff --git a/nest/rt-table.c b/nest/rt-table.c index 65fc142a..6a15f474 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -3441,7 +3441,7 @@ rt_flowspec_resolve_rte(rte *r, struct channel *c) struct bgp_channel *bc = (struct bgp_channel *) c; if ( (rt_get_source_attr(r) == RTS_BGP) - && (c->channel == &channel_bgp) + && (c->class == &channel_bgp) && (bc->base_table)) { struct bgp_proto *p = SKIP_BACK(struct bgp_proto, p, bc->c.proto); diff --git a/proto/pipe/pipe.c b/proto/pipe/pipe.c index 8af6de81..0b783c9c 100644 --- a/proto/pipe/pipe.c +++ b/proto/pipe/pipe.c @@ -145,7 +145,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, .out_subprefix = cc->out_subprefix, @@ -157,7 +157,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, .out_subprefix = cf->in_subprefix,