libnetfilter_queue - remove packet from kernel buffer, and reinject later
Hi,
I've worked with libipq, and libnetfilter_queue, and i got to a place where my userspace code can't get anymore packets( with the message:
netlink message: no buffer space available ) .
Now what i want to do is this:
Read a packet from the queue, copy it to my own queue/location in my program, and re injecting the packet later on with my verdict, after i finished.
but to my best of my understanding, until i send a verdict the packet still takes place in the queue.
and i've read something about using NF_STOLEN and then reinject, but i dont think that NF_STOLEN is a valid verdict.
Any ideas on how i can do what it is i wish to do? ( Clear the kernel queue by transferring the packets to my queue ).
Kind regards
Levi Yechiel
Hello,
Quoted 9 lines · Mistick Levi
Hi,
I've worked with libipq, andlibnetfilter_queue, and i got to a place where my userspace code can't get anymore packets( with the message:
netlink message: no buffer space available ) .Now what i want to do is this:
Read a packet from the queue, copy it to my own queue/location in my program, and re injecting the packet later on with my verdict, after i finished.
This is how it works ;)
In fact, the 'no buffer space available' message is due to your program not getting packets as fast as needed: The kernel is sending packet to a netlink socket and the internal buffer of the socket gets filled with the packets waiting to be read.
What you need to do is:
* read packet as fast as you can (your callback function has to be fast)
* do the intensive or delay needing work outside of the callback (via a thread or something)
It last option is not possible, you can increase the netlink buffer size via the nfnl_rcvbufsiz function. "Standard" syntax is the following:
nfnl_rcvbufsiz(nfq_nfnlh(my_nfq_handle), NFQ_NF_BUFSIZE);
BR,
Quoted 15 lines
but to my best of my understanding, until i send a verdict the packet still takes place in the queue.
and i've read something about usingNF_STOLENand then reinject, but i dont think thatNF_STOLENis a valid verdict.Any ideas on how i can do what it is i wish to do? ( Clear the kernel queue by transferring the packets to my queue ).
Kind regards
Levi Yechiel
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Eric Leblond <[email protected]> INL: http://www.inl.fr/ NuFW: http://www.nufw.org/
2010/1/20 Eric Leblond <[email protected]>:
Quoted 20 lines
Hello,
Quoted 9 lines · Mistick Levi
Hi,
I've worked with libipq, andlibnetfilter_queue, and i got to a place where my userspace code can't get anymore packets( with the message:
netlink message: no buffer space available ) .Now what i want to do is this:
Read a packet from the queue, copy it to my own queue/location in my program, and re injecting the packet later on with my verdict, after i finished.This is how it works ;)
In fact, the 'no buffer space available' message is due to your program not getting packets as fast as needed: The kernel is sending packet to a netlink socket and the internal buffer of the socket gets filled with the packets waiting to be read.
Quoted 5 lines
What you need to do is:
* read packet as fast as you can (your callback function has to be fast)
* do the intensive or delay needing work outside of the callback (via a thread or something)
What do you mean by doing the delay needing work outside of the callback? in the end of the callback i should give a verdict, no ?
Quoted 5 lines
It last option is not possible, you can increase the netlink buffer size via the
nfnl_rcvbufsizfunction. "Standard" syntax is the following:
nfnl_rcvbufsiz(nfq_nfnlh(my_nfq_handle),NFQ_NF_BUFSIZE);
I will try that. what i have tried so far is increasing the:wmem_default, wmem_max, rmem_default and rmem_max.
Quoted 19 lines
BR,
Quoted 9 lines
but to my best of my understanding, until i send a verdict the packet still takes place in the queue.
and i've read something about usingNF_STOLENand then reinject, but i dont think thatNF_STOLENis a valid verdict.Any ideas on how i can do what it is i wish to do? ( Clear the kernel queue by transferring the packets to my queue ).
Quoted 6 lines
Kind regards
Levi Yechiel
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines
--
Eric Leblond <[email protected]>
INL: http://www.inl.fr/
NuFW: http://www.nufw.org/
Well, I have to do some logic before deciding if the packet ACCEPTED or DROPPED. and the callback is the one that decide that(send the verdict),
My original phrasing was bad so :
Question: is it possible to take the packet out from the internal socket(as with nfq_handle packet or recv() ) and return some verdict
like: "NF_STOLEN" ,then do the delay needing work, and then re inject the packet to continue its normal traversal.
Thanks in advance,
Levi Yechiel
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello,
Quoted 21 lines · Mistick Levi
2010/1/20 Eric Leblond <[email protected]>:
Quoted 20 lines
Hello,
Quoted 9 lines · Mistick Levi
Hi,
I've worked with libipq, andlibnetfilter_queue, and i got to a place where my userspace code can't get anymore packets( with the message:
netlink message: no buffer space available ) .Now what i want to do is this:
Read a packet from the queue, copy it to my own queue/location in my program, and re injecting the packet later on with my verdict, after i finished.This is how it works ;)
In fact, the 'no buffer space available' message is due to your program not getting packets as fast as needed: The kernel is sending packet to a netlink socket and the internal buffer of the socket gets filled with the packets waiting to be read.
Quoted 8 lines
Quoted 5 lines
What you need to do is:
* read packet as fast as you can (your callback function has to be fast)
* do the intensive or delay needing work outside of the callback (via a thread or something)What do you mean by doing the delay needing work outside of the callback? in the end of the callback i should give a verdict, no ?
No, this is not necessary. The verdict can be called from anywhere else in your program.
BR,
Signature · 3 lines
Eric Leblond <[email protected]> INL: http://www.inl.fr/ NuFW: http://www.nufw.org/