Linux Netfilter discussions
 help / color / mirror / Atom feed
* NFQNL_COPY_META not working?
@ 2011-10-26 11:24 Andreas Birkjær (ABI)
  2011-10-26 13:00 ` Eric Leblond
  2011-10-26 16:48 ` Sam Roberts
  0 siblings, 2 replies; 3+ messages in thread
From: Andreas Birkjær (ABI) @ 2011-10-26 11:24 UTC (permalink / raw)
  To: netfilter@vger.kernel.org

Hello.

I have been trying to get the the netfilter queue working, everything is seemingly allright as long as I pass the entire packet to userspace. (nfq_set_mode(qh, NFQNL_COPY_PACKET, 0xfffff)).
It should be noted that I am testing this on the nfqnl_test.c which is found here: http://svn.netfilter.org/netfilter/trunk/libnetfilter_queue/utils/nfqnl_test.c

As long as I copy the entire packet to userspace, everything seems to be running smoothly, I can retrieve whatever I want from the packet.

However, I do not want to pass the entire packet to userspace - I just need to check/modify the IP and/or TCP header and then pass the packet along. When I try to use the NFQNL_COPY_META mode, then the program fails. (I am testing this on the beforementioned nfqnl_test.c file with no modifications beside the META mode.

Apparently the nfq_get_payload() function always returns -1.

I have tried searching for an answer, but almost everywhere I look, people are happy passing the entire packet, does the nfqnl_test.c need additional modifications in order to run in NFQNL_COPY_META mode or what?
When using NFQNL_COPY_META mode, I still get some output from the queue (hw_protocol, hook, packet id etc) but as stated, the nfq_get_payload returns -1.

I have not found anything on the official site stating that additional modifications are needed when running in META mode, but I might be overlooking something?

Another small question, I am a little unclear as to exactly what information is passed in META mode. As far as I can understand, the content of the headers are passed to userspace right? Meaning IP/TCP/HTTP... headers are passed but payload is not?

I hope someone is able to help me get to the bottom of this.

Kind regards
Andreas



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: NFQNL_COPY_META not working?
  2011-10-26 11:24 NFQNL_COPY_META not working? Andreas Birkjær (ABI)
@ 2011-10-26 13:00 ` Eric Leblond
  2011-10-26 16:48 ` Sam Roberts
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Leblond @ 2011-10-26 13:00 UTC (permalink / raw)
  To: Andreas Birkjær (ABI), netfilter@vger.kernel.org

Hello


"Andreas Birkjær (ABI)" <abi@thrane.com> a écrit :

>Hello.
>
>I have been trying to get the the netfilter queue working, everything
>is seemingly allright as long as I pass the entire packet to userspace.
>(nfq_set_mode(qh, NFQNL_COPY_PACKET, 0xfffff)).
>It should be noted that I am testing this on the nfqnl_test.c which is
>found here:
>http://svn.netfilter.org/netfilter/trunk/libnetfilter_queue/utils/nfqnl_test.c

Copy Meta will not send the payload to userspace. If you want a partial transfer of payload use copy packet and put the size as second parameter of nfq-set-mode.

BR

>
>As long as I copy the entire packet to userspace, everything seems to
>be running smoothly, I can retrieve whatever I want from the packet.
>
>However, I do not want to pass the entire packet to userspace - I just
>need to check/modify the IP and/or TCP header and then pass the packet
>along. When I try to use the NFQNL_COPY_META mode, then the program
>fails. (I am testing this on the beforementioned nfqnl_test.c file with
>no modifications beside the META mode.
>
>Apparently the nfq_get_payload() function always returns -1.
>
>I have tried searching for an answer, but almost everywhere I look,
>people are happy passing the entire packet, does the nfqnl_test.c need
>additional modifications in order to run in NFQNL_COPY_META mode or
>what?
>When using NFQNL_COPY_META mode, I still get some output from the queue
>(hw_protocol, hook, packet id etc) but as stated, the nfq_get_payload
>returns -1.
>
>I have not found anything on the official site stating that additional
>modifications are needed when running in META mode, but I might be
>overlooking something?
>
>Another small question, I am a little unclear as to exactly what
>information is passed in META mode. As far as I can understand, the
>content of the headers are passed to userspace right? Meaning
>IP/TCP/HTTP... headers are passed but payload is not?
>
>I hope someone is able to help me get to the bottom of this.
>
>Kind regards
>Andreas
>
>
>--
>To unsubscribe from this list: send the line "unsubscribe netfilter" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Envoyé de mon téléphone Android avec K-9 Mail. Excusez la brièveté.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: NFQNL_COPY_META not working?
  2011-10-26 11:24 NFQNL_COPY_META not working? Andreas Birkjær (ABI)
  2011-10-26 13:00 ` Eric Leblond
@ 2011-10-26 16:48 ` Sam Roberts
  1 sibling, 0 replies; 3+ messages in thread
From: Sam Roberts @ 2011-10-26 16:48 UTC (permalink / raw)
  To: Andreas Birkjær (ABI), netfilter

On Wed, Oct 26, 2011 at 4:24 AM, Andreas Birkjær (ABI) <abi@thrane.com> wrote:
> However, I do not want to pass the entire packet to userspace - I just need to check/modify the IP and/or TCP header and then pass the packet along.

nfq_set_verdict() doesn't allow modifying only a part of the packet,
to my knowledge. You either accept/drop the entire packet, or replace
the entire packet.

Cheers,
Sam

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-26 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-26 11:24 NFQNL_COPY_META not working? Andreas Birkjær (ABI)
2011-10-26 13:00 ` Eric Leblond
2011-10-26 16:48 ` Sam Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox