Skip to contentSkip to conversation

selftests: netfilter: add nfqueue test case

PATCH Superseded Florian Westphal 1 participant 1 message Jun 26, 2019

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 selftests: netfilter: add nfqueue test case

Add a test case to check nf queue infrastructure. Could be extended in the future to also cover serialization of conntrack, uid and secctx attributes in nfqueue.

For now, this checks that 'queue bypass' works, that a queue rule with no bypass option blocks traffic and that userspace receives the expected number of packets.
For this we add two queues and hook all of prerouting/input/forward/output/postrouting.

Packets get queued twice with a dummy base chain in between:
This passes with current nf tree, but reverting
commit 946c0d8e6ed4 ("netfilter: nf_queue: fix reinject verdict handling") makes this trip (it processes 30 instead of expected 20 packets).

---
 tools/testing/selftests/netfilter/.gitignore  |   1 +
 tools/testing/selftests/netfilter/Makefile    |   5 +-
 tools/testing/selftests/netfilter/nf-queue.c  | 281 ++++++++++++++++++
 .../testing/selftests/netfilter/nft_queue.sh  | 274 +++++++++++++++++
 4 files changed, 560 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/netfilter/.gitignore
 create mode 100644 tools/testing/selftests/netfilter/nf-queue.c
 create mode 100755 tools/testing/selftests/netfilter/nft_queue.sh
tools/testing/selftests/netfilter/.gitignore new file +1 -0
new file mode 100644
index 000000000000..03c4a7b5d153
@@ -0,0 +1 @@
+nf-queue
tools/testing/selftests/netfilter/Makefile +4 -1
index 4144984ebee5..0f6f6530030d 100644
@@ -2,6 +2,9 @@
 # Makefile for netfilter selftests
 
 TEST_PROGS := nft_trans_stress.sh nft_nat.sh bridge_brouter.sh \
-	conntrack_icmp_related.sh nft_flowtable.sh
+	conntrack_icmp_related.sh nft_flowtable.sh nft_queue.sh
+
+LDLIBS = -lmnl
+TEST_GEN_FILES =  nf-queue
 
 include ../lib.mk
tools/testing/selftests/netfilter/nf-queue.c new file +281 -0

281 lines not on this page · raw message

tools/testing/selftests/netfilter/nft_queue.sh new file +274 -0

274 lines not on this page · raw message

Signature · 1 line
2.21.0