From 294f9ef5ee354ff902dfdc091a604f93083c248d Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 16 Aug 2018 18:14:36 +0200 Subject: ebtables: Fix entries count in chain listing The previous fix for reference counts in iptables-nft output wasn't complete: While iptables lists the number of references for each custom chain (i.e., the number of jumps to it), ebtables lists number of entries (i.e., the number of rules contained) for each chain. Both used the same value for it, although they are different metrics. Fix this by passing both numbers separately to the 'print_header' callback so that each tool may print the desired value. Fixes: a0698de9866d2 ("xtables: Do not count rules as chain references") Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- .../shell/testcases/ebtables/0001-ebtables-basic_0 | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'iptables/tests/shell/testcases/ebtables') diff --git a/iptables/tests/shell/testcases/ebtables/0001-ebtables-basic_0 b/iptables/tests/shell/testcases/ebtables/0001-ebtables-basic_0 index 05a2715f..b0db216a 100755 --- a/iptables/tests/shell/testcases/ebtables/0001-ebtables-basic_0 +++ b/iptables/tests/shell/testcases/ebtables/0001-ebtables-basic_0 @@ -28,6 +28,36 @@ case "$XT_MULTI" in exit 1 fi + $XT_MULTI ebtables -L FOO | grep -q 'entries: 0' + if [ $? -ne 0 ]; then + echo "Unexpected entries count in empty unreferenced chain" + $XT_MULTI ebtables -L + exit 1 + fi + + $XT_MULTI ebtables -A FORWARD -j FOO + $XT_MULTI ebtables -L FORWARD | grep -q 'entries: 1' + if [ $? -ne 0 ]; then + echo "Unexpected entries count in FORWARD chain" + $XT_MULTI ebtables -L + exit 1 + fi + + $XT_MULTI ebtables -L FOO | grep -q 'entries: 0' + if [ $? -ne 0 ]; then + echo "Unexpected entries count in empty referenced chain" + $XT_MULTI ebtables -L + exit 1 + fi + + $XT_MULTI ebtables -A FOO -j ACCEPT + $XT_MULTI ebtables -L FOO | grep -q 'entries: 1' + if [ $? -ne 0 ]; then + echo "Unexpected entries count in non-empty referenced chain" + $XT_MULTI ebtables -L + exit 1 + fi + $XT_MULTI ebtables -t filter -N BAR || exit 1 $XT_MULTI ebtables -t filter -N BAZ || exit 1 -- cgit v1.2.3