Commit d3b2dc94 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf

Pablo Neira Ayuso says:

====================
Netfilter fixes for net

The following patchset contains Netfilter selftests fixes from
Fabian Frederick:

1) Extend selftest nft_meta.sh to check for meta cpu.

2) Fix selftest nft_meta.sh error reporting.

3) Fix shellcheck warnings in selftest nft_meta.sh.

4) Extend selftest nft_meta.sh to check for meta time.
====================
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 37198e93 48d072c4
...@@ -7,8 +7,7 @@ ksft_skip=4 ...@@ -7,8 +7,7 @@ ksft_skip=4
sfx=$(mktemp -u "XXXXXXXX") sfx=$(mktemp -u "XXXXXXXX")
ns0="ns0-$sfx" ns0="ns0-$sfx"
nft --version > /dev/null 2>&1 if ! nft --version > /dev/null 2>&1; then
if [ $? -ne 0 ];then
echo "SKIP: Could not run test without nft tool" echo "SKIP: Could not run test without nft tool"
exit $ksft_skip exit $ksft_skip
fi fi
...@@ -24,6 +23,8 @@ ip -net "$ns0" addr add 127.0.0.1 dev lo ...@@ -24,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 +34,9 @@ table inet filter { ...@@ -33,6 +34,9 @@ table inet filter {
counter infproto4count {} counter infproto4count {}
counter il4protocounter {} counter il4protocounter {}
counter imarkcounter {} counter imarkcounter {}
counter icpu0counter {}
counter ilastyearcounter {}
counter icurrentyearcounter {}
counter oifcount {} counter oifcount {}
counter oifnamecount {} counter oifnamecount {}
...@@ -54,6 +58,9 @@ table inet filter { ...@@ -54,6 +58,9 @@ table inet filter {
meta nfproto ipv4 counter name "infproto4count" meta nfproto ipv4 counter name "infproto4count"
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 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 {
...@@ -84,11 +91,10 @@ check_one_counter() ...@@ -84,11 +91,10 @@ check_one_counter()
local want="packets $2" local want="packets $2"
local verbose="$3" local verbose="$3"
cnt=$(ip netns exec "$ns0" nft list counter inet filter $cname | grep -q "$want") if ! ip netns exec "$ns0" nft list counter inet filter $cname | grep -q "$want"; then
if [ $? -ne 0 ];then
echo "FAIL: $cname, want \"$want\", got" echo "FAIL: $cname, want \"$want\", got"
ret=1 ret=1
ip netns exec "$ns0" nft list counter inet filter $counter ip netns exec "$ns0" nft list counter inet filter $cname
fi fi
} }
...@@ -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,9 +121,22 @@ check_one_counter oskuidcounter "1" true ...@@ -116,9 +121,22 @@ 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"
else
exit $ret
fi
#First CPU execution and counter
taskset -p 01 $$ > /dev/null
ip netns exec "$ns0" nft reset counters > /dev/null
ip netns exec "$ns0" ping -q -c 1 127.0.0.1 > /dev/null
check_one_counter icpu0counter "2" true
if [ $ret -eq 0 ];then
echo "OK: nftables meta cpu counter at expected values"
fi fi
exit $ret exit $ret
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