* [PATCH libnetfilter_queue 0/1] src: Comment-out code not needed since Linux 3.8 in examples/nf-queue.c
@ 2019-11-23 5:16 Duncan Roe
2019-11-23 5:16 ` [PATCH libnetfilter_queue 1/1] " Duncan Roe
0 siblings, 1 reply; 7+ messages in thread
From: Duncan Roe @ 2019-11-23 5:16 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel
This is the first in what I expect will be a number of patches to
examples/nf-queue.c as I update the documentation and maybe introduce new
helper functions.
An aspirational goal is to have all netfilter functions in nf-queue.c be
documented in the libnetfilter_queue web page.
Duncan Roe (1):
src: Comment-out code not needed since Linux 3.8 in
examples/nf-queue.c
examples/nf-queue.c | 48 +++++++++++++++++++++++++-----------------------
1 file changed, 25 insertions(+), 23 deletions(-)
--
2.14.5
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH libnetfilter_queue 1/1] src: Comment-out code not needed since Linux 3.8 in examples/nf-queue.c 2019-11-23 5:16 [PATCH libnetfilter_queue 0/1] src: Comment-out code not needed since Linux 3.8 in examples/nf-queue.c Duncan Roe @ 2019-11-23 5:16 ` Duncan Roe 2019-11-24 14:45 ` Florian Westphal 0 siblings, 1 reply; 7+ messages in thread From: Duncan Roe @ 2019-11-23 5:16 UTC (permalink / raw) To: pablo; +Cc: netfilter-devel This makes it clear which lines are no longer required. It also obviates the need to document NFQNL_CFG_CMD_PF_(UN)BIND. Add comment with sed command to re-enable commented-out code. Use // comments because my sed-fu is not up to reversing a /* comment block Signed-off-by: Duncan Roe <duncan_roe@optusnet.com.au> --- examples/nf-queue.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/examples/nf-queue.c b/examples/nf-queue.c index f6d254a..ee9e4f4 100644 --- a/examples/nf-queue.c +++ b/examples/nf-queue.c @@ -151,29 +151,31 @@ int main(int argc, char *argv[]) } /* PF_(UN)BIND is not needed with kernels 3.8 and later */ - nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, 0); - nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_PF_UNBIND); - - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { - perror("mnl_socket_send"); - exit(EXIT_FAILURE); - } - - nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, 0); - nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_PF_BIND); - - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { - perror("mnl_socket_send"); - exit(EXIT_FAILURE); - } - - nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, queue_num); - nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_BIND); - - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { - perror("mnl_socket_send"); - exit(EXIT_FAILURE); - } + /* Uncomment this code block if you need to cater for an older kernel */ + /* E.g. sed -i '156,178s+//++' examples/nf-queue.c */ + //nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, 0); + //nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_PF_UNBIND); + // + //if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { + // perror("mnl_socket_send"); + // exit(EXIT_FAILURE); + //} + // + //nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, 0); + //nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_PF_BIND); + // + //if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { + // perror("mnl_socket_send"); + // exit(EXIT_FAILURE); + //} + // + //nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, queue_num); + //nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_BIND); + // + //if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { + // perror("mnl_socket_send"); + // exit(EXIT_FAILURE); + //} nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, queue_num); nfq_nlmsg_cfg_put_params(nlh, NFQNL_COPY_PACKET, 0xffff); -- 2.14.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH libnetfilter_queue 1/1] src: Comment-out code not needed since Linux 3.8 in examples/nf-queue.c 2019-11-23 5:16 ` [PATCH libnetfilter_queue 1/1] " Duncan Roe @ 2019-11-24 14:45 ` Florian Westphal 2019-11-24 23:52 ` Duncan Roe 0 siblings, 1 reply; 7+ messages in thread From: Florian Westphal @ 2019-11-24 14:45 UTC (permalink / raw) To: Duncan Roe; +Cc: pablo, netfilter-devel Duncan Roe <duncan_roe@optusnet.com.au> wrote: > This makes it clear which lines are no longer required. > It also obviates the need to document NFQNL_CFG_CMD_PF_(UN)BIND. Why not simply #if 0 this code? Or just delete it, v3.8 was released almost 7 years ago. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH libnetfilter_queue 1/1] src: Comment-out code not needed since Linux 3.8 in examples/nf-queue.c 2019-11-24 14:45 ` Florian Westphal @ 2019-11-24 23:52 ` Duncan Roe 2019-11-25 21:10 ` Pablo Neira Ayuso 0 siblings, 1 reply; 7+ messages in thread From: Duncan Roe @ 2019-11-24 23:52 UTC (permalink / raw) To: Florian Westphal; +Cc: Pablo Neira Ayuso, Netfilter Development Hi Floerian, On Sun, Nov 24, 2019 at 03:45:47PM +0100, Florian Westphal wrote: > Duncan Roe <duncan_roe@optusnet.com.au> wrote: > > This makes it clear which lines are no longer required. > > It also obviates the need to document NFQNL_CFG_CMD_PF_(UN)BIND. > > Why not simply #if 0 this code? Simple reason: I think it's important to have an indicator on each commented-out line that it is,in fact, commented-out. > > Or just delete it, v3.8 was released almost 7 years ago. I could do that. But, I'm uneasy about it. There are systems around with very old Linuxes - in May last year there was that Tomato Firmware non-issue and the embedded environment was at 2.6! Your call (or Pablo's) - I'm happy either way. Cheers ... Duncan. On Sun, 27 May 2018 01:02:46 -0400, Edriss Mirzadeh wrote: > Hi there, > > I???m actually cross compiling Tomato Firmware using 64 bit Debian 9. > > The build instructions are good at the below URL, except for the repo name > which recently changed but hasn???t yet been updated in the readme > instructions. > > https://bitbucket.org/kille72/freshtomato-arm/src > > This could well be due to either the cross-compilation or the very old tool > chain, or ancient kernel 2.6 (with many back ports), but I do agree that > local headers should be double quoted, so your thought on patch rings true > in terms of portability. > > Cheers! ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH libnetfilter_queue 1/1] src: Comment-out code not needed since Linux 3.8 in examples/nf-queue.c 2019-11-24 23:52 ` Duncan Roe @ 2019-11-25 21:10 ` Pablo Neira Ayuso 2019-11-26 10:25 ` [PATCH libnetfilter_queue v2] src: Delete " Duncan Roe 0 siblings, 1 reply; 7+ messages in thread From: Pablo Neira Ayuso @ 2019-11-25 21:10 UTC (permalink / raw) To: Florian Westphal, Netfilter Development On Mon, Nov 25, 2019 at 10:52:40AM +1100, Duncan Roe wrote: > Hi Floerian, > > On Sun, Nov 24, 2019 at 03:45:47PM +0100, Florian Westphal wrote: > > Duncan Roe <duncan_roe@optusnet.com.au> wrote: > > > This makes it clear which lines are no longer required. > > > It also obviates the need to document NFQNL_CFG_CMD_PF_(UN)BIND. > > > > Why not simply #if 0 this code? > > Simple reason: I think it's important to have an indicator on each commented-out > line that it is,in fact, commented-out. > > > > Or just delete it, v3.8 was released almost 7 years ago. > > I could do that. But, I'm uneasy about it. There are systems around with very > old Linuxes - in May last year there was that Tomato Firmware non-issue and the > embedded environment was at 2.6! > > Your call (or Pablo's) - I'm happy either way. I think it's fine to remove it. There will be a commit message describing this is only required by very old kernel, which should be good enough for people with exotic environments to catch up I would expect. Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH libnetfilter_queue v2] src: Delete code not needed since Linux 3.8 in examples/nf-queue.c 2019-11-25 21:10 ` Pablo Neira Ayuso @ 2019-11-26 10:25 ` Duncan Roe 2019-11-26 10:44 ` Pablo Neira Ayuso 0 siblings, 1 reply; 7+ messages in thread From: Duncan Roe @ 2019-11-26 10:25 UTC (permalink / raw) To: pablo; +Cc: netfilter-devel The removed code sent configuration commands NFQNL_CFG_CMD_PF_UNBIND & NFQNL_CFG_CMD_PF_BIND which the kernel required prior to 3.8. Signed-off-by: Duncan Roe <duncan_roe@optusnet.com.au> --- examples/nf-queue.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/examples/nf-queue.c b/examples/nf-queue.c index f6d254a..960e244 100644 --- a/examples/nf-queue.c +++ b/examples/nf-queue.c @@ -150,23 +150,6 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - /* PF_(UN)BIND is not needed with kernels 3.8 and later */ - nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, 0); - nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_PF_UNBIND); - - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { - perror("mnl_socket_send"); - exit(EXIT_FAILURE); - } - - nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, 0); - nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_PF_BIND); - - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { - perror("mnl_socket_send"); - exit(EXIT_FAILURE); - } - nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, queue_num); nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_BIND); -- 2.14.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH libnetfilter_queue v2] src: Delete code not needed since Linux 3.8 in examples/nf-queue.c 2019-11-26 10:25 ` [PATCH libnetfilter_queue v2] src: Delete " Duncan Roe @ 2019-11-26 10:44 ` Pablo Neira Ayuso 0 siblings, 0 replies; 7+ messages in thread From: Pablo Neira Ayuso @ 2019-11-26 10:44 UTC (permalink / raw) To: Duncan Roe; +Cc: netfilter-devel On Tue, Nov 26, 2019 at 09:25:46PM +1100, Duncan Roe wrote: > The removed code sent configuration commands NFQNL_CFG_CMD_PF_UNBIND & > NFQNL_CFG_CMD_PF_BIND which the kernel required prior to 3.8. Applied, thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-11-26 10:44 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-11-23 5:16 [PATCH libnetfilter_queue 0/1] src: Comment-out code not needed since Linux 3.8 in examples/nf-queue.c Duncan Roe 2019-11-23 5:16 ` [PATCH libnetfilter_queue 1/1] " Duncan Roe 2019-11-24 14:45 ` Florian Westphal 2019-11-24 23:52 ` Duncan Roe 2019-11-25 21:10 ` Pablo Neira Ayuso 2019-11-26 10:25 ` [PATCH libnetfilter_queue v2] src: Delete " Duncan Roe 2019-11-26 10:44 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).