summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2018-01-16 16:20:01 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2018-01-16 16:20:01 +0100
commitb94057911554e04df9b709f8354e2e220131096a (patch)
tree411495bfa60fccc6b685346f3fb6543ab54fed2f /filter
parent0ff86d054efa8005c5df943acf6d2122781d3175 (diff)
Filter: Allow silent filter execution
A filter should log messages only if executed explicitly (e.g., during route export or route import). When a filter is executed for technical reasons (e.g., to establish whether a route was exported before), it should run silently.
Diffstat (limited to 'filter')
-rw-r--r--filter/filter.c9
-rw-r--r--filter/filter.h1
2 files changed, 7 insertions, 3 deletions
diff --git a/filter/filter.c b/filter/filter.c
index 1e8f7d5a..b0c56046 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -590,7 +590,8 @@ f_rta_cow(void)
static struct tbf rl_runtime_err = TBF_DEFAULT_LOG_LIMITS;
#define runtime(x) do { \
- log_rl(&rl_runtime_err, L_ERR "filters, line %d: %s", what->lineno, x); \
+ if (!(f_flags & FF_SILENT)) \
+ log_rl(&rl_runtime_err, L_ERR "filters, line %d: %s", what->lineno, x); \
res.type = T_RETURN; \
res.val.i = F_ERROR; \
return res; \
@@ -889,7 +890,8 @@ interpret(struct f_inst *what)
break;
case P('p',','):
ONEARG;
- if (what->a2.i == F_NOP || (what->a2.i != F_NONL && what->a1.p))
+ if ((what->a2.i == F_NOP || (what->a2.i != F_NONL && what->a1.p)) &&
+ !(f_flags & FF_SILENT))
log_commit(*L_INFO, &f_buf);
switch (what->a2.i) {
@@ -1723,7 +1725,8 @@ f_run(struct filter *filter, struct rte **rte, struct ea_list **tmp_attrs, struc
if (res.type != T_RETURN) {
- log_rl(&rl_runtime_err, L_ERR "Filter %s did not return accept nor reject. Make up your mind", filter->name);
+ if (!(f_flags & FF_SILENT))
+ log_rl(&rl_runtime_err, L_ERR "Filter %s did not return accept nor reject. Make up your mind", filter->name);
return F_ERROR;
}
DBG( "done (%u)\n", res.val.i );
diff --git a/filter/filter.h b/filter/filter.h
index 72b37461..efb4b978 100644
--- a/filter/filter.h
+++ b/filter/filter.h
@@ -227,5 +227,6 @@ struct f_trie
#define NEW_F_VAL struct f_val * val; val = cfg_alloc(sizeof(struct f_val));
#define FF_FORCE_TMPATTR 1 /* Force all attributes to be temporary */
+#define FF_SILENT 2 /* Silent filter execution */
#endif