Linux Netfilter discussions
 help / color / mirror / Atom feed
From: "W. Michael Petullo" <mike@flyn.org>
To: netfilter@vger.kernel.org
Subject: Modifying NFQUEUE rules in flight
Date: Mon, 13 Mar 2017 21:18:38 -0400	[thread overview]
Message-ID: <20170314011838.GA9432@imp.flyn.org> (raw)

I have a question about the use of NFQUEUE from userspace.

Imagine two firewall rules:

        (A): NFQUEUE tcp -- imp x.x.x.x tcp dpt:http NFQUEUE num 0

and

        (B): NFQUEUE tcp -- imp x.x.x.x tcp dpt:http NFQUEUE num 1

I am interested in making the callback associated with rule (A)/NFQUEUE 0
remove rule (B) and replace it (usng firewalld/dbus in my case)
with another, more specific rule. For example, perhaps the callback for
NFQUEUE 0 would rewrite rule (B) to include a source port. I am further
interested in having this new rule apply to the packet being processed.

Is this type of modification in flight possible? By the time the callback
for (A)/NFQUEUE 0 is invoked, the kernel is obviously processing a packet
through the rule chain. In my experiments I have not been able to modify
the chain such that the kernel continues to push the packet through the
modified chain.

I assume that if this is possible it requires the proper use of NF_QUEUE,
NF_STOLEN, and so on. However, I have not yet come across a clear
description of the meaning of these values with respect to libnetfilter.

I can instead get what I want by copying some of the functionality in
(B)'s callback to (A)'s callback. However, the two callbacks really do
two different things, and futher (A) exists only for a short time. For
these reasons, I am trying to move the code to something which resembles
what I describe above.

Any comments would be helpful.

Thank you,

-- 
Mike

:wq

             reply	other threads:[~2017-03-14  1:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-14  1:18 W. Michael Petullo [this message]
2017-03-14  8:08 ` Modifying NFQUEUE rules in flight Eric Leblond

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170314011838.GA9432@imp.flyn.org \
    --to=mike@flyn.org \
    --cc=netfilter@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox