[RFC PATCH 16/20] adapt sh route filters
Asbjørn Sloth Tønnesen
ast at 2e8.dk
Mon Dec 30 17:56:42 CET 2019
---
nest/route.h | 1 +
nest/rt-show.c | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/nest/route.h b/nest/route.h
index eaaa5c3f..74cb55f4 100644
--- a/nest/route.h
+++ b/nest/route.h
@@ -344,6 +344,7 @@ struct rt_show_data {
struct fib_iterator fit; /* Iterator over networks in table */
int verbose, tables_defined_by;
const struct filter *filter;
+ const struct filter *filters[NET_MAX];
struct proto *show_protocol;
struct proto *export_protocol;
struct channel *export_channel;
diff --git a/nest/rt-show.c b/nest/rt-show.c
index 3431293a..f36bfe6f 100644
--- a/nest/rt-show.c
+++ b/nest/rt-show.c
@@ -107,6 +107,8 @@ rt_show_net(struct cli *c, net *n, struct rt_show_data *d)
int first = 1;
int pass = 0;
+ const struct filter *f = d->filters[d->tab->table->addr_type];
+
bsnprintf(ia, sizeof(ia), "%N", n->n.addr);
for (e = n->routes; e; e = e->next)
@@ -178,7 +180,7 @@ rt_show_net(struct cli *c, net *n, struct rt_show_data *d)
if (d->show_protocol && (d->show_protocol != e->attrs->src->proto))
goto skip;
- if (f_run(d->filter, &e, c->show_pool, 0) > F_ACCEPT)
+ if (f_run(f, &e, c->show_pool, 0) > F_ACCEPT)
goto skip;
if (d->stats < 2)
@@ -342,6 +344,7 @@ static inline void
rt_show_prepare_tables(struct rt_show_data *d)
{
struct rt_show_data_rtable *tab, *tabx;
+ u32 net_type_mask = 0;
/* Add implicit tables if no table is specified */
if (EMPTY_LIST(d->tables))
@@ -378,8 +381,12 @@ rt_show_prepare_tables(struct rt_show_data *d)
rem_node(&(tab->n));
continue;
}
+
+ net_type_mask |= 1 << tab->table->addr_type;
}
+ filters_adapt(&d->filters, d->filter, net_type_mask, d->running_on_config);
+
/* Ensure there is at least one table */
if (EMPTY_LIST(d->tables))
cf_error("No valid tables");
--
2.24.0
More information about the Bird-users
mailing list