diff options
author | Maria Matejka <mq@ucw.cz> | 2021-06-21 17:07:31 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2021-11-22 18:33:53 +0100 |
commit | f81702b7e44ba7f2b264fe14f0f4e1e30913e475 (patch) | |
tree | a40097fcf4687f1b9d33a3ba794e38898bfbab4f /sysdep/unix/krt.c | |
parent | 3a8197a9dce6fc5d38b089a291ac79d8d394fea1 (diff) |
Table import and export are now explicit hooks.
Channels have now included rt_import_req and rt_export_req to hook into
the table instead of just one list node. This will (in future) allow for:
* channel import and export bound to different tables
* more efficient pipe code (dropping most of the channel code)
* conversion of 'show route' to a special kind of export
* temporary static routes from CLI
The import / export states are also updated to the new algorithms.
Diffstat (limited to 'sysdep/unix/krt.c')
-rw-r--r-- | sysdep/unix/krt.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index 32bfe7fc..40a58442 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -542,6 +542,29 @@ krt_is_installed(struct krt_proto *p, net *n) return n->routes && bmap_test(&p->p.main_channel->export_map, n->routes->rte.id); } +static uint +rte_feed_count(net *n) +{ + uint count = 0; + for (struct rte_storage *e = n->routes; e; e = e->next) + if (rte_is_valid(RTE_OR_NULL(e))) + count++; + return count; +} + +static void +rte_feed_obtain(net *n, rte **feed, uint count) +{ + uint i = 0; + for (struct rte_storage *e = n->routes; e; e = e->next) + if (rte_is_valid(RTE_OR_NULL(e))) + { + ASSERT_DIE(i < count); + feed[i++] = &e->rte; + } + ASSERT_DIE(i == count); +} + static struct rte * krt_export_net(struct krt_proto *p, net *net) { @@ -549,7 +572,15 @@ krt_export_net(struct krt_proto *p, net *net) const struct filter *filter = c->out_filter; if (c->ra_mode == RA_MERGED) - return rt_export_merged_show(c, net, krt_filter_lp); + { + uint count = rte_feed_count(net); + if (!count) + return NULL; + + rte **feed = alloca(count * sizeof(rte *)); + rte_feed_obtain(net, feed, count); + return rt_export_merged(c, feed, count, krt_filter_lp, 1); + } static _Thread_local rte rt; rt = net->routes->rte; |