Commit 48d072c4 authored by Fabian Frederick's avatar Fabian Frederick Committed by Pablo Neira Ayuso

selftests: netfilter: add time counter check

Check packets are correctly placed in current year.
Also do a NULL check for another one.
Signed-off-by: default avatarFabian Frederick <fabf@skynet.be>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent d30a7d54
...@@ -23,6 +23,8 @@ ip -net "$ns0" addr add 127.0.0.1 dev lo ...@@ -23,6 +23,8 @@ ip -net "$ns0" addr add 127.0.0.1 dev lo
trap cleanup EXIT trap cleanup EXIT
currentyear=$(date +%G)
lastyear=$((currentyear-1))
ip netns exec "$ns0" nft -f /dev/stdin <<EOF ip netns exec "$ns0" nft -f /dev/stdin <<EOF
table inet filter { table inet filter {
counter iifcount {} counter iifcount {}
...@@ -33,6 +35,8 @@ table inet filter { ...@@ -33,6 +35,8 @@ table inet filter {
counter il4protocounter {} counter il4protocounter {}
counter imarkcounter {} counter imarkcounter {}
counter icpu0counter {} counter icpu0counter {}
counter ilastyearcounter {}
counter icurrentyearcounter {}
counter oifcount {} counter oifcount {}
counter oifnamecount {} counter oifnamecount {}
...@@ -55,6 +59,8 @@ table inet filter { ...@@ -55,6 +59,8 @@ table inet filter {
meta l4proto icmp counter name "il4protocounter" meta l4proto icmp counter name "il4protocounter"
meta mark 42 counter name "imarkcounter" meta mark 42 counter name "imarkcounter"
meta cpu 0 counter name "icpu0counter" meta cpu 0 counter name "icpu0counter"
meta time "$lastyear-01-01" - "$lastyear-12-31" counter name ilastyearcounter
meta time "$currentyear-01-01" - "$currentyear-12-31" counter name icurrentyearcounter
} }
chain output { chain output {
...@@ -100,8 +106,7 @@ check_lo_counters() ...@@ -100,8 +106,7 @@ check_lo_counters()
for counter in iifcount iifnamecount iifgroupcount iiftypecount infproto4count \ for counter in iifcount iifnamecount iifgroupcount iiftypecount infproto4count \
oifcount oifnamecount oifgroupcount oiftypecount onfproto4count \ oifcount oifnamecount oifgroupcount oiftypecount onfproto4count \
il4protocounter \ il4protocounter icurrentyearcounter ol4protocounter \
ol4protocounter \
; do ; do
check_one_counter "$counter" "$want" "$verbose" check_one_counter "$counter" "$want" "$verbose"
done done
...@@ -116,6 +121,7 @@ check_one_counter oskuidcounter "1" true ...@@ -116,6 +121,7 @@ check_one_counter oskuidcounter "1" true
check_one_counter oskgidcounter "1" true check_one_counter oskgidcounter "1" true
check_one_counter imarkcounter "1" true check_one_counter imarkcounter "1" true
check_one_counter omarkcounter "1" true check_one_counter omarkcounter "1" true
check_one_counter ilastyearcounter "0" true
if [ $ret -eq 0 ];then if [ $ret -eq 0 ];then
echo "OK: nftables meta iif/oif counters at expected values" echo "OK: nftables meta iif/oif counters at expected values"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment