From: Patrick McHardy <kaber@trash.net>
To: davem@davemloft.net
Cc: netfilter-devel@lists.netfilter.org, Patrick McHardy <kaber@trash.net>
Subject: [NETFILTER 03/6]: nf_queue: fix rerouting after packet mangling
Date: Sat, 25 Feb 2006 14:18:11 +0100 (MET) [thread overview]
Message-ID: <20060225131630.7400.98595.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20060225131547.7400.12127.sendpatchset@localhost.localdomain>
[NETFILTER]: nf_queue: fix rerouting after packet mangling
Packets should be rerouted when they come back from userspace, not before.
Also move the queue_rerouters to RCU to avoid taking the queue_handler_lock
for each reinjected packet.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 5409613c1733e5162fb884865637d1607afcfbc9
tree 81e984ae53bd364b368ed77278ffda87202d20fc
parent 7ef7e9ed0e79dcb31560fc7d669a23ca2f230e09
author Patrick McHardy <kaber@trash.net> Sat, 25 Feb 2006 13:43:45 +0100
committer Patrick McHardy <kaber@trash.net> Sat, 25 Feb 2006 13:43:45 +0100
net/netfilter/nf_queue.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
index 1fc7152..c61f723 100644
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -6,6 +6,7 @@
#include <linux/skbuff.h>
#include <linux/netfilter.h>
#include <linux/seq_file.h>
+#include <linux/rcupdate.h>
#include <net/protocol.h>
#include "nf_internals.h"
@@ -64,7 +65,7 @@ int nf_register_queue_rerouter(int pf, s
return -EINVAL;
write_lock_bh(&queue_handler_lock);
- queue_rerouter[pf] = rer;
+ rcu_assign_pointer(queue_rerouter[pf], rer);
write_unlock_bh(&queue_handler_lock);
return 0;
@@ -77,8 +78,9 @@ int nf_unregister_queue_rerouter(int pf)
return -EINVAL;
write_lock_bh(&queue_handler_lock);
- queue_rerouter[pf] = NULL;
+ rcu_assign_pointer(queue_rerouter[pf], NULL);
write_unlock_bh(&queue_handler_lock);
+ synchronize_rcu();
return 0;
}
EXPORT_SYMBOL_GPL(nf_unregister_queue_rerouter);
@@ -114,6 +116,7 @@ int nf_queue(struct sk_buff **skb,
struct net_device *physindev = NULL;
struct net_device *physoutdev = NULL;
#endif
+ struct nf_queue_rerouter *rerouter;
/* QUEUE == DROP if noone is waiting, to be safe. */
read_lock(&queue_handler_lock);
@@ -155,15 +158,13 @@ int nf_queue(struct sk_buff **skb,
if (physoutdev) dev_hold(physoutdev);
}
#endif
- if (queue_rerouter[pf])
- queue_rerouter[pf]->save(*skb, info);
+ rerouter = rcu_dereference(queue_rerouter[pf]);
+ if (rerouter)
+ rerouter->save(*skb, info);
status = queue_handler[pf]->outfn(*skb, info, queuenum,
queue_handler[pf]->data);
- if (status >= 0 && queue_rerouter[pf])
- status = queue_rerouter[pf]->reroute(skb, info);
-
read_unlock(&queue_handler_lock);
if (status < 0) {
@@ -189,6 +190,7 @@ void nf_reinject(struct sk_buff *skb, st
{
struct list_head *elem = &info->elem->list;
struct list_head *i;
+ struct nf_queue_rerouter *rerouter;
rcu_read_lock();
@@ -226,6 +228,12 @@ void nf_reinject(struct sk_buff *skb, st
}
if (verdict == NF_ACCEPT) {
+ rerouter = rcu_dereference(queue_rerouter[info->pf]);
+ if (rerouter && rerouter->reroute(&skb, info) < 0)
+ verdict = NF_DROP;
+ }
+
+ if (verdict == NF_ACCEPT) {
next_hook:
verdict = nf_iterate(&nf_hooks[info->pf][info->hook],
&skb, info->hook,
next prev parent reply other threads:[~2006-02-25 13:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-25 13:17 [00/06]: Netfilter fixes for 2.6.16 Patrick McHardy
2006-02-25 13:17 ` [NETFILTER 01/6]: nf_queue: don't copy registered rerouter data Patrick McHardy
2006-02-25 13:17 ` [NETFILTER 02/6]: nf_queue: check if rerouter is present before using it Patrick McHardy
2006-02-25 13:18 ` Patrick McHardy [this message]
2006-02-25 13:18 ` [NETFILTER 04/6]: nf_queue: remove unnecessary check for outfn Patrick McHardy
2006-02-25 13:18 ` [NETFILTER 05/6]: nf_queue: fix end-of-list check Patrick McHardy
2006-02-25 13:18 ` [NETFILTER 06/6]: Restore {ipt,ip6t,ebt}_LOG compatibility Patrick McHardy
2006-02-25 14:13 ` Gregor Maier
2006-02-25 18:48 ` Patrick McHardy
2006-02-27 21:04 ` [00/06]: Netfilter fixes for 2.6.16 David S. Miller
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=20060225131630.7400.98595.sendpatchset@localhost.localdomain \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--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.