[RFC PATCH 07/20] add generic pseudo filter check function

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


---
 filter/filter.c | 9 +++++++--
 filter/filter.h | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/filter/filter.c b/filter/filter.c
index e505d570..b8147662 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -413,6 +413,12 @@ f_eval_buf(const struct f_line *expr, struct linpool *tmp_pool, buffer *buf)
   return fret;
 }
 
+int
+is_pseudo_filter(const struct filter *f)
+{
+  return f == FILTER_ACCEPT || f == FILTER_REJECT || f == FILTER_UNDEF;
+}
+
 /**
  * filter_same - compare two filters
  * @new: first filter to be compared
@@ -427,8 +433,7 @@ filter_same(const struct filter *new, const struct filter *old)
 {
   if (old == new)	/* Handle FILTER_ACCEPT and FILTER_REJECT */
     return 1;
-  if (old == FILTER_ACCEPT || old == FILTER_REJECT ||
-      new == FILTER_ACCEPT || new == FILTER_REJECT)
+  if (is_pseudo_filter(old) || is_pseudo_filter(new))
     return 0;
 
   if ((!old->sym) && (!new->sym))
diff --git a/filter/filter.h b/filter/filter.h
index 9d997efb..84b6b0be 100644
--- a/filter/filter.h
+++ b/filter/filter.h
@@ -58,6 +58,7 @@ enum filter_return f_eval_rte(const struct f_line *expr, struct rte **rte, struc
 uint f_eval_int(const struct f_line *expr);
 enum filter_return f_eval_buf(const struct f_line *expr, struct linpool *tmp_pool, buffer *buf);
 
+int is_pseudo_filter(const struct filter *f);
 const char *filter_name(const struct filter *filter);
 int filter_same(const struct filter *new, const struct filter *old);
 int f_same(const struct f_line *f1, const struct f_line *f2);
-- 
2.24.0



More information about the Bird-users mailing list