[RFC PATCH 17/20] adapt mrt filters

Asbjørn Sloth Tønnesen ast at 2e8.dk
Mon Dec 30 17:56:43 CET 2019


---
 proto/mrt/mrt.c | 17 +++++++++++++++--
 proto/mrt/mrt.h |  2 ++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/proto/mrt/mrt.c b/proto/mrt/mrt.c
index 7a396a84..bc20e5c6 100644
--- a/proto/mrt/mrt.c
+++ b/proto/mrt/mrt.c
@@ -483,6 +483,8 @@ mrt_rib_table_dump(struct mrt_table_dump_state *s, net *n, int add_path)
   mrt_init_message(&s->buf, MRT_TABLE_DUMP_V2, subtype);
   mrt_rib_table_header(s, n->n.addr);
 
+  const struct filter *f = s->filters[s->table->addr_type];
+
   rte *rt, *rt0;
   for (rt0 = n->routes; rt = rt0; rt0 = rt0->next)
   {
@@ -498,7 +500,7 @@ mrt_rib_table_dump(struct mrt_table_dump_state *s, net *n, int add_path)
 
     rte_make_tmp_attrs(&rt, s->linpool, NULL);
 
-    if (f_run(s->filter, &rt, s->linpool, 0) <= F_ACCEPT)
+    if (f_run(f, &rt, s->linpool, 0) <= F_ACCEPT)
       mrt_rib_table_entry(s, rt);
 
     if (rt != rt0)
@@ -709,8 +711,13 @@ mrt_dump_cmd(struct mrt_dump_data *d)
   s->filter = d->filter;
   s->filename = d->filename;
 
-  if (s->table_ptr)
+  u32 net_type_mask = NB_IP;
+  if (s->table_ptr) {
     rt_lock_table(s->table_ptr);
+    net_type_mask = 1 << s->table_ptr->addr_type;
+  }
+
+  filters_adapt(&s->filters, s->filter, net_type_mask, config);
 
   this_cli->cont = mrt_dump_cont;
   this_cli->cleanup = mrt_dump_cleanup;
@@ -818,6 +825,12 @@ mrt_check_config(struct proto_config *CF)
 
   if (!cf->period)
     cf_error("Period not specified");
+
+  u32 net_type_mask = NB_IP;
+  if (cf->table_cf)
+    net_type_mask = cf->table_cf->addr_type;
+
+  filters_adapt(&cf->filters, cf->filter, net_type_mask, new_config);
 }
 
 static struct proto *
diff --git a/proto/mrt/mrt.h b/proto/mrt/mrt.h
index 4dfb1b19..1d4634e4 100644
--- a/proto/mrt/mrt.h
+++ b/proto/mrt/mrt.h
@@ -24,6 +24,7 @@ struct mrt_config {
   struct rtable_config *table_cf;
   const char *table_expr;
   const struct filter *filter;
+  const struct filter *filters[NET_MAX];
   const char *filename;
   uint period;
   int always_add_path;
@@ -62,6 +63,7 @@ struct mrt_table_dump_state {
   const char *table_expr;		/* Wildcard for table name (or NULL) */
   struct rtable *table_ptr;		/* Explicit table (or NULL) */
   const struct filter *filter;		/* Optional filter */
+  const struct filter *filters[NET_MAX];
   const char *filename;			/* Filename pattern */
   int always_add_path;			/* Always use *_ADDPATH message subtypes */
 
-- 
2.24.0



More information about the Bird-users mailing list