From: Kuzin Andrey <kuzinandrey@yandex.ru>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH]: drop packet without verdict from nfqueue after timeout
Date: Mon, 23 Mar 2009 21:48:23 +0300 [thread overview]
Message-ID: <1691181420.20090323214823@yandex.ru> (raw)
This is patch for problem with stucked packets in nf_queue if
something going wrong in userspace program. Automatically drop packets
without any verdict after timeout defined by NFQNL_TIMEOUT_ENTRY_DROP.
Who may create patch for menu config for this feature ?
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 8c86011..74fc322 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -169,17 +169,29 @@ __enqueue_entry(struct nfqnl_instance *queue, struct nf_queue_entry *entry)
queue->queue_total++;
}
+#define NFQNL_TIMEOUT_ENTRY_DROP 30
+
static struct nf_queue_entry *
find_dequeue_entry(struct nfqnl_instance *queue, unsigned int id)
{
- struct nf_queue_entry *entry = NULL, *i;
+ struct nf_queue_entry *entry = NULL, *next, *i;
+ ktime_t kt = ktime_get_real();
spin_lock_bh(&queue->lock);
- list_for_each_entry(i, &queue->queue_list, list) {
+ list_for_each_entry_safe(i, next, &queue->queue_list, list) {
if (i->id == id) {
entry = i;
break;
+ } else {
+ struct timeval tv = ktime_to_timeval(ktime_sub(kt, i->skb->tstamp));
+ if (tv.tv_sec > NFQNL_TIMEOUT_ENTRY_DROP) {
+ printk(KERN_ERR "nf_queue: drop timeouted packet "
+ "(queue_num=%u seq_id=%u)\n", queue->queue_num, i->id);
+ list_del(&i->list);
+ queue->queue_total--;
+ nf_reinject(i, NF_DROP);
+ }
}
}
next reply other threads:[~2009-03-23 18:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-23 18:48 Kuzin Andrey [this message]
2009-03-23 19:18 ` [PATCH]: drop packet without verdict from nfqueue after timeout Patrick McHardy
2009-03-23 22:05 ` Eric Leblond
2009-03-23 22:15 ` Patrick McHardy
2009-03-24 5:23 ` Re[2]: " Kuzin Andrey
2009-03-24 3:17 ` Kuzin Andrey
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=1691181420.20090323214823@yandex.ru \
--to=kuzinandrey@yandex.ru \
--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