New example program nfq6
v2 cover New example program nfq6
Hi Pablo,
I've been using nfq6 as a patch testbed for some time.
Now that nfq6 has matured to only use functions from the code base, I offer it as a second example for libnetfilter_queue.
I did fix some errors from checkpatch.
I myself disagree with those that remain.
If you think some of them warrant fixing, I'll do it of course.
Cheers ... Duncan.
Duncan Roe (1):
examples: add an example which uses more functions
.gitignore | 1 + examples/Makefile.am | 6 +- examples/nfq6.c | 692 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 698 insertions(+), 1 deletion(-) create mode 100644 examples/nfq6.c
Signature · 1 line
2.35.8
PATCH v2 1/1 examples: add an example which uses more functions
Add nfq6 which started out as a copy of nf-queue and can still print packet frameworks (that is test 16).
Usage: nfq6 [-a <alt q #>] [-t <test #>],... queue_number
nfq6 -h
-a <n>: Alternate queue for test 4
-h: give this Help and exit
-t <n>: do Test <n>. Tests are:
0: If packet mark is zero, set it to 0xbeef and give verdict NF_REPEAT 1: If packet mark is not 0xfaceb00c,
set it to that and give verdict NF_REPEAT
If packet mark *is* 0xfaceb00c, accept the packet
2: Allow ENOBUFS to happen; treat as harmless when it does 3: Configure NFQA_CFG_F_FAIL_OPEN
4: Send packets to alternate -a queue
5: Force on test 4 and specify BYPASS
6: Exit nfq6 if incoming packet starts "q[:space:]" (e.g. q\n) 7: Use pktb_setup_raw
8: Use sendmsg to avoid memcpy after mangling
9: Replace 1st ASD by F
10: Replace 1st QWE by RTYUIOP (UDP packets only)
11: Replace 2nd ASD by G
12: Replace 2nd QWE by MNBVCXZ (UDP packets only)
13: Set 16MB kernel socket buffer
14: Report EINTR if we get it
15: Log netlink packets with no checksum
16: Log all netlink packets
17: Replace 1st ZXC by VBN
18: Replace 2nd ZXC by VBN
19: Enable tests 10 & 12 for TCP (not recommended)
20: Disable GSO
nfq6 can process any combination of IPv4, IPv6, TCP & UDP packets. Users can find examples of setting and testing packet marks, mangling packets and sending packets to another queue. Also the code suggests a method to deal with multiple protocols, as someone asked about on the netfilter list recently.
v2: 2 code changes:
1. Add test of no GSO
2. Accept packets we can't handle (we used to drop them)
4 cosmetic changes
1. Explain why 'bool' is an enum
2. Rename mangler function pointer to follow same convention as others.
3. Separate function pointers from function prototypes.
4. Add instructions to convert back to single-protocol app.
--- .gitignore | 1 + examples/Makefile.am | 6 +- examples/nfq6.c | 692 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 698 insertions(+), 1 deletion(-) create mode 100644 examples/nfq6.c
.gitignore +1 -0
@@ -19,6 +19,7 @@ Makefile.in /libnetfilter_queue.pc /examples/nf-queue +/examples/nfq6 /doxygen/doxyfile.stamp /doxygen/html/ /doxygen/man/
examples/Makefile.am +5 -1
@@ -1,7 +1,11 @@ include ${top_srcdir}/Make_global.am -check_PROGRAMS = nf-queue +check_PROGRAMS = nf-queue nfq6 nf_queue_SOURCES = nf-queue.c nf_queue_LDADD = ../src/libnetfilter_queue.la -lmnl nf_queue_LDFLAGS = -dynamic + +nfq6_SOURCES = nfq6.c +nfq6_LDADD = ../src/libnetfilter_queue.la -lmnl +nfq6_LDFLAGS = -dynamic
examples/nfq6.c new file +692 -0
692 lines not on this page · raw message
Signature · 1 line
2.35.8