Skip to contentSkip to conversation

NFQUEUE verdicts - adding non-termination

DISCUSSION Andrew Watts 3 participants 9 messages Nov 11, 2010 – Nov 16, 2010 netfilter

lore
Share & tools
lore
#0 lore raw

Hi.

The NF_CONTINUE verdict that Darryl Miles brings up in his 11/4 post is very interesting.

NF_CONTINUE would provide the NFQUEUE target the added flexibility of, say, partial handling in userspace. A queue-handler could have a set of criteria that, when satisfied, would result in an immediate drop or accept. One could then leave the rest of the packets to find their fate in the chains/rules left to traverse.

I would be interested in helping to add this verdict if someone will take the lead (assuming a patch hasn't already been written - has it?).

Your comments appreciated.

~ Andy

#1 lore raw
Quoted 7 lines · Andrew Watts

Hi.

The NF_CONTINUE verdict that Darryl Miles brings up in his 11/4 post is very interesting.

NF_CONTINUE would provide the NFQUEUE target the added flexibility of, say, partial handling in userspace. A queue-handler could have a set of criteria that, when satisfied, would result in an immediate drop or accept. One could then leave the rest of the packets to find their fate in the chains/rules left to traverse.

I would be interested in helping to add this verdict if someone will take the lead (assuming a patch hasn't already been written - has it?).

There's no difference between returning NF_ACCEPT or a new NF_CONTINUE. Queueing happens outside of the ruleset context, so in either case the packet would continue through the network stack directly, not after the NFQUEUE rule.

#2 lore raw
Quoted 13 lines · Patrick McHardy
Quoted 11 lines · Andrew Watts

Hi.

The NF_CONTINUE verdict that Darryl Miles brings up in his 11/4 post is very interesting. NF_CONTINUE would provide the NFQUEUE target the added flexibility of, say, partial handling in userspace. A queue-handler could have a set of criteria that, when satisfied, would result in an immediate drop or accept. One could then leave the rest of the packets to find their fate in the chains/rules left to traverse. I would be interested in helping to add this verdict if someone will take the lead (assuming a patch hasn't already been written - has it?).

Quoted 4 lines

There's no difference between returning NF_ACCEPT or a new NF_CONTINUE. Queueing happens outside of the ruleset context, so in either case the packet would continue through the network stack directly, not after the NFQUEUE rule.

I see. Is there a way to achieve this result under the current infrastructure?

~ Andy

#3 lore raw

Am 12.11.2010 12:01, schrieb Andrew Watts:

Quoted 15 lines
Quoted 12 lines · Patrick McHardy
Quoted 11 lines · Andrew Watts

Hi.

The NF_CONTINUE verdict that Darryl Miles brings up in his 11/4 post is very interesting. NF_CONTINUE would provide the NFQUEUE target the added flexibility of, say, partial handling in userspace. A queue-handler could have a set of criteria that, when satisfied, would result in an immediate drop or accept. One could then leave the rest of the packets to find their fate in the chains/rules left to traverse. I would be interested in helping to add this verdict if someone will take the lead (assuming a patch hasn't already been written - has it?).

Quoted 7 lines
Quoted 4 lines

There's no difference between returning NF_ACCEPT or a new NF_CONTINUE. Queueing happens outside of the ruleset context, so in either case the packet would continue through the network stack directly, not after the NFQUEUE rule.

I see. Is there a way to achieve this result under the current infrastructure?

Having the packet continue after the NFQUEUE rule? No, once the packet is reinjected, that rule might not even be there anymore.

#4 lore raw
Quoted 21 lines · Patrick McHardy

Am 12.11.2010 12:01, schrieb Andrew Watts:

Quoted 20 lines
Quoted 17 lines · Patrick McHardy
Quoted 11 lines · Andrew Watts

Hi.

The NF_CONTINUE verdict that Darryl Miles brings up in his 11/4 post is very interesting. NF_CONTINUE would provide the NFQUEUE target the added flexibility of, say, partial handling in userspace. A queue-handler could have a set of criteria that, when satisfied, would result in an immediate drop or accept. One could then leave the rest of the packets to find their fate in the chains/rules left to traverse. I would be interested in helping to add this verdict if someone will take the lead (assuming a patch hasn't already been written - has it?).

There's no difference between returning NF_ACCEPT or a new NF_CONTINUE. Queueing happens outside of the ruleset context, so in either case the packet would continue through the network stack directly, not after the NFQUEUE rule.

Quoted 5 lines
Quoted 2 lines

I see. Is there a way to achieve this result under the current infrastructure?

Having the packet continue after the NFQUEUE rule? No, once the packet is reinjected, that rule might not even be there anymore.

Actually, what you can do is use NF_REPEAT as verdict and have the packet continue at the next rule based on marks. Something like this:

Chain INPUT:
-m mark --mark 0 -j NOT_QUEUED
-m mark --mark 1 -j BACK_FROM_QUEUE

Chain NOT_QUEUED:
... rules ...
-j NFQUEUE

[ nfqueue: return NF_REPEAT, set mark = 1 ]

Chain BACK_FROM_QUEUE:
... further rules ...

#5 lore raw
Quoted 58 lines · Patrick McHardy

From: Patrick McHardy <[email protected]>
Subject: Re: NFQUEUE verdicts - adding non-termination
To: "Andrew Watts" <[email protected]>
Cc: [email protected]
Date: Friday, November 12, 2010, 11:19 AM

Quoted 2 lines · Patrick McHardy

Am 12.11.2010 12:01, schrieb Andrew Watts:

Quoted 1 line

--- On Thu, 11/11/10, Patrick McHardy <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines
Quoted 5 lines · Andrew Watts
Quoted 3 lines

Hi.

The NF_CONTINUE verdict that Darryl Miles

brings up in his 11/4

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

post is very interesting. NF_CONTINUE

would provide the NFQUEUE

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

target the added flexibility of, say,

partial handling in

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

userspace. A queue-handler could have a

set of criteria that,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

when satisfied, would result in an

immediate drop or accept. One

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

could then leave the rest of the packets

to find their fate in the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

chains/rules left to traverse. I would be

interested in helping

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

to add this verdict if someone will take

the lead (assuming a patch

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

hasn't already been written - has it?).

There's no difference between returning

NF_ACCEPT or a new NF_CONTINUE.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Queueing happens outside of the ruleset

context, so in either case the

Quoted 1 line
Quoted 1 line
Quoted 1 line

packet would continue through the network

stack directly, not after

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

the NFQUEUE rule.

I see. Is there a way to achieve this result under

the current

Quoted 3 lines
Quoted 1 line

infrastructure?

Having the packet continue after the NFQUEUE rule? No,

once the packet

Quoted 1 line

is reinjected, that rule might not even be there

anymore.

Actually, what you can do is use NF_REPEAT as verdict and have the
packet continue at the next rule based on marks. Something like this:

Chain INPUT:

(quoted diff) +0 -2
-m mark --mark 0 -j NOT_QUEUED
-m mark --mark 1 -j BACK_FROM_QUEUE
Quoted 9 lines

Chain NOT_QUEUED:
... rules ...
-j NFQUEUE

[ nfqueue: return NF_REPEAT, set mark = 1 ]

Chain BACK_FROM_QUEUE:
... further rules ...

Yes, that works quite well. If the fork is placed near the start of the chain, you reduce the amount of redundant traversing since it seems it goes back to square one. I initially misunderstood the NF_REPEAT verdict after looking at the libnetfilter_queue source "NF_REPEAT iterate the same cycle once more".

~ Andy

#6 lore raw
In reply to Patrick McHardy
Quoted 5 lines · Patrick McHardy
Quoted 4 lines · Andrew Watts

Hi.

The NF_CONTINUE verdict that Darryl Miles brings up in his 11/4 post is very interesting.

Quoted 8 lines
Quoted 3 lines

NF_CONTINUE would provide the NFQUEUE target the added flexibility of, say, partial handling in userspace. A queue-handler could have a set of criteria that, when satisfied, would result in an immediate drop or accept. One could then leave the rest of the packets to find their fate in the chains/rules left to traverse.

I would be interested in helping to add this verdict if someone will take the lead (assuming a patch hasn't already been written - has it?).

There's no difference between returning NF_ACCEPT or a new NF_CONTINUE. Queueing happens outside of the ruleset context, so in either case the packet would continue through the network stack directly, not after the NFQUEUE rule.

I've been interested in this thread since I recently converted our version of snort inline to use NFQUEUE instead of QUEUE. One of driving factors was that I needed to have multiple QUEUE targets. While I was doing the work I was hoping there was a verdict like NF_RETURN, so that if it passed the snort inspection then I could have another NFQUEUE target that would do https domain filtering. From reading this thread I now understand why I can just continue, but I wondering what is that the recommended approach for this type of use case? As it is now, I think I would need to have the 2nd NFQUEUE target on a different hook.

stig

#7 lore raw
Quoted 15 lines · Stig Thormodsrud
Quoted 5 lines · Patrick McHardy
Quoted 4 lines · Andrew Watts

Hi.

The NF_CONTINUE verdict that Darryl Miles brings up in his 11/4 post is very interesting.

Quoted 8 lines
Quoted 3 lines

NF_CONTINUE would provide the NFQUEUE target the added flexibility of, say, partial handling in userspace. A queue-handler could have a set of criteria that, when satisfied, would result in an immediate drop or accept. One could then leave the rest of the packets to find their fate in the chains/rules left to traverse.

I would be interested in helping to add this verdict if someone will take the lead (assuming a patch hasn't already been written - has it?).

There's no difference between returning NF_ACCEPT or a new NF_CONTINUE. Queueing happens outside of the ruleset context, so in either case the packet would continue through the network stack directly, not after the NFQUEUE rule.

Quoted 9 lines

I've been interested in this thread since I recently converted our version of snort inline to use NFQUEUE instead of QUEUE. One of driving factors was that I needed to have multiple QUEUE targets. While I was doing the work I was hoping there was a verdict like NF_RETURN, so that if it passed the snort inspection then I could have another NFQUEUE target that would do https domain filtering. From reading this thread I now understand why I can just continue, but I wondering what is that the recommended approach for this type of use case? As it is now, I think I would need to have the 2nd NFQUEUE target on a different hook.

Look at my second response to Andrew, you can use NF_REPEAT and some mark based jumps to do this. You can also return NF_QUEUE from userspace directly and encode the queue number in the upper 16 bits.

#8 lore raw
Quoted 49 lines · Patrick McHardy

From: Patrick McHardy <[email protected]>
Subject: Re: NFQUEUE verdicts - adding non-termination
To: "Stig Thormodsrud" <[email protected]>
Cc: "Andrew Watts" <[email protected]>, [email protected]
Date: Monday, November 15, 2010, 10:34 AM

Quoted 5 lines · Stig Thormodsrud
Quoted 4 lines · Patrick McHardy
Quoted 3 lines · Andrew Watts

Hi.

The NF_CONTINUE verdict that Darryl Miles

brings up in his 11/4 post is very interesting.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

NF_CONTINUE would provide the NFQUEUE target

the added flexibility of, say, partial handling in userspace. A queue-handler could have a set of criteria that, when satisfied, would result in an immediate drop or accept. One could then leave the rest of the packets to find their fate in the chains/rules left to traverse.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I would be interested in helping to add this

verdict if someone will take the lead (assuming a patch hasn't already been written - has it?).

Quoted 2 lines
Quoted 2 lines

There's no difference between returning NF_ACCEPT

or a new NF_CONTINUE.

Quoted 1 line
Quoted 1 line

Queueing happens outside of the ruleset context,

so in either case the

Quoted 1 line
Quoted 1 line

packet would continue through the network stack

directly, not after

Quoted 3 lines
Quoted 1 line

the NFQUEUE rule.

I've been interested in this thread since I recently

converted our

Quoted 1 line

version of snort inline to use NFQUEUE instead of

QUEUE.  One of driving

Quoted 1 line

factors was that I needed to have multiple QUEUE

targets.  While I was

Quoted 1 line

doing the work I was hoping there was a verdict like

NF_RETURN, so that

Quoted 1 line

if it passed the snort inspection then I could have

another NFQUEUE

Quoted 1 line

target that would do https domain filtering.

From reading this thread I

Quoted 1 line

now understand why I can just continue, but I

wondering what is that the

Quoted 1 line

recommended approach for this type of use case?

As it is now, I think I

Quoted 9 lines
Quoted 1 line

would need to have the 2nd NFQUEUE target on a

different hook.

Look at my second response to Andrew, you can use NF_REPEAT and some
mark based jumps to do this. You can also return NF_QUEUE from userspace
directly and encode the queue number in the upper 16 bits.

Patrick, many thanks for the guidance on this. Your advice was right on.

Stig, something to consider in addition to Patrick's comment is that you can make the mark-based decision more complex than just binary. Then a single queue handler can process according to different mark values and increment the mark on each return (until a termination value is reached).

~ Andy

--
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