utils: Add example of setting socket buffer size
PATCH 1/1 utils: Add example of setting socket buffer size
The libnetfilter_queue main HTML page mentions nfnl_rcvbufsiz() so the new libmnl-only libnetfilter_queue will have to support it.
The added call acts as a demo and a test case.
--- utils/nfqnl_test.c | 5 +++++ 1 file changed, 5 insertions(+)
utils/nfqnl_test.c +5 -0
@@ -91,6 +91,7 @@ int main(int argc, char **argv)int fd;int rv;uint32_t queue =0 ; +uint32_t ret; char buf[4096] __attribute__ ((aligned));if (argc ==2 ) {
@@ -107,6 +108,10 @@ int main(int argc, char **argv)fprintf (stderr,"error during nfq_open()\n" );exit (1 ); } +printf ("setting socket buffer size to 2MB\n" ); + ret =nfnl_rcvbufsiz (nfq_nfnlh (h),1024 *1024 ); +printf ("Read buffer set to 0x%x bytes (%gMB)\n" , ret, + ret /1024.0 /1024 );printf ("unbinding existing nf_queue handler for AF_INET (if any)\n" );if (nfq_unbind_pf (h,AF_INET ) <0 ) {
Signature · 1 line
2.35.8
Pablo Neira Ayuso
maintainerQuoted 23 lines · Duncan Roe
The
libnetfilter_queuemain HTML page mentionsnfnl_rcvbufsiz()so the new libmnl-onlylibnetfilter_queuewill have to support it.The added call acts as a demo and a test case.
Signed-off-by Duncan Roe <[email protected]>--- utils/nfqnl_test.c | 5 +++++ 1 file changed, 5 insertions(+)utils/nfqnl_test.c +1
-0@@ -91,6 +91,7 @@ int main(int argc, char **argv)int fd;int rv;uint32_t queue =0 ; +uint32_t ret; char buf[4096] __attribute__ ((aligned));if (argc ==2 ) {
utils/nfqnl_test.c int main(int argc, char **argv) · line 112
Quoted 5 lines
utils/nfqnl_test.c +2
-0@@ -107,6 +108,10 @@ int main(int argc, char **argv)fprintf (stderr,"error during nfq_open()\n" );exit (1 ); } +printf ("setting socket buffer size to 2MB\n" ); + ret =nfnl_rcvbufsiz (nfq_nfnlh (h),1024 *1024 );
libnfnetlink is deprecated.
maybe call setsockopt and use nfq_fd() instead if you would like that this shows in the example file.
Quoted 8 lines
utils/nfqnl_test.c +2
-0+printf ("Read buffer set to 0x%x bytes (%gMB)\n" , ret, + ret /1024.0 /1024 );printf ("unbinding existing nf_queue handler for AF_INET (if any)\n" );if (nfq_unbind_pf (h,AF_INET ) <0 ) {Signature · 1 line
2.35.8
Cc'ing list this time
----- Forwarded message from Duncan Roe <[email protected]> -----
Date: Wed, 15 Nov 2023 10:46:34 +1100
From: Duncan Roe <[email protected]>
To: Pablo Neira Ayuso <[email protected]>
Subject: Re: [PATCH libnetfilter_queue] utils: Add example of setting socket buffer size
Hi Pablo,
Quoted 22 lines · Pablo Neira Ayuso
Quoted 21 lines · Duncan Roe
The
libnetfilter_queuemain HTML page mentionsnfnl_rcvbufsiz()so the new libmnl-onlylibnetfilter_queuewill have to support it.The added call acts as a demo and a test case.
Signed-off-by Duncan Roe <[email protected]>--- utils/nfqnl_test.c | 5 +++++ 1 file changed, 5 insertions(+)utils/nfqnl_test.c +1
-0@@ -91,6 +91,7 @@ int main(int argc, char **argv)int fd;int rv;uint32_t queue =0 ; +uint32_t ret; char buf[4096] __attribute__ ((aligned));
Quoted 9 lines
utils/nfqnl_test.c int main(int argc, char **argv) · line 112
Quoted 7 lines
utils/nfqnl_test.c +2
-0if (argc ==2 ) {@@ -107,6 +108,10 @@ int main(int argc, char **argv)fprintf (stderr,"error during nfq_open()\n" );exit (1 ); } +printf ("setting socket buffer size to 2MB\n" ); + ret =nfnl_rcvbufsiz (nfq_nfnlh (h),1024 *1024 );libnfnetlink is deprecated.
Yes I know that, obviously:)
Quoted 12 lines
maybe call setsockopt and use
nfq_fd()instead if you would like that this shows in the example file.Quoted 8 lines
utils/nfqnl_test.c +2
-1+printf ("Read buffer set to 0x%x bytes (%gMB)\n" , ret, + ret /1024.0 /1024 );printf ("unbinding existing nf_queue handler for AF_INET (if any)\n" );if (nfq_unbind_pf (h,AF_INET ) <0 ) { --2.35.8
The point here is that nfnl_rcvbufsiz() has been advertised in the main page of libnetfilter_queue HTML for a long time and there are likely a number of systems out there that use it. When libnfnetlink is removed, libnetfilter_queue will have to provide nfnl_rcvbufsiz() or those systems will start failing.
I have in mind that although libnetfilter_queue will provide nfnl_rcvbufsiz(), there will be no documentation for it.
You will see in
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
I replaced the advice to use nfnl_rcvbufsiz() (in 2 places) with advice to use setsocketopt(). I only mentioned that programs calling nfnl_rcvbufsiz() will continue to run.
So I offered this patch as the only documentation of how to use nfnl_rcvbufsiz(). I need it for my testing, but it's fine with me if you don't want to take it.
I could add a setsockopt() example to nf-queue or nfqnl_test if you like.
Cheers ... Duncan.
----- End forwarded message -----