From: Patrick McHardy <kaber@trash.net>
To: Rennie deGraaf <degraaf@cpsc.ucalgary.ca>
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: Writing a match that communicates with userspace
Date: Wed, 19 Jul 2006 16:15:27 +0200 [thread overview]
Message-ID: <44BE3E7F.80700@trash.net> (raw)
In-Reply-To: <44BD6D43.7010607@cpsc.ucalgary.ca>
Rennie deGraaf wrote:
> I'm trying to write a match module for iptables that needs to call out
> to a userspace application (using netlink) for additional information
> before deciding if it should match a given packet or not. The delay
> before the userspace app. responds could be as much as a second or so;
> any longer, and the match should fail. My questions is, how could I
> implement such a system?
>
> What I was considering was to put my match() function into some sort of
> interruptible wait state after sending the request to userspace, and
> having my netlink socket callback wake up the match function. However,
> I haven't been able to figure out what sort of concurrency exists in
> netfilter (If one I block in match(), does that tie up the whole system
> until resuming, or are all packets handled in their own threads?), and
> the kernel debugging code complains whenever I call msleep() or mdelay()
> from within match(). I'm not sure how to implement this approach
> safely, or even if it is possible to do so.
>
> My other thought was to store packets in an internal queue and hotdrop
> them after sending the request to userspace, and having my netlink
> callback pull them out and reinject them where they left off, but have
> no idea how do the reinjecting or how to put an upper bound on the time
> packets wait in my internal queue. This design also seems to be quite a
> kludge.
>
> I suppose it would be possible for me to shoe-horn my match into a
> target, or even move the entire system to userspace and use NFQUEUE, but
> that would be even more of a kludge.
>
> Does anyone have any suggestions on how I could design and implement
> such a system? I would be grateful for any advice that you can give.
IIRC the geoip match doesn something similar, I guess you can find
some pointers there.
prev parent reply other threads:[~2006-07-19 14:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-18 23:22 Writing a match that communicates with userspace Rennie deGraaf
2006-07-19 14:15 ` Patrick McHardy [this message]
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=44BE3E7F.80700@trash.net \
--to=kaber@trash.net \
--cc=degraaf@cpsc.ucalgary.ca \
--cc=netfilter-devel@lists.netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.