From: Justin Yaple <yaplej@gmail.com>
To: netfilter-devel <netfilter-devel@vger.kernel.org>
Subject: exit netfilter queue processing
Date: Sun, 5 Dec 2010 18:05:39 -0800 [thread overview]
Message-ID: <AANLkTimyUqtT=dNFvgjyrsWWnDQQ6xRHmkSF0z7aLuSn@mail.gmail.com> (raw)
Hello,
I used the netfilter queue example for processing packets but one
thing that I could not find is how to safely stop everything. I setup
some sig handlers to try and be a little more graceful in terminating
with CTRL+C or when my service is stopped. My problem is that recv()
blocks so if there are no packets in the queue my servicestate might
be changed to STOPPED and there might not be any more packets in the
queue so it will wait indefinitely for recv().
I have been reading Linux System Programming and I think that a
select() around the recv() might do the trick but didnt know if there
was some other way to do this specific to netfilter. Maybe something
that would force recv() to return with a value of rv < 0.
while ((servicestate >= STOPPING) && ((rv = recv(fd, buf, sizeof(buf),
0)) && rv >= 0)) {
/*
* This will execute the callback_function for each ip packet
* that is received into the Netfilter QUEUE.
*/
nfq_handle_packet(h, buf, rv);
}
Thanks.
reply other threads:[~2010-12-06 2:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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='AANLkTimyUqtT=dNFvgjyrsWWnDQQ6xRHmkSF0z7aLuSn@mail.gmail.com' \
--to=yaplej@gmail.com \
--cc=netfilter-devel@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;
as well as URLs for NNTP newsgroup(s).