network/iptables: reduce ping timeouts
PATCH 1/2 network/iptables: reduce ping timeouts
--- testcases/network/iptables/iptables_tests.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
testcases/network/iptables/iptables_tests.sh +6 -6
@@ -1,6 +1,6 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-or-later -# Copyright (c) 2018 Oracle and/or its affiliates. All Rights Reserved. +# Copyright (c) 2018-2019 Oracle and/or its affiliates. All Rights Reserved. # Copyright (c) International Business Machines Corp., 2001 # # Author: Jan 20 2004 Hubert Lin <[email protected]>
@@ -123,7 +123,7 @@ test2() fi tst_res TINFO "Pinging 127.0.0.1" - ping -c 2 127.0.0.1 > tst_iptables.out 2>&1 + ping -c 2 127.0.0.1 -W 1 -i 0 > tst_iptables.out 2>&1 if [ $? -ne 0 ]; then grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1 if [ $? -ne 0 ]; then
@@ -148,7 +148,7 @@ test2() return fi tst_res TINFO "Pinging 127.0.0.1 again" - ping -c 2 127.0.0.1 > tst_iptables.out 2>&1 + ping -c 2 127.0.0.1 -W 1 -i 0 > tst_iptables.out 2>&1 if [ $? -ne 0 ]; then tst_res TFAIL "iptables blocking loopback. This is expected" \ "behaviour on certain distributions where" \
@@ -174,7 +174,7 @@ test3() fi tst_res TINFO "Pinging 127.0.0.1" - ping -c 2 127.0.0.1 > tst_iptables.out 2>&1 + ping -c 2 127.0.0.1 -W 1 -i 0 > tst_iptables.out 2>&1 if [ $? -ne 0 ]; then grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1 if [ $? -ne 0 ]; then
@@ -198,7 +198,7 @@ test3() return fi tst_res TINFO "Pinging 127.0.0.1 again" - ping -c 2 127.0.0.1 > tst_iptables.out 2>&1 + ping -c 2 127.0.0.1 -W 1 -i 0 > tst_iptables.out 2>&1 if [ $? -ne 0 ]; then tst_res TFAIL "iptables blocking ping requests. This is" \ "expected behaviour on certain distributions" \
@@ -332,7 +332,7 @@ test6() fi tst_res TINFO "ping 127.0.0.1" - ping -c 10 127.0.0.1 > tst_iptables.out 2>&1 + ping -c 10 127.0.0.1 -W 1 -i 0 > tst_iptables.out 2>&1 if [ $? -eq 0 ]; then sleep 2 logcnt=$(dmesg | grep -c "$logprefix")
Signature · 1 line
2.20.1
PATCH 2/2 network/iptables: add new test for iptables-tranlsate and nft
* Reuse the test-cases from iptables_tests by moving them into iptables_lib.sh.
* create nft rules with iptables-translate.
---
runtest/net.tcp_cmds | 3 +-
testcases/network/iptables/Makefile | 23 +--
testcases/network/iptables/iptables01.sh | 18 ++
.../{iptables_tests.sh => iptables_lib.sh} | 163 +++++++++---------
testcases/network/iptables/nft01.sh | 18 ++
5 files changed, 119 insertions(+), 106 deletions(-)
create mode 100755 testcases/network/iptables/iptables01.sh
rename testcases/network/iptables/{iptables_tests.sh => iptables_lib.sh} (65%)
create mode 100755 testcases/network/iptables/nft01.shruntest/net.tcp_cmds +2 -1
@@ -17,7 +17,8 @@ rsh rsh01.sh sendfile sendfile01.sh tcpdump tcpdump01.sh telnet telnet01.sh -iptables iptables_tests.sh +iptables iptables01.sh +nft nft01.sh dhcpd dhcpd_tests.sh dnsmasq dnsmasq_tests.sh iproute ip_tests.sh
testcases/network/iptables/Makefile +3 -20
@@ -1,29 +1,12 @@ -# -# network/iptables testcases Makefile. -# -# Copyright (C) 2009, Cisco Systems Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2009, Cisco Systems Inc. # # Ngie Cooper, July 2009 -# top_srcdir ?= ../../.. include $(top_srcdir)/include/mk/env_pre.mk -INSTALL_TARGETS := iptables_tests.sh +INSTALL_TARGETS := *.sh include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/network/iptables/iptables01.sh new file +18 -0
@@ -0,0 +1,18 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2018-2019 Oracle and/or its affiliates. All Rights Reserved. + +TST_CNT=6 +TST_SETUP="init" +TST_TESTFUNC="test" +TST_CLEANUP="cleanup" +TST_NEEDS_TMPDIR=1 +TST_NEEDS_ROOT=1 +TST_NEEDS_CMDS="iptables grep ping telnet" +TST_NEEDS_DRIVERS="ip_tables" +use_iptables=1 + +. iptables_lib.sh +. tst_test.sh + +tst_run
testcases/network/iptables/iptables_lib.sh renamed from testcases/network/iptables/iptables_tests.sh +78 -85
331 lines not on this page · raw message
testcases/network/iptables/nft01.sh new file +18 -0
@@ -0,0 +1,18 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2019 Oracle and/or its affiliates. All Rights Reserved. + +TST_CNT=6 +TST_SETUP="init" +TST_TESTFUNC="test" +TST_CLEANUP="cleanup" +TST_NEEDS_TMPDIR=1 +TST_NEEDS_ROOT=1 +TST_NEEDS_CMDS="nft iptables-translate grep ping telnet" +TST_NEEDS_DRIVERS="nf_tables" +use_iptables=0 + +. iptables_lib.sh +. tst_test.sh + +tst_run
Signature · 1 line
2.20.1
PATCH 2/2 network/iptables: add new test for iptables-tranlsate and nft
Hi Alexey,
Quoted 6 lines
* Reuse the test-cases from
iptables_testsby moving them intoiptables_lib.sh.* create nft rules with iptables-translate.
Signed-off-by Alexey Kodanev <[email protected]>
Thanks for your patch.
Rewrite is ok, I'd just also drop dots from messages.
Also redirection to tst_iptables.out in cleanup() is pointless, maybe we could just change:
cleanup()
{
if lsmod | grep -q "ip_tables"; then
NFRUN -F -t filter > /dev/null 2>&1
NFRUN -F -t nat > /dev/null 2>&1
NFRUN -F -t mangle > /dev/null 2>&1
rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT \
iptable_mangle iptable_nat ip_conntrack \
iptable_filter ip_tables nf_nat_ipv4 nf_nat \
nf_log_ipv4 nf_log_common nf_reject_ipv4 \
nf_conntrack_ipv4 nf_defrag_ipv4 nf_conntrack \
> /dev/null 2>&1
fi
}For further work on iptables tests: I wonder if nc is more commonly installed in distros than telnet (if yes, I'd be for using it).
But for nft01.sh I got error:
nft01 1 TINFO: INIT: Flushing all rules.
nft01 1 TCONF: nft not applicable for test 1
nft01 2 TINFO: Use nft to DROP packets from particular IP
nft01 2 TINFO: Rule to block icmp from 127.0.0.1
nft01 2 TFAIL: nft command failed to append new rule.
Error: Could not process rule: No such file or directory
add rule ip filter INPUT ip protocol icmp ip saddr 127.0.0.1 counter drop ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nft01 3 TINFO: Use nft to REJECT ping request.
nft01 3 TINFO: Rule to reject ping request.
nft01 3 TFAIL: nft command failed to append new rule.
Error: Could not process rule: No such file or directory
add rule ip filter INPUT ip daddr 127.0.0.1 icmp type echo-request counter reject ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nft01 4 TINFO: Use nft to log packets to particular port.
nft01 4 TINFO: Rule to log tcp packets to particular port.
nft01 4 TFAIL: nft command failed to append new rule.
Error: Could not process rule: No such file or directory
add rule ip filter INPUT ip daddr 127.0.0.1 tcp dport 45886 counter log prefix "1128114107:" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nft01 5 TINFO: Use nft to log packets to multiple ports.
nft01 5 TINFO: Rule to log tcp packets to port 45801 - 45803.
nft01 5 TFAIL: nft command failed to append new rule.
Error: Could not process rule: No such file or directory
add rule ip filter INPUT ip daddr 127.0.0.1 tcp dport 45801-45803 counter log prefix "1128114107:" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nft01 6 TINFO: Use nft to log ping request with limited rate.
nft01 6 TINFO: Rule to log ping request.
nft01 6 TFAIL: nft command failed to append new rule.
Error: Could not process rule: No such file or directory
add rule ip filter INPUT ip daddr 127.0.0.1 icmp type echo-request limit rate 3/hour burst 5 packets counter log prefix "1128114107:" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Tested on openSUSE Tumbleweed (5.3.8-1-default, nftables v0.9.2 (Scram),
iptables v1.8.3 (legacy)) and Debian unstable (5.2.0-rc3+, nftables v0.9.0 (Fearless Fosdick), iptables v1.8.2 (nf_tables)). Am I missing something, have wrong version?
Kind regards,
Petr
PATCH 2/2 network/iptables: add new test for iptables-tranlsate and nft
Hi Petr,
Quoted 30 lines · Petr Vorel
Hi Alexey,
Quoted 6 lines
* Reuse the test-cases from
iptables_testsby moving them intoiptables_lib.sh.* create nft rules with iptables-translate.
Signed-off-by Alexey Kodanev <[email protected]>Thanks for your patch.
Rewrite is ok, I'd just also drop dots from messages.Also redirection to tst_iptables.out in
cleanup()is pointless, maybe we could just change:
cleanup(){ if lsmod | grep -q "ip_tables"; then NFRUN -F -t filter > /dev/null 2>&1 NFRUN -F -t nat > /dev/null 2>&1 NFRUN -F -t mangle > /dev/null 2>&1 rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT \ iptable_mangle iptable_nat ip_conntrack \ iptable_filter ip_tables nf_nat_ipv4 nf_nat \ nf_log_ipv4 nf_log_common nf_reject_ipv4 \ nf_conntrack_ipv4 nf_defrag_ipv4 nf_conntrack \ > /dev/null 2>&1 fi }
Quoted 3 lines
For further work on iptables tests: I wonder if nc is more commonly installed in distros than telnet (if yes, I'd be for using it).
Agree.
Quoted 10 lines
But for
nft01.shI got error:nft01 1 TINFO: INIT: Flushing all rules.
nft01 1 TCONF: nft not applicable for test 1
nft01 2 TINFO: Use nft to DROP packets from particular IP nft01 2 TINFO: Rule to block icmp from 127.0.0.1
nft01 2 TFAIL: nft command failed to append new rule.
Error: Could not process rule: No such file or directory
add rule ip filter INPUT ip protocol icmp ip saddr 127.0.0.1 counter drop ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It seems there is no ip filter table with INPUT chain? firewalld not installed?
Is it test running fine after these:
# nft add table ip filter
# nft add chain ip filter INPUT '{ type filter hook input priority 0; }'Quoted 31 lines
nft01 3 TINFO: Use nft to REJECT ping request.
nft01 3 TINFO: Rule to reject ping request.
nft01 3 TFAIL: nft command failed to append new rule.
Error: Could not process rule: No such file or directory
add rule ip filter INPUT ip daddr 127.0.0.1 icmp type echo-request counter reject ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nft01 4 TINFO: Use nft to log packets to particular port.
nft01 4 TINFO: Rule to log tcp packets to particular port.
nft01 4 TFAIL: nft command failed to append new rule.
Error: Could not process rule: No such file or directory
add rule ip filter INPUT ip daddr 127.0.0.1 tcp dport 45886 counter log prefix "1128114107:" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nft01 5 TINFO: Use nft to log packets to multiple ports.
nft01 5 TINFO: Rule to log tcp packets to port 45801 - 45803.
nft01 5 TFAIL: nft command failed to append new rule.
Error: Could not process rule: No such file or directory
add rule ip filter INPUT ip daddr 127.0.0.1 tcp dport 45801-45803 counter log prefix "1128114107:" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nft01 6 TINFO: Use nft to log ping request with limited rate.
nft01 6 TINFO: Rule to log ping request.
nft01 6 TFAIL: nft command failed to append new rule.
Error: Could not process rule: No such file or directory
add rule ip filter INPUT ip daddr 127.0.0.1 icmp type echo-request limit rate 3/hour burst 5 packets counter log prefix "1128114107:" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Tested on openSUSE Tumbleweed (5.3.8-1-default, nftables v0.9.2 (Scram),
iptables v1.8.3 (legacy)) and Debian unstable (5.2.0-rc3+, nftables v0.9.0 (Fearless Fosdick), iptables v1.8.2 (nf_tables)). Am I missing something, have wrong version?Kind regards,
Petr
PATCH 2/2 network/iptables: add new test for iptables-tranlsate and nft
Hi Alexey,
Quoted 11 lines
Quoted 9 lines
But for
nft01.shI got error:
nft01 1 TINFO: INIT: Flushing all rules.
nft01 1 TCONF: nft not applicable for test 1
nft01 2 TINFO: Use nft to DROP packets from particular IP nft01 2 TINFO: Rule to block icmp from 127.0.0.1
nft01 2 TFAIL: nft command failed to append new rule.
Error: Could not process rule: No such file or directory
add rule ip filter INPUT ip protocol icmp ip saddr 127.0.0.1 counter drop ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^It seems there is no ip filter table with INPUT chain? firewalld not installed?
No, firewalld it's installed on openSUSE (+ I'll test it for Debian, but I expect the same result).
Quoted 4 lines
Is it test running fine after these:
# nft add table ip filter # nft add chain ip filter INPUT '{ type filter hook input priority 0; }'
Kind regards,
Petr
PATCH 1/2 network/iptables: reduce ping timeouts
In reply to Alexey Kodanev