Add new testcase for testing 'iptables -o' Signed-off-by: Cui Bixuan <cuibix...@huawei.com> --- testcases/network/iptables/iptables_tests.sh | 47 +++++++++++++++++++++++++- 1 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/testcases/network/iptables/iptables_tests.sh b/testcases/network/iptables/iptables_tests.sh index 8a34712..14f2c95 100755 --- a/testcases/network/iptables/iptables_tests.sh +++ b/testcases/network/iptables/iptables_tests.sh @@ -22,7 +22,7 @@ # <hubertnospa...@symbio.com.tw> export TCID="iptables" -export TST_TOTAL=7 +export TST_TOTAL=8 . test.sh @@ -367,6 +367,50 @@ test07() tst_resm TPASS "iptables -c test succeed." } +test08() +{ + tst_resm TINFO "Use iptables to DROP packets from particular" \ + "network card" + tst_resm TINFO "Rule to block icmp from 127.0.0.1" + + iptables -A OUTPUT -o lo -p icmp -j DROP > tst_iptables.out 2>&1 + if [ $? -ne 0 ]; then + tst_resm TFAIL "iptables command failed to append new rule." + cat tst_iptables.out + return + fi + + tst_resm TINFO "Pinging 127.0.0.1" + ping 127.0.0.1 -c 2 > tst_iptables.out 2>&1 + if [ $? -ne 0 ]; then + tst_resm TINFO "Ping 127.0.0.1 not successful." + else + tst_resm TFAIL "iptables did not block icmp from 127.0.0.1" + cat tst_iptables.out + return + fi + + tst_resm TINFO "Deleting icmp DROP from lo rule." + iptables -D OUTPUT 1 > tst_iptables.out 2>&1 + if [ $? -ne 0 ]; then + tst_resm TBROK "iptables did not remove the rule." + cat tst_iptables.out + return + fi + + tst_resm TINFO "Pinging 127.0.0.1 again" + ping 127.0.0.1 -c 2 > tst_iptables.out 2>&1 + if [ $? -ne 0 ]; then + tst_resm TFAIL "iptables blocking loopback. This is expected" \ + "behaviour on certain distributions where" \ + "enabling firewall drops all packets by default." + cat tst_iptables.out + return + fi + + tst_resm TPASS "iptables can DROP packets from particular network card." +} + setup TST_CLEANUP=cleanup @@ -377,5 +421,6 @@ test04 test05 test06 test07 +test08 tst_exit -- 1.6.0.2 ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list