summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--grammar/rainerscript.c8
-rw-r--r--tests/Makefile.am3
-rwxr-xr-xtests/rs_optimizer_pri.sh17
-rw-r--r--tests/testsuites/rs_optimizer_pri.conf8
5 files changed, 35 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 3300c802..702662ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -51,6 +51,9 @@ Version 7.5.7 [v7-devel] 2013-11-??
* high water mark is now dynamically 90% of queue size
* low water makr is now dynamically 70% of queue size
* queue.workerThreadMinimumMessage set to queue.size / num workers
+- bugfix: RainerScript optimizer did not optimize PRI filters
+ things like "if $syslogfacility-text == "local3"" were not converted
+ to PRIFILT. This was a regression introduced in 7.5.6.
- bugfix: legacy directive $ActionQueueWorkerThreads was not honored
- bugfix: segfault on startup when certain script constructs are used
e.g. "if not $msg ..."
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c
index cc44bd3f..427e1abb 100644
--- a/grammar/rainerscript.c
+++ b/grammar/rainerscript.c
@@ -2884,7 +2884,7 @@ cnfexprOptimize_CMP_severity_facility(struct cnfexpr *expr)
if(expr->l->nodetype != 'V')
FINALIZE;
- if(!strcmp("$syslogseverity", ((struct cnfvar*)expr->l)->name)) {
+ if(!strcmp("syslogseverity", ((struct cnfvar*)expr->l)->name)) {
if(expr->r->nodetype == 'N') {
int sev = (int) ((struct cnfnumval*)expr->r)->val;
if(sev >= 0 && sev <= 7) {
@@ -2898,7 +2898,7 @@ cnfexprOptimize_CMP_severity_facility(struct cnfexpr *expr)
"evaluate to FALSE", sev);
}
}
- } else if(!strcmp("$syslogfacility", ((struct cnfvar*)expr->l)->name)) {
+ } else if(!strcmp("syslogfacility", ((struct cnfvar*)expr->l)->name)) {
if(expr->r->nodetype == 'N') {
int fac = (int) ((struct cnfnumval*)expr->r)->val;
if(fac >= 0 && fac <= 24) {
@@ -2926,7 +2926,7 @@ cnfexprOptimize_CMP_var(struct cnfexpr *expr)
{
struct cnffunc *func;
- if(!strcmp("$syslogfacility-text", ((struct cnfvar*)expr->l)->name)) {
+ if(!strcmp("syslogfacility-text", ((struct cnfvar*)expr->l)->name)) {
if(expr->r->nodetype == 'S') {
char *cstr = es_str2cstr(((struct cnfstringval*)expr->r)->estr, NULL);
int fac = decodeSyslogName((uchar*)cstr, syslogFacNames);
@@ -2944,7 +2944,7 @@ cnfexprOptimize_CMP_var(struct cnfexpr *expr)
}
free(cstr);
}
- } else if(!strcmp("$syslogseverity-text", ((struct cnfvar*)expr->l)->name)) {
+ } else if(!strcmp("syslogseverity-text", ((struct cnfvar*)expr->l)->name)) {
if(expr->r->nodetype == 'S') {
char *cstr = es_str2cstr(((struct cnfstringval*)expr->r)->estr, NULL);
int sev = decodeSyslogName((uchar*)cstr, syslogPriNames);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 070b2350..a2548a68 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -75,6 +75,7 @@ TESTS += \
rscript_prifilt.sh \
rscript_optimizer1.sh \
rscript_ruleset_call.sh \
+ rs_optimizer_pri.sh \
cee_simple.sh \
cee_diskqueue.sh \
incltest.sh \
@@ -299,6 +300,8 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/stop-localvar.conf \
global_vars.sh \
testsuites/global_vars.conf \
+ rs_optimizer_pri.sh \
+ testsuites/rs_optimizer_pr.conf \
rscript_prifilt.sh \
testsuites/rscript_prifilt.conf \
rscript_optimizer1.sh \
diff --git a/tests/rs_optimizer_pri.sh b/tests/rs_optimizer_pri.sh
new file mode 100755
index 00000000..4d6e4637
--- /dev/null
+++ b/tests/rs_optimizer_pri.sh
@@ -0,0 +1,17 @@
+# Test for the RainerScript optimizer, folding of
+# syslogfacility/priority-text to prifilt. Unfortunately, we cannot yet
+# automatically detect if the optimizer does not correctly fold, but we
+# can at least detect if it segfaults or otherwise creates incorrect code.
+# This file is part of the rsyslog project, released under ASL 2.0
+# rgerhards, 2013-11-20
+echo ===============================================================================
+echo \[rs_optimizer_pri.sh\]: testing RainerScript PRI optimizer
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup rs_optimizer_pri.conf
+sleep 1
+source $srcdir/diag.sh tcpflood -m100 # correct facility
+source $srcdir/diag.sh tcpflood -m100 -P175 # incorrect facility --> must be ignored
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 99
+source $srcdir/diag.sh exit
diff --git a/tests/testsuites/rs_optimizer_pri.conf b/tests/testsuites/rs_optimizer_pri.conf
new file mode 100644
index 00000000..9ff27dc8
--- /dev/null
+++ b/tests/testsuites/rs_optimizer_pri.conf
@@ -0,0 +1,8 @@
+$IncludeConfig diag-common.conf
+template(name="outfmt" type="string" string="%msg:F,58:2%\n")
+
+module(load="../plugins/imtcp/.libs/imtcp")
+input(type="imtcp" port="13514")
+
+if $syslogfacility-text == "local4" then
+ action(type="omfile" template="outfmt" file="rsyslog.out.log")