Hi,
I have one concern about this part,
diff --git a/testcases/network/iptables/iptables_tests.sh
b/testcases/network/iptables/iptables_tests.sh
--- a/testcases/network/iptables/iptables_tests.sh
+++ b/testcases/network/iptables/iptables_tests.sh
@@ -61,7 +61,7 @@
# Initialize cleanup function.
trap "cleanup" 0
- which tst_resm &>$LTPTMP/tst_iptables.out || RC=$?
+ which tst_resm > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_brkm TBROK \
"Test INIT: USCTEST commands not found, set PATH
correctly."
@@ -69,17 +69,17 @@
fi
tst_resm TINFO "INIT: Inititalizing tests."
- which iptables &> $LTPTMP/tst_iptables.out || RC=$?
+ which iptables > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
"Test INIT: iptables command does not exist. Reason:"
return $RC
fi
- modprobe ip_tables &>$LTPTMP/tst_iptables.out || RC=$?
+ modprobe ip_tables > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
RC=0
- iptables -L &>$LTPTMP/tst_iptables.out || RC=$?
+ iptables -L > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
"Test INIT: no iptables support in kenrel.
Reason:"
@@ -88,9 +88,9 @@
fi
tst_resm TINFO "INIT: Flushing all rules."
- iptables -F -t filter &>$LTPTMP/tst_iptables.out || RC=$?
- iptables -F -t nat &>$LTPTMP/tst_iptables.out || RC=$?
- iptables -F -t mangle &>$LTPTMP/tst_iptables.out || RC=$?
+ iptables -F -t filter > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
+ iptables -F -t nat > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
+ iptables -F -t mangle > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
return $RC
}
@@ -107,12 +107,12 @@
TST_COUNT=0
RC=0
- lsmod | grep "ip_tables" &>$LTPTMP/tst_iptables.out || RC=0
+ lsmod | grep "ip_tables" > $LTPTMP/tst_iptables.out 2>&1 || RC=0
if [ $RC -eq 0 ]; then
- iptables -F -t filter &>$LTPTMP/tst_iptables.out
- iptables -F -t nat &>$LTPTMP/tst_iptables.out
- iptables -F -t mangle &>$LTPTMP/tst_iptables.out
- rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT
iptable_mangle iptable_nat ip_conntrack
iptable_filter ip_tables &>$LTPTMP/tst_iptables.out
+ iptables -F -t filter > $LTPTMP/tst_iptables.out 2>&1
+ iptables -F -t nat > $LTPTMP/tst_iptables.out 2>&1
+ iptables -F -t mangle > $LTPTMP/tst_iptables.out 2>&1
+ rmmod -v ipt_limit ipt_multiport ipt_LOG ipt_REJECT
iptable_mangle iptable_nat ip_conntrack
iptable_filter ip_tables > $LTPTMP/tst_iptables.out 2>&1
fi
rm -fr $LTPTMP/tst_iptables.*
return $RC
@@ -134,12 +134,12 @@
TCID=iptables01 # Name of the test case.
TST_COUNT=1 # Test number.
- local chaincnt=0 # chain counter
+ chaincnt=0 # chain counter
- local cmd="iptables -L -t filter"
+ cmd="iptables -L -t filter"
tst_resm TINFO \
"$TCID: $cmd will list all rules in table filter."
- $cmd &>$LTPTMP/tst_iptables.out || RC=$?
+ $cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: $cmd failed to list rules. Reason:"
@@ -155,10 +155,10 @@
fi
fi
- local cmd="iptables -L -t nat"
+ cmd="iptables -L -t nat"
tst_resm TINFO \
"$TCID: $cmd will list all rules in table nat."
- $cmd &>$LTPTMP/tst_iptables.out || RC=$?
+ $cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: $cmd failed to list rules. Reason:"
@@ -174,10 +174,10 @@
fi
fi
- local cmd="iptables -L -t mangle"
+ cmd="iptables -L -t mangle"
tst_resm TINFO \
"$TCID: $cmd will list all rules in table mangle."
- $cmd &>$LTPTMP/tst_iptables.out || RC=$?
+ $cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: $cmd failed to list rules. Reason:"
@@ -219,7 +219,7 @@
tst_resm TINFO "$TCID: Rule to block icmp from 127.0.0.1"
iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP \
- &>$LTPTMP/tst_iptables.out || RC=$?
+ > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
"$TCID: iptables command failed to append new rule.
Reason:"
@@ -227,11 +227,11 @@
fi
tst_resm TINFO "$TCID: Pinging 127.0.0.1"
- ping -c 2 127.0.0.1 &>$LTPTMP/tst_iptables.out || RC=$?
+ ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
RC=0
grep "100% packet loss" $LTPTMP/tst_iptables.out \
- &>$LTPTMP/tst_iptables.err || RC=$?
+ > $LTPTMP/tst_iptables.err 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: iptables did not block packets from
loopback"
@@ -246,14 +246,14 @@
fi
tst_resm TINFO "$TCID: Deleting icmp DROP from 127.0.0.1 rule."
- iptables -D INPUT 1 &>$LTPTMP/tst_iptables.out || RC=$?
+ iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: iptables did not remove the rule. Reason:"
return $RC
fi
tst_resm TINFO "$TCID: Pinging 127.0.0.1 again"
- ping -c 2 127.0.0.1 &>$LTPTMP/tst_iptables.out || RC=$?
+ ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: iptables blocking loopback. Reason:"
@@ -288,7 +288,7 @@
tst_resm TINFO "$TCID: Rule to reject ping request."
iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -j
REJECT \
- &>$LTPTMP/tst_iptables.out || RC=$?
+ > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
"$TCID: iptables command failed to append new rule.
Reason:"
@@ -296,11 +296,11 @@
fi
tst_resm TINFO "$TCID: Pinging 127.0.0.1"
- ping -c 2 127.0.0.1 &>$LTPTMP/tst_iptables.out || RC=$?
+ ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
RC=0
grep "100% packet loss" $LTPTMP/tst_iptables.out \
- &>$LTPTMP/tst_iptables.err || RC=$?
+ > $LTPTMP/tst_iptables.err 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: iptables did not block ping request."
@@ -315,14 +315,14 @@
fi
tst_resm TINFO "$TCID: Deleting icmp request REJECT rule."
- iptables -D INPUT 1 &>$LTPTMP/tst_iptables.out || RC=$?
+ iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: iptables did not remove the rule. Reason:"
return $RC
fi
tst_resm TINFO "$TCID: Pinging 127.0.0.1 again"
- ping -c 2 127.0.0.1 &>$LTPTMP/tst_iptables.out || RC=$?
+ ping -c 2 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: iptables blocking ping requests. Reason:"
@@ -351,15 +351,15 @@
RC=0 # Return value from commands.
TCID=iptables04 # Name of the test case.
TST_COUNT=4 # Test number.
- local dport=45886 # destination port
- local logprefix="$TCID-$(date +%m%d%H%M%S):" # log-prefix used by
iptables
+ dport=45886 # destination port
+ logprefix="$TCID-$(date +%m%d%H%M%S):" # log-prefix used by iptables
tst_resm TINFO \
"$TCID: Use iptables to log packets to particular port."
tst_resm TINFO "$TCID: Rule to log tcp packets to particular port."
iptables -A INPUT -p tcp -d 127.0.0.1 --dport $dport -j LOG
--log-prefix "$logprefix" \
- &>$LTPTMP/tst_iptables.out || RC=$?
+ > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
"$TCID: iptables command failed to append new rule.
Reason:"
@@ -367,12 +367,12 @@
fi
tst_resm TINFO "$TCID: telnet 127.0.0.1 $dport"
- telnet 127.0.0.1 $dport &>$LTPTMP/tst_iptables.out || RC=$?
+ telnet 127.0.0.1 $dport > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
RC=0
sleep 2
dmesg | grep "$logprefix" \
- &>$LTPTMP/tst_iptables.err || RC=$?
+ > $LTPTMP/tst_iptables.err 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: iptables did not log packets to port
$dport"
@@ -387,7 +387,7 @@
fi
tst_resm TINFO "$TCID: Deleting the rule to log."
- iptables -D INPUT 1 &>$LTPTMP/tst_iptables.out || RC=$?
+ iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: iptables did not remove the rule. Reason:"
@@ -417,14 +417,14 @@
RC=0 # Return value from commands.
TCID=iptables05 # Name of the test case.
TST_COUNT=5 # Test number.
- local dport=0 # destination port
- local logprefix="$TCID-$(date +%m%d%H%M%S):" # log-prefix used by
iptables
+ dport=0 # destination port
+ logprefix="$TCID-$(date +%m%d%H%M%S):" # log-prefix used by iptables
tst_resm TINFO \
"$TCID: Use iptables to log packets to multiple ports."
tst_resm TINFO "$TCID: Rule to log tcp packets to port 45801 - 45803."
iptables -A INPUT -p tcp -d 127.0.0.1 --dport 45801:45803 -j LOG
--log-prefix "$logprefix" \
- &>$LTPTMP/tst_iptables.out || RC=$?
+ > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
"$TCID: iptables command failed to append new rule.
Reason:"
@@ -433,7 +433,7 @@
tst_resm TINFO "$TCID: Rule to log tcp packets to port 45804 - 45806."
iptables -A INPUT -p tcp -d 127.0.0.1 -m multiport --dports
45804,45806,45805 -j LOG
--log-prefix "$logprefix" \
- &>$LTPTMP/tst_iptables.out || RC=$?
+ > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
"$TCID: iptables command failed to append new rule.
Reason:"
@@ -442,12 +442,12 @@
for dport in 45801 45802 45803 45804 45805 45806; do
tst_resm TINFO "$TCID: telnet 127.0.0.1 $dport"
- telnet 127.0.0.1 $dport &>$LTPTMP/tst_iptables.out || RC=$?
+ telnet 127.0.0.1 $dport > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
RC=0
sleep 2
dmesg | grep "$logprefix" | grep "=$dport " \
- &>$LTPTMP/tst_iptables.err || RC=$?
+ > $LTPTMP/tst_iptables.err 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: iptables did not log packets to
port $dport"
@@ -463,7 +463,7 @@
done
tst_resm TINFO "$TCID: Flushing all rules."
- iptables -F &>$LTPTMP/tst_iptables.out || RC=$?
+ iptables -F > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: iptables did not flush all rules. Reason:"
@@ -492,15 +492,15 @@
RC=0 # Return value from commands.
TCID=iptables06 # Name of the test case.
TST_COUNT=6 # Test number.
- local logcnt=0 # log counter
- local logprefix="$TCID-$(date +%m%d%H%M%S):" # log-prefix used by
iptables
+ logcnt=0 # log counter
+ logprefix="$TCID-$(date +%m%d%H%M%S):" # log-prefix used by iptables
tst_resm TINFO \
"$TCID: Use iptables to log ping request with limited rate."
tst_resm TINFO "$TCID: Rule to log ping request."
iptables -A INPUT -p icmp --icmp-type echo-request -d 127.0.0.1 -m
limit -j LOG --log-prefix
"$logprefix" \
- &>$LTPTMP/tst_iptables.out || RC=$?
+ > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_brk TBROK $LTPTMP/tst_iptables.out NULL \
"$TCID: iptables command failed to append new rule.
Reason:"
@@ -508,7 +508,7 @@
fi
tst_resm TINFO "$TCID: ping 127.0.0.1"
- ping -c 10 127.0.0.1 &>$LTPTMP/tst_iptables.out || RC=$?
+ ping -c 10 127.0.0.1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -eq 0 ]; then
RC=0
sleep 2
@@ -527,7 +527,7 @@
fi
tst_resm TINFO "$TCID: Deleting the rule to log."
- iptables -D INPUT 1 &>$LTPTMP/tst_iptables.out || RC=$?
+ iptables -D INPUT 1 > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
if [ $RC -ne 0 ]; then
tst_res TFAIL $LTPTMP/tst_iptables.out \
"$TCID: iptables did not remove the rule. Reason:"
As all "local" keywords has been removed, is it possible that those variable
have been reused
unexpectedly later? Otherwise, all those patches look good, and seems not break
any existing
functionality.
Cai Qian
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list