mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-31 22:21:54 +00:00
Route table export journal converted to the generic structure
This commit is contained in:
parent
3787c0f7a5
commit
08f67979ce
10
nest/proto.c
10
nest/proto.c
@ -659,7 +659,7 @@ channel_start_import(struct channel *c)
|
||||
c->in_req = (struct rt_import_request) {
|
||||
.name = mb_sprintf(c->proto->pool, "%s.%s", c->proto->name, c->name),
|
||||
.trace_routes = c->debug | c->proto->debug,
|
||||
.list = proto_work_list(c->proto),
|
||||
.loop = c->proto->loop,
|
||||
.dump_req = channel_dump_import_req,
|
||||
.log_state_change = channel_import_log_state_change,
|
||||
.preimport = channel_preimport,
|
||||
@ -731,7 +731,8 @@ channel_start_export(struct channel *c)
|
||||
}
|
||||
|
||||
c->refeed_req = c->out_req;
|
||||
c->refeed_req.name = mb_sprintf(p, "%s.%s.refeed", c->proto->name, c->name);
|
||||
c->refeed_req.pool = rp_newf(c->proto->pool, c->proto->pool->domain, "Channel %s.%s export refeed", c->proto->name, c->name);
|
||||
c->refeed_req.name = mb_sprintf(c->refeed_req.pool, "%s.%s.refeed", c->proto->name, c->name);
|
||||
c->refeed_req.dump_req = channel_dump_refeed_req;
|
||||
c->refeed_req.log_state_change = channel_refeed_log_state_change;
|
||||
c->refeed_req.mark_seen = channel_rpe_mark_seen_refeed;
|
||||
@ -829,6 +830,7 @@ channel_refeed_stopped(struct rt_export_request *req)
|
||||
req->hook = NULL;
|
||||
|
||||
channel_feed_end(c);
|
||||
channel_check_stopped(c);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -996,6 +998,8 @@ channel_reload_stopped(struct rt_export_request *req)
|
||||
{
|
||||
struct channel *c = SKIP_BACK(struct channel, reload_req, req);
|
||||
|
||||
req->hook = NULL;
|
||||
|
||||
/* Restart reload */
|
||||
if (c->reload_pending)
|
||||
{
|
||||
@ -1198,8 +1202,6 @@ channel_set_state(struct channel *c, uint state)
|
||||
void
|
||||
channel_request_feeding(struct channel *c, struct channel_feeding_request *cfr)
|
||||
{
|
||||
ASSERT_DIE(c->out_req.hook);
|
||||
|
||||
CD(c, "Feeding requested (%s)",
|
||||
cfr->type == CFRT_DIRECT ? "direct" :
|
||||
(cfr->trie ? "partial" : "auxiliary"));
|
||||
|
44
nest/route.h
44
nest/route.h
@ -12,6 +12,7 @@
|
||||
|
||||
#include "lib/lists.h"
|
||||
#include "lib/tlists.h"
|
||||
#include "lib/lockfree.h"
|
||||
#include "lib/bitmap.h"
|
||||
#include "lib/resource.h"
|
||||
#include "lib/net.h"
|
||||
@ -77,26 +78,6 @@ struct rt_export_hook;
|
||||
struct rt_export_request;
|
||||
struct rt_exporter;
|
||||
|
||||
struct rt_exporter_class {
|
||||
void (*start)(struct rt_exporter *, struct rt_export_request *);
|
||||
void (*stop)(struct rt_export_hook *);
|
||||
void (*done)(void *_rt_export_hook);
|
||||
};
|
||||
|
||||
struct rt_exporter {
|
||||
const struct rt_exporter_class *class;
|
||||
pool *rp;
|
||||
list hooks; /* Registered route export hooks */
|
||||
uint addr_type; /* Type of address data exported (NET_*) */
|
||||
|
||||
/* Table-specific */
|
||||
|
||||
list pending; /* List of packed struct rt_pending_export */
|
||||
|
||||
struct rt_pending_export *first; /* First export to announce */
|
||||
u64 next_seq; /* The next export will have this ID */
|
||||
};
|
||||
|
||||
extern uint rtable_max_id;
|
||||
|
||||
/* The public part of rtable structure */
|
||||
@ -130,7 +111,7 @@ struct rtable_private {
|
||||
u32 debug; /* Debugging flags (D_*) */
|
||||
|
||||
list imports; /* Registered route importers */
|
||||
struct rt_exporter exporter; /* Exporter API structure */
|
||||
struct lfjour journal; /* Exporter API structure */
|
||||
TLIST_STRUCT_DEF(rt_flowspec_link, struct rt_flowspec_link) flowspec_links; /* Links serving flowspec reload */
|
||||
|
||||
struct hmap id_map;
|
||||
@ -140,8 +121,8 @@ struct rtable_private {
|
||||
* obstacle from this routing table.
|
||||
*/
|
||||
struct event *nhu_uncork_event; /* Helper event to schedule NHU on uncork */
|
||||
struct settle export_settle; /* Export batching settle timer */
|
||||
struct timer *prune_timer; /* Timer for periodic pruning / GC */
|
||||
struct event *prune_event; /* Event for prune execution */
|
||||
struct birdloop_flag_handler fh; /* Handler for simple events */
|
||||
btime last_rt_change; /* Last time when route changed */
|
||||
btime gc_time; /* Time of last GC */
|
||||
@ -193,8 +174,6 @@ LOBJ_UNLOCK_CLEANUP(rtable, rtable);
|
||||
#define RT_PUB(tab) SKIP_BACK(rtable, priv, tab)
|
||||
|
||||
/* Flags for birdloop_flag() */
|
||||
#define RTF_CLEANUP 1
|
||||
#define RTF_EXPORT 4
|
||||
#define RTF_DELETE 8
|
||||
|
||||
extern struct rt_cork {
|
||||
@ -279,7 +258,7 @@ struct rt_import_request {
|
||||
char *name;
|
||||
u8 trace_routes;
|
||||
|
||||
event_list *list; /* Where to schedule announce events */
|
||||
struct birdloop *loop; /* Where to schedule cleanup event */
|
||||
|
||||
void (*dump_req)(struct rt_import_request *req);
|
||||
void (*log_state_change)(struct rt_import_request *req, u8 state);
|
||||
@ -312,13 +291,13 @@ struct rt_import_hook {
|
||||
u8 stale_pruning; /* Last prune started when this value was set at stale_valid */
|
||||
|
||||
void (*stopped)(struct rt_import_request *); /* Stored callback when import is stopped */
|
||||
event announce_event; /* This event announces table updates */
|
||||
event cleanup_event; /* Used to finally unhook the import from the table */
|
||||
};
|
||||
|
||||
struct rt_pending_export {
|
||||
LFJOUR_ITEM_INHERIT(li);
|
||||
struct rt_pending_export * _Atomic next; /* Next export for the same destination */
|
||||
const rte *new, *new_best, *old, *old_best;
|
||||
u64 seq; /* Sequential ID (table-local) of the pending export */
|
||||
};
|
||||
|
||||
struct rt_export_request {
|
||||
@ -365,8 +344,7 @@ static inline int rt_prefilter_net(const struct rt_prefilter *p, const net_addr
|
||||
}
|
||||
|
||||
struct rt_export_hook {
|
||||
node n;
|
||||
struct rt_exporter *table; /* The connected table */
|
||||
struct lfjour_recipient recipient; /* Journal recipient structure */
|
||||
|
||||
pool *pool;
|
||||
|
||||
@ -381,7 +359,7 @@ struct rt_export_hook {
|
||||
btime last_state_change; /* Time of last state transition */
|
||||
|
||||
_Atomic u8 export_state; /* Route export state (TES_*, see below) */
|
||||
struct event event; /* Event running all the export operations */
|
||||
struct event *event; /* Event running all the export operations */
|
||||
|
||||
struct bmap seq_map; /* Keep track which exports were already procesed */
|
||||
|
||||
@ -389,6 +367,7 @@ struct rt_export_hook {
|
||||
|
||||
/* Table-specific items */
|
||||
|
||||
rtable *tab; /* The table pointer to use in corner cases */
|
||||
union {
|
||||
u32 feed_index; /* Routing table iterator used during feeding */
|
||||
struct {
|
||||
@ -402,13 +381,11 @@ struct rt_export_hook {
|
||||
};
|
||||
};
|
||||
|
||||
struct rt_pending_export *_Atomic last_export;/* Last export processed */
|
||||
struct rt_pending_export *rpe_next; /* Next pending export to process */
|
||||
|
||||
u8 refeed_pending; /* Refeeding and another refeed is scheduled */
|
||||
u8 feed_type; /* Which feeding method is used (TFT_*, see below) */
|
||||
};
|
||||
|
||||
|
||||
#define TIS_DOWN 0
|
||||
#define TIS_UP 1
|
||||
#define TIS_STOP 2
|
||||
@ -673,7 +650,6 @@ struct rt_show_data {
|
||||
};
|
||||
|
||||
void rt_show(struct rt_show_data *);
|
||||
struct rt_show_data_rtable * rt_show_add_exporter(struct rt_show_data *d, struct rt_exporter *t, const char *name);
|
||||
struct rt_show_data_rtable * rt_show_add_table(struct rt_show_data *d, rtable *t);
|
||||
|
||||
/* Value of table definition mode in struct rt_show_data */
|
||||
|
@ -358,16 +358,16 @@ rt_show_export_stopped(struct rt_export_request *req)
|
||||
struct rt_show_data_rtable *
|
||||
rt_show_add_table(struct rt_show_data *d, rtable *t)
|
||||
{
|
||||
struct rt_show_data_rtable *rsdr = cfg_allocz(sizeof(struct rt_show_data_rtable));
|
||||
rsdr->table = t;
|
||||
rsdr->name = t->name;
|
||||
add_tail(&(d->tables), &(rsdr->n));
|
||||
struct rt_show_data_rtable *tab = cfg_allocz(sizeof(struct rt_show_data_rtable));
|
||||
tab->table = t;
|
||||
tab->name = t->name;
|
||||
add_tail(&(d->tables), &(tab->n));
|
||||
|
||||
struct proto_config *krt = t->config->krt_attached;
|
||||
if (krt)
|
||||
rsdr->kernel = (struct krt_proto *) krt->proto;
|
||||
tab->kernel = (struct krt_proto *) krt->proto;
|
||||
|
||||
return rsdr;
|
||||
return tab;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
891
nest/rt-table.c
891
nest/rt-table.c
File diff suppressed because it is too large
Load Diff
@ -1899,7 +1899,7 @@ bgp_free_pending_tx(struct bgp_channel *c)
|
||||
c->ptx = NULL;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Prefix hash table exporter
|
||||
*/
|
||||
@ -2057,6 +2057,11 @@ bgp_setup_out_table(struct bgp_channel *c)
|
||||
|
||||
c->c.out_table = &c->prefix_exporter;
|
||||
}
|
||||
#else
|
||||
void
|
||||
bgp_setup_out_table(struct bgp_channel *c)
|
||||
{}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
@ -396,7 +396,7 @@ struct bgp_channel {
|
||||
/* Rest are zeroed when down */
|
||||
pool *pool;
|
||||
struct bgp_pending_tx *ptx; /* Routes waiting to be sent */
|
||||
struct rt_exporter prefix_exporter; /* Table-like exporter for ptx */
|
||||
// struct rt_exporter prefix_exporter; /* Table-like exporter for ptx */
|
||||
|
||||
ip_addr next_hop_addr; /* Local address for NEXT_HOP attribute */
|
||||
ip_addr link_addr; /* Link-local version of next_hop_addr */
|
||||
|
Loading…
Reference in New Issue
Block a user