Blame SOURCES/0038-tests-shell-Test-for-fixed-extension-registration.patch

87db66
From f5185f4efad409fc7ec4ae05267b642ee4103a6c Mon Sep 17 00:00:00 2001
87db66
From: Phil Sutter <phil@nwl.cc>
87db66
Date: Fri, 4 Dec 2020 17:44:51 +0100
87db66
Subject: [PATCH] tests/shell: Test for fixed extension registration
87db66
87db66
Use strace to look at iptables-restore behaviour with typically
87db66
problematic input (conntrack revision 0 is no longer supported by
87db66
current kernels) to make sure the fix in commit a1eaaceb0460b
87db66
("libxtables: Simplify pending extension registration") is still
87db66
effective.
87db66
87db66
Signed-off-by: Phil Sutter <phil@nwl.cc>
87db66
(cherry picked from commit 93d0c97e8b6713f51ba679e01a1338d4f9076e7c)
87db66
Signed-off-by: Phil Sutter <psutter@redhat.com>
87db66
---
87db66
 .../0017-pointless-compat-checks_0            | 25 +++++++++++++++++++
87db66
 1 file changed, 25 insertions(+)
87db66
 create mode 100755 iptables/tests/shell/testcases/ipt-restore/0017-pointless-compat-checks_0
87db66
87db66
diff --git a/iptables/tests/shell/testcases/ipt-restore/0017-pointless-compat-checks_0 b/iptables/tests/shell/testcases/ipt-restore/0017-pointless-compat-checks_0
87db66
new file mode 100755
87db66
index 0000000000000..cf73de32df409
87db66
--- /dev/null
87db66
+++ b/iptables/tests/shell/testcases/ipt-restore/0017-pointless-compat-checks_0
87db66
@@ -0,0 +1,25 @@
87db66
+#!/bin/bash
87db66
+
87db66
+# A bug in extension registration would leave unsupported older extension
87db66
+# revisions in pending list and get compatibility checked again for each rule
87db66
+# using them. With SELinux enabled, the resulting socket() call per rule leads
87db66
+# to significant slowdown (~50% performance in worst cases).
87db66
+
87db66
+set -e
87db66
+
87db66
+strace --version >/dev/null || { echo "skip for missing strace"; exit 0; }
87db66
+
87db66
+RULESET="$(
87db66
+	echo "*filter"
87db66
+	for ((i = 0; i < 100; i++)); do
87db66
+		echo "-A FORWARD -m conntrack --ctstate NEW"
87db66
+	done
87db66
+	echo "COMMIT"
87db66
+)"
87db66
+
87db66
+cmd="$XT_MULTI iptables-restore"
87db66
+socketcount=$(strace -esocket $cmd <<< "$RULESET" 2>&1 | wc -l)
87db66
+
87db66
+# unpatched iptables-restore would open 111 sockets,
87db66
+# patched only 12 but keep a certain margin for future changes
87db66
+[[ $socketcount -lt 20 ]]
87db66
-- 
87db66
2.28.0
87db66