0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-18 17:18:42 +00:00

Table export announcer needs both an event and a timer to do export bundling the right way

This commit is contained in:
Maria Matejka 2022-09-09 19:09:31 +02:00
parent 974f16b1f7
commit 3d627d09d4
2 changed files with 21 additions and 13 deletions

View File

@ -1432,6 +1432,14 @@ rt_announce_exports(timer *tm)
}
}
static void
rt_kick_announce_exports(void *_tab)
{
RT_LOCKED((rtable *) _tab, tab)
if (!tm_active(tab->export_timer))
tm_start(tab->export_timer, tab->config->export_settle_time);
}
static void
rt_import_announce_exports(void *_hook)
{
@ -1455,9 +1463,7 @@ rt_import_announce_exports(void *_hook)
}
rt_trace(tab, D_EVENTS, "Announcing exports after imports from %s", hook->req->name);
if (!tm_active(tab->exporter.export_timer))
tm_start(tab->exporter.export_timer, tab->config->export_settle_time);
ev_schedule(tab->export_event);
}
}
@ -2703,6 +2709,8 @@ rt_setup(pool *pp, struct rtable_config *cf)
t->rt_event = ev_new_init(p, rt_event, t);
t->nhu_event = ev_new_init(p, rt_next_hop_update, t);
t->export_event = ev_new_init(p, rt_kick_announce_exports, t);
t->export_timer = tm_new_init(p, rt_announce_exports, t, 0, 0);
t->prune_timer = tm_new_init(p, rt_prune_timer, t, 0, 0);
t->last_rt_change = t->gc_time = current_time();
@ -2712,7 +2720,6 @@ rt_setup(pool *pp, struct rtable_config *cf)
.addr_type = t->addr_type,
.rp = t->rp,
},
.export_timer = tm_new_init(p, rt_announce_exports, t, 0, 0),
.next_seq = 1,
};
@ -2852,8 +2859,8 @@ again:
FIB_ITERATE_END;
rt_trace(tab, D_EVENTS, "Prune done, scheduling export timer");
if (!tm_active(tab->exporter.export_timer))
tm_start(tab->exporter.export_timer, tab->config->export_settle_time);
if (!tm_active(tab->export_timer))
tm_start(tab->export_timer, tab->config->export_settle_time);
#ifdef DEBUGGING
fib_check(&tab->fib);
@ -3078,8 +3085,8 @@ done:;
ev_schedule(tab->rt_event);
if (EMPTY_LIST(tab->exporter.pending) && tm_active(tab->exporter.export_timer))
tm_stop(tab->exporter.export_timer);
if (EMPTY_LIST(tab->exporter.pending) && tm_active(tab->export_timer))
tm_stop(tab->export_timer);
}
static void
@ -3704,8 +3711,8 @@ rt_next_hop_update(void *_tab)
rt_trace(tab, D_STATES, "Next hop updater corked");
if ((tab->nhu_state & NHU_RUNNING)
&& !EMPTY_LIST(tab->exporter.pending)
&& !tm_active(tab->exporter.export_timer))
tm_start(tab->exporter.export_timer, tab->config->export_settle_time);
&& !tm_active(tab->export_timer))
tm_start(tab->export_timer, tab->config->export_settle_time);
tab->nhu_corked = tab->nhu_state;
tab->nhu_state = 0;
@ -3744,8 +3751,8 @@ rt_next_hop_update(void *_tab)
/* Finished NHU, cleanup */
rt_trace(tab, D_EVENTS, "NHU done, scheduling export timer");
if (!tm_active(tab->exporter.export_timer))
tm_start(tab->exporter.export_timer, tab->config->export_settle_time);
if (!tm_active(tab->export_timer))
tm_start(tab->export_timer, tab->config->export_settle_time);
/* State change:
* NHU_DIRTY -> NHU_SCHEDULED

View File

@ -85,7 +85,6 @@ struct rt_exporter {
struct rt_table_exporter {
struct rt_exporter e;
list pending; /* List of packed struct rt_pending_export */
struct timer *export_timer;
struct rt_pending_export *first; /* First export to announce */
u64 next_seq; /* The next export will have this ID */
@ -129,6 +128,8 @@ struct rtable_private {
*/
struct event *rt_event; /* Routing table event */
struct event *nhu_event; /* Specific event for next hop update */
struct event *export_event; /* Event for export batching */
struct timer *export_timer; /* Timer for export batching */
struct timer *prune_timer; /* Timer for periodic pruning / GC */
btime last_rt_change; /* Last time when route changed */
btime gc_time; /* Time of last GC */