Skip to content

Commit

Permalink
mmanon: add support for ipv6
Browse files Browse the repository at this point in the history
see also rsyslog#1723
closes rsyslog#1614
  • Loading branch information
jgerhards committed Sep 2, 2017
1 parent 21d64f3 commit e290977
Show file tree
Hide file tree
Showing 10 changed files with 923 additions and 15 deletions.
508 changes: 493 additions & 15 deletions plugins/mmanon/mmanon.c

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ TESTS += \
mmanon_simple_12_ipv4.sh \
mmanon_simple_33_ipv4.sh \
mmanon_simple_8_ipv4.sh \
mmanon_random_128_ipv6.sh \
mmanon_zero_128_ipv6.sh \
mmanon_zero_96_ipv6.sh \
mmanon_random_cons_128_ipv6.sh \
mmanon_zero_50_ipv6.sh \
mmanon_recognize_ipv6.sh \
mmanon_zero_64_ipv6.sh \
mmanon_both_modes_compatible.sh \
empty-prop-comparison.sh \
rs_optimizer_pri.sh \
cee_simple.sh \
Expand Down Expand Up @@ -844,6 +852,14 @@ EXTRA_DIST= \
mmanon_simple_12_ipv4.sh \
mmanon_simple_33_ipv4.sh \
mmanon_simple_8_ipv4.sh \
mmanon_random_128_ipv6.sh \
mmanon_zero_128_ipv6.sh \
mmanon_zero_96_ipv6.sh \
mmanon_random_cons_128_ipv6.sh \
mmanon_zero_50_ipv6.sh \
mmanon_recognize_ipv6.sh \
mmanon_zero_64_ipv6.sh \
mmanon_both_modes_compatible.sh \
testsuites/rscript_ne_var.conf \
rscript_eq.sh \
testsuites/rscript_eq.conf \
Expand Down
35 changes: 35 additions & 0 deletions tests/mmanon_both_modes_compatible.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# add 2016-11-22 by Jan Gerhards, released under ASL 2.0
. $srcdir/diag.sh init
. $srcdir/diag.sh generate-conf
. $srcdir/diag.sh add-conf '
template(name="outfmt" type="string" string="%msg%\n")
module(load="../plugins/mmanon/.libs/mmanon")
module(load="../plugins/imtcp/.libs/imtcp")
input(type="imtcp" port="13514" ruleset="testing")
ruleset(name="testing") {
action(type="mmanon" ipv4.enable="on" ipv4.mode="zero" ipv4.bits="32" ipv6.bits="128" ipv6.anonmode="zero" ipv6.enable="on")
action(type="omfile" file="rsyslog.out.log" template="outfmt")
}'

. $srcdir/diag.sh startup
. $srcdir/diag.sh tcpflood -m1 -M "\"<129>Mar 10 01:00:00 172.20.245.8 tag: FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
<129>Mar 10 01:00:00 172.20.245.8 tag: 1.1.1.8 space 61:34:ad::7:F
<129>Mar 10 01:00:00 172.20.245.8 tag: 111.1.1.8
<129>Mar 10 01:00:00 172.20.245.8 tag: abf:3:002::500F:ce 1.1.1.9\""

. $srcdir/diag.sh shutdown-when-empty
. $srcdir/diag.sh wait-shutdown
echo ' 0:0:0:0:0:0:0:0
0.0.0.0 space 0:0:0:0:0:0:0:0
0.0.0.0
0:0:0:0:0:0:0:0 0.0.0.0' | cmp rsyslog.out.log
if [ ! $? -eq 0 ]; then
echo "invalid response generated, rsyslog.out.log is:"
cat rsyslog.out.log
. $srcdir/diag.sh error-exit 1
fi;

. $srcdir/diag.sh exit
64 changes: 64 additions & 0 deletions tests/mmanon_random_128_ipv6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash
# add 2016-11-22 by Jan Gerhards, released under ASL 2.0
. $srcdir/diag.sh init
. $srcdir/diag.sh generate-conf
. $srcdir/diag.sh add-conf '
template(name="outfmt" type="string" string="%msg%\n")
template(name="filename" type="string" string="rsyslog.out.%syslogtag%.log")
module(load="../plugins/mmanon/.libs/mmanon")
module(load="../plugins/imtcp/.libs/imtcp")
input(type="imtcp" port="13514" ruleset="testing")
ruleset(name="testing") {
action(type="mmanon" ipv6.anonmode="random" ipv6.bits="128" ipv6.enable="on")
action(type="omfile" dynafile="filename" template="outfmt")
}'

echo 'Since this test tests randomization, there is a theoretical possibility of it failing even if rsyslog works correctly. Therefore, if the test unexpectedly fails try restarting it.'
. $srcdir/diag.sh startup
. $srcdir/diag.sh tcpflood -m1 -M "\"<129>Mar 10 01:00:00 172.20.245.8 file1 33:45:DDD::4
<129>Mar 10 01:00:00 172.20.245.8 file2 ::
<129>Mar 10 01:00:00 172.20.245.8 file3 72:8374:adc7:47FF::43:0:1AFE
<129>Mar 10 01:00:00 172.20.245.8 file4 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
<129>Mar 10 01:00:00 172.20.245.8 file5 72:8374:adc7:47FF::43:0:1AFE\""

. $srcdir/diag.sh shutdown-when-empty
. $srcdir/diag.sh wait-shutdown
echo ' 33:45:DDD::4' | cmp rsyslog.out.file1.log >/dev/null
if [ $? -eq 0 ]; then
echo "invalidly equal ip-address generated, rsyslog.out.file1.log is:"
cat rsyslog.out.file1.log
. $srcdir/diag.sh error-exit 1
fi;

echo ' ::' | cmp rsyslog.out.file2.log >/dev/null
if [ $? -eq 0 ]; then
echo "invalidly equal ip-address generated, rsyslog.out.file2.log is:"
cat rsyslog.out.file2.log
. $srcdir/diag.sh error-exit 1
fi;

echo ' 72:8374:adc7:47FF::43:0:1AFE' | cmp rsyslog.out.file3.log >/dev/null
if [ $? -eq 0 ]; then
echo "invalidly equal ip-address generated, rsyslog.out.file3.log is:"
cat rsyslog.out.file3.log
. $srcdir/diag.sh error-exit 1
fi;

echo ' FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF' | cmp rsyslog.out.file4.log >/dev/null
if [ $? -eq 0 ]; then
echo "invalidly equal ip-address generated, rsyslog.out.file4.log is:"
cat rsyslog.out.file4.log
. $srcdir/diag.sh error-exit 1
fi;

cmp rsyslog.out.file3.log rsyslog.out.file5.log >/dev/null
if [ $? -eq 0 ]; then
echo "invalidly equal ip-addresses generated, rsyslog.out.file3.log and rsyslog.out.file5.log are:"
cat rsyslog.out.file3.log
cat rsyslog.out.file5.log
. $srcdir/diag.sh error-exit 1
fi;

. $srcdir/diag.sh exit
81 changes: 81 additions & 0 deletions tests/mmanon_random_cons_128_ipv6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
# add 2016-11-22 by Jan Gerhards, released under ASL 2.0
. $srcdir/diag.sh init
. $srcdir/diag.sh generate-conf
. $srcdir/diag.sh add-conf '
template(name="outfmt" type="string" string="%msg%\n")
template(name="filename" type="string" string="rsyslog.out.%syslogtag%.log")
module(load="../plugins/mmanon/.libs/mmanon")
module(load="../plugins/imtcp/.libs/imtcp")
input(type="imtcp" port="13514" ruleset="testing")
ruleset(name="testing") {
action(type="mmanon" ipv6.anonmode="random-consistent" ipv6.bits="128")
action(type="omfile" dynafile="filename" template="outfmt")
}'

echo 'Since this test tests randomization, there is a theoretical possibility of it failing even if rsyslog works correctly. Therefore, if the test unexpectedly fails try restarting it.'
. $srcdir/diag.sh startup
. $srcdir/diag.sh tcpflood -m1 -M "\"<129>Mar 10 01:00:00 172.20.245.8 file1 33:45:DDD::4
<129>Mar 10 01:00:00 172.20.245.8 file2 ::
<129>Mar 10 01:00:00 172.20.245.8 file6 ::
<129>Mar 10 01:00:00 172.20.245.8 file3 72:8374:adc7:47FF::43:0:1AFE
<129>Mar 10 01:00:00 172.20.245.8 file4 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
<129>Mar 10 01:00:00 172.20.245.8 file5 72:8374:adc7:47FF::43:0:1AFE\""

. $srcdir/diag.sh shutdown-when-empty
. $srcdir/diag.sh wait-shutdown
echo ' 33:45:DDD::4' | cmp rsyslog.out.file1.log >/dev/null
if [ $? -eq 0 ]; then
echo "invalidly equal ip-address generated, rsyslog.out.file1.log is:"
cat rsyslog.out.file1.log
. $srcdir/diag.sh error-exit 1
fi;

echo ' ::' | cmp rsyslog.out.file2.log >/dev/null
if [ $? -eq 0 ]; then
echo "invalidly equal ip-address generated, rsyslog.out.file2.log is:"
cat rsyslog.out.file2.log
. $srcdir/diag.sh error-exit 1
fi;

echo ' 72:8374:adc7:47FF::43:0:1AFE' | cmp rsyslog.out.file3.log >/dev/null
if [ $? -eq 0 ]; then
echo "invalidly equal ip-address generated, rsyslog.out.file3.log is:"
cat rsyslog.out.file3.log
. $srcdir/diag.sh error-exit 1
fi;

echo ' FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF' | cmp rsyslog.out.file4.log >/dev/null
if [ $? -eq 0 ]; then
echo "invalidly equal ip-address generated, rsyslog.out.file4.log is:"
cat rsyslog.out.file4.log
. $srcdir/diag.sh error-exit 1
fi;

cmp rsyslog.out.file3.log rsyslog.out.file5.log >/dev/null
if [ ! $? -eq 0 ]; then
echo "invalidly unequal ip-addresses generated, rsyslog.out.file1.log and rsyslog.out.file6.log are:"
cat rsyslog.out.file1.log
cat rsyslog.out.file6.log
. $srcdir/diag.sh error-exit 1
fi;

cmp rsyslog.out.file2.log rsyslog.out.file6.log >/dev/null
if [ ! $? -eq 0 ]; then
echo "invalidly unequal ip-addresses generated, rsyslog.out.file1.log and rsyslog.out.file6.log are:"
cat rsyslog.out.file1.log
cat rsyslog.out.file6.log
. $srcdir/diag.sh error-exit 1
fi;

cmp rsyslog.out.file4.log rsyslog.out.file5.log >/dev/null
if [ $? -eq 0 ]; then
echo "invalidly equal ip-addresses generated, rsyslog.out.file4.log and rsyslog.out.file5.log are:"
cat rsyslog.out.file4.log
cat rsyslog.out.file5.log
. $srcdir/diag.sh error-exit 1
fi;

. $srcdir/diag.sh exit
59 changes: 59 additions & 0 deletions tests/mmanon_recognize_ipv6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash
# add 2016-11-22 by Jan Gerhards, released under ASL 2.0
. $srcdir/diag.sh init
. $srcdir/diag.sh generate-conf
. $srcdir/diag.sh add-conf '
template(name="outfmt" type="string" string="%msg%\n")
module(load="../plugins/mmanon/.libs/mmanon")
module(load="../plugins/imtcp/.libs/imtcp")
input(type="imtcp" port="13514" ruleset="testing")
ruleset(name="testing") {
action(type="mmanon" ipv4.enable="off" ipv6.enable="on" ipv6.bits="128" ipv6.anonmode="zero")
action(type="omfile" file="rsyslog.out.log" template="outfmt")
}'

. $srcdir/diag.sh startup
. $srcdir/diag.sh tcpflood -m1 -M "\"<129>Mar 10 01:00:00 172.20.245.8 tag: asdfghjk
<129>Mar 10 01:00:00 172.20.245.8 tag: FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
<129>Mar 10 01:00:00 172.20.245.8 tag: 61:34:ad::7:F aa:ff43::756:99:0
<129>Mar 10 01:00:00 172.20.245.8 tag: ::
<129>Mar 10 01:00:00 172.20.245.8 tag: 0::
<129>Mar 10 01:00:00 172.20.245.8 tag: 13:abd:45:
<129>Mar 10 01:00:00 172.20.245.8 tag: 13:abd:45::. test
<129>Mar 10 01:00:00 172.20.245.8 tag: 13:abd:45::* test
<129>Mar 10 01:00:00 172.20.245.8 tag: *13:abd:45::* test
<129>Mar 10 01:00:00 172.20.245.8 tag: 13:abd:45:* test
<129>Mar 10 01:00:00 172.20.245.8 tag: ewirnwemaa:ff43::756:99:0
<129>Mar 10 01:00:00 172.20.245.8 tag: a::, cc:: LLL
<129>Mar 10 01:00:00 172.20.245.8 tag: 12:12345::a
<129>Mar 10 01:00:00 172.20.245.8 tag: textnoblank72:8374:adc7:47FF::43:0:1AFE
<129>Mar 10 01:00:00 172.20.245.8 tag: 72:8374:adc7:47FF::43:0:1AFEstillnoblank
<129>Mar 10 01:00:00 172.20.245.8 tag: textnoblank72:8374:adc7:47FF::43:0:1AFEstillnoblank\""

. $srcdir/diag.sh shutdown-when-empty
. $srcdir/diag.sh wait-shutdown
echo ' asdfghjk
0:0:0:0:0:0:0:0
0:0:0:0:0:0:0:0 0:0:0:0:0:0:0:0
0:0:0:0:0:0:0:0
0:0:0:0:0:0:0:0
13:abd:45:
0:0:0:0:0:0:0:0. test
0:0:0:0:0:0:0:0* test
*0:0:0:0:0:0:0:0* test
13:abd:45:* test
ewirnwem0:0:0:0:0:0:0:0
0:0:0:0:0:0:0:0, 0:0:0:0:0:0:0:0 LLL
12:10:0:0:0:0:0:0:0
textnoblank0:0:0:0:0:0:0:0
0:0:0:0:0:0:0:0stillnoblank
textnoblank0:0:0:0:0:0:0:0stillnoblank' | cmp rsyslog.out.log
if [ ! $? -eq 0 ]; then
echo "invalid response generated, rsyslog.out.log is:"
cat rsyslog.out.log
. $srcdir/diag.sh error-exit 1
fi;

. $srcdir/diag.sh exit
50 changes: 50 additions & 0 deletions tests/mmanon_zero_128_ipv6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
# add 2016-11-22 by Jan Gerhards, released under ASL 2.0
. $srcdir/diag.sh init
. $srcdir/diag.sh generate-conf
. $srcdir/diag.sh add-conf '
template(name="outfmt" type="string" string="%msg%\n")
module(load="../plugins/mmanon/.libs/mmanon")
module(load="../plugins/imtcp/.libs/imtcp")
input(type="imtcp" port="13514" ruleset="testing")
ruleset(name="testing") {
action(type="mmanon" ipv6.bits="129" ipv6.anonmode="zero")
action(type="omfile" file="./rsyslog.out.log" template="outfmt")
}
action(type="omfile" file="rsyslog2.out.log")'

. $srcdir/diag.sh startup
. $srcdir/diag.sh tcpflood -m1 -M "\"<129>Mar 10 01:00:00 172.20.245.8 tag: asdfghjk
<129>Mar 10 01:00:00 172.20.245.8 tag: FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
<129>Mar 10 01:00:00 172.20.245.8 tag: 61:34:ad::7:F aa:ff43::756:99:0
<129>Mar 10 01:00:00 172.20.245.8 tag: ::
<129>Mar 10 01:00:00 172.20.245.8 tag: 0::
<129>Mar 10 01:00:00 172.20.245.8 tag: 13:abd:45:
<129>Mar 10 01:00:00 172.20.245.8 tag: textnoblank72:8374:adc7:47FF::43:0:1AFEstillnoblank\""

. $srcdir/diag.sh shutdown-when-empty
. $srcdir/diag.sh wait-shutdown
echo ' asdfghjk
0:0:0:0:0:0:0:0
0:0:0:0:0:0:0:0 0:0:0:0:0:0:0:0
0:0:0:0:0:0:0:0
0:0:0:0:0:0:0:0
13:abd:45:
textnoblank0:0:0:0:0:0:0:0stillnoblank' | cmp rsyslog.out.log
if [ ! $? -eq 0 ]; then
echo "invalid response generated, rsyslog.out.log is:"
cat rsyslog.out.log
. $srcdir/diag.sh error-exit 1
fi;


grep 'invalid number of ipv6.bits (129), corrected to 128' rsyslog2.out.log > /dev/null
if [ $? -ne 0 ]; then
echo "invalid correction of bits parameter generated, rsyslog2.out.log is:"
cat rsyslog2.out.log
. $srcdir/diag.sh error-exit 1
fi;

. $srcdir/diag.sh exit
42 changes: 42 additions & 0 deletions tests/mmanon_zero_50_ipv6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# add 2016-11-22 by Jan Gerhards, released under ASL 2.0
. $srcdir/diag.sh init
. $srcdir/diag.sh generate-conf
. $srcdir/diag.sh add-conf '
template(name="outfmt" type="string" string="%msg%\n")
module(load="../plugins/mmanon/.libs/mmanon")
module(load="../plugins/imtcp/.libs/imtcp")
input(type="imtcp" port="13514" ruleset="testing")
ruleset(name="testing") {
action(type="mmanon" ipv6.bits="50" ipv6.anonmode="zero")
action(type="omfile" file="./rsyslog.out.log" template="outfmt")
}
action(type="omfile" file="rsyslog2.out.log")'

. $srcdir/diag.sh startup
. $srcdir/diag.sh tcpflood -m1 -M "\"<129>Mar 10 01:00:00 172.20.245.8 tag: asdfghjk
<129>Mar 10 01:00:00 172.20.245.8 tag: FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
<129>Mar 10 01:00:00 172.20.245.8 tag: 61:34:ad::7:F aa:ff43::756:99:0
<129>Mar 10 01:00:00 172.20.245.8 tag: ::
<129>Mar 10 01:00:00 172.20.245.8 tag: 0::
<129>Mar 10 01:00:00 172.20.245.8 tag: 13:abd:45:
<129>Mar 10 01:00:00 172.20.245.8 tag: textnoblank72:8374:adc7:47FF::43:0:1AFEstillnoblank\""

. $srcdir/diag.sh shutdown-when-empty
. $srcdir/diag.sh wait-shutdown
echo ' asdfghjk
ffff:ffff:ffff:ffff:fffc:0:0:0
61:34:ad:0:0:0:0:0 aa:ff43:0:0:0:0:0:0
0:0:0:0:0:0:0:0
0:0:0:0:0:0:0:0
13:abd:45:
textnoblank72:8374:adc7:47ff:0:0:0:0stillnoblank' | cmp rsyslog.out.log
if [ ! $? -eq 0 ]; then
echo "invalid response generated, rsyslog.out.log is:"
cat rsyslog.out.log
. $srcdir/diag.sh error-exit 1
fi;

. $srcdir/diag.sh exit
Loading

0 comments on commit e290977

Please sign in to comment.