[libvirt] [PATCH v2] [TCK] nwfilter: probe for inverted ctdir
Stefan Berger
stefanb at linux.vnet.ibm.com
Thu May 16 16:02:17 UTC 2013
Linux netfilter at some point inverted the meaning of the '--ctdir reply'
and newer netfilter implementations now expect '--ctdir original'
instead and vice-versa.
We probe for this netfilter change via an IMCP message over loopback and 3
filtering rules applied to INPUT. If the sent byte arrives, the newer
netfilter implementation has been detected and we convert the strings
in the iptables output to now match that inversion implemented by libvirt.
The downside of this is that probing of libvirt and this test tool are
independent and this test tool will only work correctly for all cases
if used with libvirt probing for 'ctdir inversion' as well.
Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
---
scripts/nwfilter/nwfilter2vmtest.sh | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
Index: libvirt-tck/scripts/nwfilter/nwfilter2vmtest.sh
===================================================================
--- libvirt-tck.orig/scripts/nwfilter/nwfilter2vmtest.sh
+++ libvirt-tck/scripts/nwfilter/nwfilter2vmtest.sh
@@ -28,6 +28,10 @@ FLAG_LIBVIRT_TEST="$((1<<3))"
FLAG_TAP_TEST="$((1<<4))"
FLAG_FORCE_CLEAN="$((1<<5))"
+# --ctdir original vs. --ctdir reply's meaning was inverted in
+# netfilter at some point. We probe for it.
+IPTABLES_CTRDIR_CORRECTED=0
+
failctr=0
passctr=0
attachfailctr=0
@@ -100,6 +104,15 @@ mktmpdir() {
return 0
}
+probeIptablesCtdir() {
+ # below gawk works for "2\.6\.39.*"; any non-digit immediately
+ # after '39' will be ignored
+ rev=$(uname -r | gawk -F. '{print $1 * 1000000 + $2 * 1000 + $3 }')
+ # 2.6.39 had the correction
+ if [ $rev -ge 2006039 ]; then
+ IPTABLES_CTDIR_CORRECTED=1
+ fi
+}
checkExpectedOutput() {
xmlfile="$1"
@@ -160,6 +173,14 @@ checkExpectedOutput() {
break
fi
+ if [ $IPTABLES_CTDIR_CORRECTED -ne 0 ]; then
+ #change --ctdir ORIGINAL to --ctdir REPLY
+ #and --ctdir REPLY to --ctdir ORIGINAL
+ sed -i "s/ctdir[ ]*ORIGINAL/ctdir _REPLY/" ${tmpfile}
+ sed -i "s/ctdir[ ]*REPLY/ctdir ORIGINAL/" ${tmpfile}
+ sed -i "s/ctdir _REPLY/ctdir REPLY/" ${tmpfile}
+ fi
+
diff -w ${tmpfile} ${tmpfile2} >/dev/null
if [ $? -ne 0 ]; then
@@ -551,6 +572,8 @@ main() {
echo "This script will only run on Linux."
fi
exit 1;
+ else
+ probeIptablesCtdir
fi
if [ $(($flags & $FLAG_TAP_TEST)) -ne 0 ]; then
More information about the libvir-list
mailing list